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 : /* BaseError should generally not be caught, as it has Interrupted as
23 : a subclass. Catch Error instead. */
24 : class BaseError : public std::exception
25 0 : {
26 : protected:
27 : string err;
28 : public:
29 : BaseError(const format & f);
30 273 : ~BaseError() throw () { };
31 2 : const char * what() const throw () { return err.c_str(); }
32 66 : const string & msg() const throw () { return err; }
33 : BaseError & addPrefix(const format & f);
34 : };
35 :
36 : #define MakeError(newClass, superClass) \
37 : class newClass : public superClass \
38 : { \
39 : public: \
40 : newClass(const format & f) : superClass(f) { }; \
41 : };
42 :
43 546 : MakeError(Error, BaseError)
44 :
45 : class SysError : public Error
46 0 : {
47 : public:
48 : int errNo;
49 : SysError(const format & f);
50 : };
51 :
52 :
53 : typedef list<string> Strings;
54 : typedef set<string> StringSet;
55 :
56 :
57 : /* Paths are just strings. */
58 : typedef string Path;
59 : typedef list<Path> Paths;
60 : typedef set<Path> PathSet;
61 :
62 :
63 : typedef enum {
64 : lvlError,
65 : lvlInfo,
66 : lvlTalkative,
67 : lvlChatty,
68 : lvlDebug,
69 : lvlVomit
70 : } Verbosity;
71 :
72 :
73 : }
74 :
75 :
76 : #endif /* !__TYPES_H */
|