sbuild 1.4.23
sbuild-parse-error.h
00001 /* Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
00002  *
00003  * schroot is free software: you can redistribute it and/or modify it
00004  * under the terms of the GNU General Public License as published by
00005  * the Free Software Foundation, either version 3 of the License, or
00006  * (at your option) any later version.
00007  *
00008  * schroot is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>.
00016  *
00017  *********************************************************************/
00018 
00019 #ifndef SBUILD_PARSE_ERROR_H
00020 #define SBUILD_PARSE_ERROR_H
00021 
00022 #include <sbuild/sbuild-custom-error.h>
00023 #include <sbuild/sbuild-null.h>
00024 
00025 #include <map>
00026 #include <string>
00027 
00028 namespace sbuild
00029 {
00030 
00034   template<typename T>
00035   class parse_error : public error<T>
00036   {
00037   public:
00038     typedef typename error<T>::error_type error_type;
00039 
00046     template<typename C>
00047     parse_error (C const&   context,
00048                  error_type error):
00049       sbuild::error<T>(format_error(context, null(), null(), error, null(), null(), null()),
00050                        format_reason(context, null(), null(), error, null(), null(), null()))
00051     {
00052     }
00053 
00060     template<typename D>
00061     parse_error (error_type error,
00062                  D const&   detail):
00063       sbuild::error<T>(format_error(null(), null(), null(), error, detail, null(), null()),
00064                        format_reason(null(), null(), null(), error, detail, null(), null()))
00065     {
00066     }
00067 
00075     template<typename D>
00076     parse_error (size_t     line,
00077                  error_type error,
00078                  D const&   detail):
00079       sbuild::error<T>(format_error(line, null(), null(), error, detail, null(), null()),
00080                        format_reason(line, null(), null(), error, detail, null(), null()))
00081     {
00082     }
00083 
00092     template<typename D>
00093     parse_error (size_t             line,
00094                  std::string const& group,
00095                  error_type         error,
00096                  D const&           detail):
00097       sbuild::error<T>(format_error(line, group, null(), error, detail, null(), null()),
00098                        format_reason(line, group, null(), error, detail, null(), null()))
00099     {
00100     }
00101 
00111     template<typename D>
00112     parse_error (size_t             line,
00113                  std::string const& group,
00114                  std::string const& key,
00115                  error_type         error,
00116                  D const&           detail):
00117       sbuild::error<T>(format_error(line, group, key, error, detail, null(), null()),
00118                        format_reason(line, group, key, error, detail, null(), null()))
00119     {
00120     }
00121 
00129     template<typename D>
00130     parse_error (std::string const& group,
00131                  error_type         error,
00132                  D const&           detail):
00133       sbuild::error<T>(format_error(group, null(), null(), error, detail, null(), null()),
00134                        format_reason(group, null(), null(), error, detail, null(), null()))
00135     {
00136     }
00137 
00146     template<typename D>
00147     parse_error (std::string const& group,
00148                  std::string const& key,
00149                  error_type         error,
00150                  D const&           detail):
00151       sbuild::error<T>(format_error(group, key, null(), error, detail, null(), null()),
00152                        format_reason(group, key, null(), error, detail, null(), null()))
00153     {
00154     }
00155 
00162     template<typename C>
00163     parse_error (C const&                  context,
00164                  std::runtime_error const& error):
00165       sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null(), null()),
00166                        sbuild::error<T>::format_reason(context, null(), null(), error, null(), null(), null()))
00167     {
00168     }
00169 
00176     parse_error (size_t                    line,
00177                  std::runtime_error const& error):
00178       sbuild::error<T>(sbuild::error<T>::format_error(line, null(), null(), error, null(), null(), null()),
00179                        sbuild::error<T>::format_reason(line, null(), null(), error, null(), null(), null()))
00180     {
00181     }
00182 
00190     parse_error (size_t                    line,
00191                  std::string const&        group,
00192                  std::runtime_error const& error):
00193       sbuild::error<T>(sbuild::error<T>::format_error(line, group, null(), error, null(), null(), null()),
00194                        sbuild::error<T>::format_reason(line, group, null(), error, null(), null(), null()))
00195     {
00196     }
00197 
00206     parse_error (size_t                    line,
00207                  std::string const&        group,
00208                  std::string const&        key,
00209                  std::runtime_error const& error):
00210       sbuild::error<T>(sbuild::error<T>::format_error(line, group, key, error, null(), null(), null()),
00211                        sbuild::error<T>::format_reason(line, group, key, error, null(), null(), null()))
00212     {
00213     }
00214 
00221     parse_error (std::string const&        group,
00222                  std::runtime_error const& error):
00223       sbuild::error<T>(sbuild::error<T>::format_error(group, null(), null(), error, null(), null(), null()),
00224                        sbuild::error<T>::format_reason(group, null(), null(), error, null(), null(), null()))
00225     {
00226     }
00227 
00235     parse_error (std::string const&        group,
00236                  std::string const&        key,
00237                  std::runtime_error const& error):
00238       sbuild::error<T>(sbuild::error<T>::format_error(group, key, null(), error, null(), null(), null()),
00239                        sbuild::error<T>::format_reason(group, key, null(), error, null(), null(), null()))
00240     {
00241     }
00242 
00243   };
00244 
00245 }
00246 
00247 #endif /* SBUILD_PARSE_ERROR_H */
00248 
00249 /*
00250  * Local Variables:
00251  * mode:C++
00252  * End:
00253  */