sbuild  1.6.5
sbuild-parse-error.h
1 /* Copyright © 2005-2007 Roger Leigh <rleigh@debian.org>
2  *
3  * schroot is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * schroot is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  *********************************************************************/
18 
19 #ifndef SBUILD_PARSE_ERROR_H
20 #define SBUILD_PARSE_ERROR_H
21 
22 #include <sbuild/sbuild-custom-error.h>
23 #include <sbuild/sbuild-null.h>
24 
25 #include <map>
26 #include <string>
27 
28 namespace sbuild
29 {
30 
34  template<typename T>
35  class parse_error : public error<T>
36  {
37  public:
38  typedef typename error<T>::error_type error_type;
39 
46  template<typename C>
47  parse_error (C const& context,
49  sbuild::error<T>(this->format_error(context, null(), null(), error, null(), null(), null()),
50  this->format_reason(context, null(), null(), error, null(), null(), null()))
51  {
52  }
53 
60  template<typename D>
62  D const& detail):
63  sbuild::error<T>(this->format_error(null(), null(), null(), error, detail, null(), null()),
64  this->format_reason(null(), null(), null(), error, detail, null(), null()))
65  {
66  }
67 
75  template<typename D>
76  parse_error (size_t line,
78  D const& detail):
79  sbuild::error<T>(this->format_error(line, null(), null(), error, detail, null(), null()),
80  this->format_reason(line, null(), null(), error, detail, null(), null()))
81  {
82  }
83 
92  template<typename D>
93  parse_error (size_t line,
94  std::string const& group,
96  D const& detail):
97  sbuild::error<T>(this->format_error(line, group, null(), error, detail, null(), null()),
98  this->format_reason(line, group, null(), error, detail, null(), null()))
99  {
100  }
101 
111  template<typename D>
112  parse_error (size_t line,
113  std::string const& group,
114  std::string const& key,
116  D const& detail):
117  sbuild::error<T>(this->format_error(line, group, key, error, detail, null(), null()),
118  this->format_reason(line, group, key, error, detail, null(), null()))
119  {
120  }
121 
129  template<typename D>
130  parse_error (std::string const& group,
132  D const& detail):
133  sbuild::error<T>(this->format_error(group, null(), null(), error, detail, null(), null()),
134  this->format_reason(group, null(), null(), error, detail, null(), null()))
135  {
136  }
137 
146  template<typename D>
147  parse_error (std::string const& group,
148  std::string const& key,
150  D const& detail):
151  sbuild::error<T>(this->format_error(group, key, null(), error, detail, null(), null()),
152  this->format_reason(group, key, null(), error, detail, null(), null()))
153  {
154  }
155 
162  template<typename C>
163  parse_error (C const& context,
164  std::runtime_error const& error):
165  sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null(), null()),
166  sbuild::error<T>::format_reason(context, null(), null(), error, null(), null(), null()))
167  {
168  }
169 
176  parse_error (size_t line,
177  std::runtime_error const& error):
178  sbuild::error<T>(sbuild::error<T>::format_error(line, null(), null(), error, null(), null(), null()),
179  sbuild::error<T>::format_reason(line, null(), null(), error, null(), null(), null()))
180  {
181  }
182 
190  parse_error (size_t line,
191  std::string const& group,
192  std::runtime_error const& error):
193  sbuild::error<T>(sbuild::error<T>::format_error(line, group, null(), error, null(), null(), null()),
194  sbuild::error<T>::format_reason(line, group, null(), error, null(), null(), null()))
195  {
196  }
197 
206  parse_error (size_t line,
207  std::string const& group,
208  std::string const& key,
209  std::runtime_error const& error):
210  sbuild::error<T>(sbuild::error<T>::format_error(line, group, key, error, null(), null(), null()),
211  sbuild::error<T>::format_reason(line, group, key, error, null(), null(), null()))
212  {
213  }
214 
221  parse_error (std::string const& group,
222  std::runtime_error const& error):
223  sbuild::error<T>(sbuild::error<T>::format_error(group, null(), null(), error, null(), null(), null()),
224  sbuild::error<T>::format_reason(group, null(), null(), error, null(), null(), null()))
225  {
226  }
227 
235  parse_error (std::string const& group,
236  std::string const& key,
237  std::runtime_error const& error):
238  sbuild::error<T>(sbuild::error<T>::format_error(group, key, null(), error, null(), null(), null()),
239  sbuild::error<T>::format_reason(group, key, null(), error, null(), null(), null()))
240  {
241  }
242 
243  };
244 
245 }
246 
247 #endif /* SBUILD_PARSE_ERROR_H */
248 
249 /*
250  * Local Variables:
251  * mode:C++
252  * End:
253  */