00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
00222
00223
00224
00225
00226
00227