sbuild-parse-error.h

Go to the documentation of this file.
00001 /* Copyright © 2005-2006  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 2 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, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00016  * MA  02111-1307  USA
00017  *
00018  *********************************************************************/
00019 
00020 #ifndef SBUILD_PARSE_ERROR_H
00021 #define SBUILD_PARSE_ERROR_H
00022 
00023 #include <map>
00024 #include <string>
00025 
00026 #include <boost/format.hpp>
00027 
00028 #include "sbuild-error.h"
00029 #include "sbuild-log.h"
00030 
00031 namespace sbuild
00032 {
00033 
00037   class parse_error : public runtime_error
00038   {
00039   public:
00040     enum type
00041       {
00042         NONE,            
00043         BAD_FILE,        
00044         BAD_VALUE,       
00045         INVALID_LINE,    
00046         NO_GROUP,        
00047         INVALID_GROUP,   
00048         DUPLICATE_GROUP, 
00049         NO_KEY,          
00050         DUPLICATE_KEY,   
00051         MISSING_KEY,     
00052         DISALLOWED_KEY   
00053       };
00054 
00061     parse_error (type               error,
00062                  std::string const& detail);
00063 
00071     parse_error (size_t             line,
00072                  type               error,
00073                  std::string const& detail);
00074 
00083     parse_error (size_t             line,
00084                  std::string const& group,
00085                  type               error,
00086                  std::string const& detail);
00087 
00097     parse_error (size_t             line,
00098                  std::string const& group,
00099                  std::string const& key,
00100                  type               error,
00101                  std::string const& detail);
00102 
00110     parse_error (std::string const& group,
00111                  type               error,
00112                  std::string const& detail);
00113 
00122     parse_error (std::string const& group,
00123                  std::string const& key,
00124                  type               error,
00125                  std::string const& detail);
00126 
00127   private:
00129     static std::map<type,const char *> error_strings;
00130 
00137     static const char *
00138     get_error (type error);
00139 
00146     static std::string
00147     format_error (type               error,
00148                   std::string const& detail);
00149 
00157     static std::string
00158     format_error (size_t             line,
00159                   type               error,
00160                   std::string const& detail);
00161 
00170     static std::string
00171     format_error (size_t             line,
00172                   std::string const& group,
00173                   type               error,
00174                   std::string const& detail);
00175 
00185     static std::string
00186     format_error (size_t             line,
00187                   std::string const& group,
00188                   std::string const& key,
00189                   type               error,
00190                   std::string const& detail);
00191 
00199     static std::string
00200     format_error (std::string const& group,
00201                   type               error,
00202                   std::string const& detail);
00203 
00212     static std::string
00213     format_error (std::string const& group,
00214                   std::string const& key,
00215                   type               error,
00216                   std::string const& detail);
00217   };
00218 
00219 }
00220 
00221 #endif /* SBUILD_PARSE_ERROR_H */
00222 
00223 /*
00224  * Local Variables:
00225  * mode:C++
00226  * End:
00227  */

Generated on Sat Jun 17 14:41:22 2006 for schroot by  doxygen 1.4.6