1 : #ifndef __TYPES_H
2 : #define __TYPES_H
3 :
4 : #include <string>
5 : #include <list>
6 : #include <set>
7 :
8 : #include <boost/format.hpp>
9 :
10 :
11 : namespace nix {
12 :
13 :
14 : /* Inherit some names from other namespaces for convenience. */
15 : using std::string;
16 : using std::list;
17 : using std::set;
18 : using std::vector;
19 : using boost::format;
20 :
21 :
22 : class Error : public std::exception
23 : {
24 : protected:
25 : string err;
26 : public:
27 : Error(const format & f);
28 242 : ~Error() throw () { };
29 4 : const char * what() const throw () { return err.c_str(); }
30 104 : const string & msg() const throw () { return err; }
31 : Error & addPrefix(const format & f);
32 : };
33 :
34 : class SysError : public Error
35 : {
36 : public:
37 : SysError(const format & f);
38 : };
39 :
40 : #define MakeError(newClass, superClass) \
41 : class newClass : public superClass \
42 : { \
43 : public: \
44 : newClass(const format & f) : superClass(f) { }; \
45 : };
46 :
47 4 : MakeError(UsageError, Error)
48 :
49 :
50 : typedef list<string> Strings;
51 : typedef set<string> StringSet;
52 :
53 :
54 : /* Paths are just strings. */
55 : typedef string Path;
56 : typedef list<Path> Paths;
57 : typedef set<Path> PathSet;
58 :
59 :
60 : typedef enum {
61 : lvlError,
62 : lvlInfo,
63 : lvlTalkative,
64 : lvlChatty,
65 : lvlDebug,
66 : lvlVomit
67 : } Verbosity;
68 :
69 :
70 : }
71 :
72 :
73 : #endif /* !__TYPES_H */
|