1 | /* Copyright © 2005-2008 Roger Leigh <rleigh@debian.org> |
---|
2 | * |
---|
3 | * schroot is free software: you can redistribute it and/or modify it |
---|
4 | * under the terms of the GNU General Public License as published by |
---|
5 | * the Free Software Foundation, either version 3 of the License, or |
---|
6 | * (at your option) any later version. |
---|
7 | * |
---|
8 | * schroot is distributed in the hope that it will be useful, but |
---|
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | * General Public License for more details. |
---|
12 | * |
---|
13 | * You should have received a copy of the GNU General Public License |
---|
14 | * along with this program. If not, see |
---|
15 | * <http://www.gnu.org/licenses/>. |
---|
16 | * |
---|
17 | *********************************************************************/ |
---|
18 | |
---|
19 | #ifndef SBUILD_KEYFILE_BASE_H |
---|
20 | #define SBUILD_KEYFILE_BASE_H |
---|
21 | |
---|
22 | #include <sbuild/sbuild-i18n.h> |
---|
23 | #include <sbuild/sbuild-log.h> |
---|
24 | #include <sbuild/sbuild-parse-error.h> |
---|
25 | #include <sbuild/sbuild-parse-value.h> |
---|
26 | #include <sbuild/sbuild-types.h> |
---|
27 | #include <sbuild/sbuild-tr1types.h> |
---|
28 | #include <sbuild/sbuild-util.h> |
---|
29 | |
---|
30 | #include <cassert> |
---|
31 | #include <map> |
---|
32 | #include <string> |
---|
33 | #include <sstream> |
---|
34 | |
---|
35 | #include <boost/format.hpp> |
---|
36 | |
---|
37 | namespace sbuild |
---|
38 | { |
---|
39 | |
---|
40 | /** |
---|
41 | * Base class for key-value configuration file formats. |
---|
42 | */ |
---|
43 | class keyfile_base |
---|
44 | { |
---|
45 | public: |
---|
46 | /// Configuration parameter priority. |
---|
47 | enum priority |
---|
48 | { |
---|
49 | PRIORITY_OPTIONAL, ///< The parameter is optional. |
---|
50 | PRIORITY_REQUIRED, ///< The parameter is required. |
---|
51 | PRIORITY_DISALLOWED, ///< The parameter is not allowed in this context. |
---|
52 | PRIORITY_DEPRECATED, ///< The parameter is deprecated, but functional. |
---|
53 | PRIORITY_OBSOLETE ///< The parameter is obsolete, and not functional. |
---|
54 | }; |
---|
55 | |
---|
56 | /// Error codes. |
---|
57 | enum error_code |
---|
58 | { |
---|
59 | BAD_FILE, ///< The file to parse couldn't be opened. |
---|
60 | DEPRECATED_KEY, ///< The key is deprecated. |
---|
61 | DEPRECATED_KEY_NL, ///< The key is deprecated (no line specified). |
---|
62 | DISALLOWED_KEY, ///< The key is not allowed. |
---|
63 | DISALLOWED_KEY_NL, ///< The key is not allowed (no line specified). |
---|
64 | DUPLICATE_GROUP, ///< The group is a duplicate. |
---|
65 | DUPLICATE_KEY, ///< The key is a duplicate. |
---|
66 | INVALID_GROUP, ///< The group is invalid. |
---|
67 | INVALID_LINE, ///< The line is invalid. |
---|
68 | MISSING_KEY, ///< The key is missing. |
---|
69 | MISSING_KEY_NL, ///< The key is missing (no line specified). |
---|
70 | NO_GROUP, ///< No group was specified. |
---|
71 | NO_KEY, ///< No key was specified. |
---|
72 | OBSOLETE_KEY, ///< The key is obsolete. |
---|
73 | OBSOLETE_KEY_NL, ///< The key is obsolete (no line specified). |
---|
74 | PASSTHROUGH_G, ///< Pass through exception with group. |
---|
75 | PASSTHROUGH_GK, ///< Pass through exception with group and key. |
---|
76 | PASSTHROUGH_LG, ///< Pass through exception with line and group. |
---|
77 | PASSTHROUGH_LGK, ///< Pass through exception with line, group and key. |
---|
78 | UNKNOWN_KEY ///< The key is unknown. |
---|
79 | }; |
---|
80 | |
---|
81 | /// Exception type. |
---|
82 | typedef parse_error<error_code> error; |
---|
83 | |
---|
84 | /// The constructor. |
---|
85 | keyfile_base (); |
---|
86 | |
---|
87 | /// The destructor. |
---|
88 | virtual ~keyfile_base (); |
---|
89 | |
---|
90 | }; |
---|
91 | |
---|
92 | } |
---|
93 | |
---|
94 | #endif /* SBUILD_KEYFILE_BASE_H */ |
---|
95 | |
---|
96 | /* |
---|
97 | * Local Variables: |
---|
98 | * mode:C++ |
---|
99 | * End: |
---|
100 | */ |
---|