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 <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
00219
00220
00221
00222
00223
00224