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 <sbuild/sbuild-error.h>
00024 
00025 #include <map>
00026 #include <string>
00027 
00028 namespace sbuild
00029 {
00030 
00034   class parse_error : public runtime_error
00035   {
00036   public:
00037     enum type
00038       {
00039         NONE,            
00040         BAD_FILE,        
00041         BAD_VALUE,       
00042         INVALID_LINE,    
00043         NO_GROUP,        
00044         INVALID_GROUP,   
00045         DUPLICATE_GROUP, 
00046         NO_KEY,          
00047         DUPLICATE_KEY,   
00048         MISSING_KEY,     
00049         DISALLOWED_KEY   
00050       };
00051 
00058     parse_error (type               error,
00059                  std::string const& detail);
00060 
00068     parse_error (size_t             line,
00069                  type               error,
00070                  std::string const& detail);
00071 
00080     parse_error (size_t             line,
00081                  std::string const& group,
00082                  type               error,
00083                  std::string const& detail);
00084 
00094     parse_error (size_t             line,
00095                  std::string const& group,
00096                  std::string const& key,
00097                  type               error,
00098                  std::string const& detail);
00099 
00107     parse_error (std::string const& group,
00108                  type               error,
00109                  std::string const& detail);
00110 
00119     parse_error (std::string const& group,
00120                  std::string const& key,
00121                  type               error,
00122                  std::string const& detail);
00123 
00124   private:
00126     static std::map<type,const char *> error_strings;
00127 
00134     static const char *
00135     get_error (type error);
00136 
00143     static std::string
00144     format_error (type               error,
00145                   std::string const& detail);
00146 
00154     static std::string
00155     format_error (size_t             line,
00156                   type               error,
00157                   std::string const& detail);
00158 
00167     static std::string
00168     format_error (size_t             line,
00169                   std::string const& group,
00170                   type               error,
00171                   std::string const& detail);
00172 
00182     static std::string
00183     format_error (size_t             line,
00184                   std::string const& group,
00185                   std::string const& key,
00186                   type               error,
00187                   std::string const& detail);
00188 
00196     static std::string
00197     format_error (std::string const& group,
00198                   type               error,
00199                   std::string const& detail);
00200 
00209     static std::string
00210     format_error (std::string const& group,
00211                   std::string const& key,
00212                   type               error,
00213                   std::string const& detail);
00214   };
00215 
00216 }
00217 
00218 #endif /* SBUILD_PARSE_ERROR_H */
00219 
00220 /*
00221  * Local Variables:
00222  * mode:C++
00223  * End:
00224  */

Generated on Mon Jun 26 12:50:25 2006 for schroot by  doxygen 1.4.7