diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-09-04T21·06+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-09-04T21·06+0000 |
commit | 75068e7d753cf6cbe45a4bf294000dca9bd41d8b (patch) | |
tree | c6274cc10caab08349b5585206034f41ca4a575f /src/libutil/types.hh | |
parent | aab88127321344d5818d823bff515d127108d058 (diff) |
* Use a proper namespace.
* Optimise header file usage a bit. * Compile the parser as C++.
Diffstat (limited to 'src/libutil/types.hh')
-rw-r--r-- | src/libutil/types.hh | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/libutil/types.hh b/src/libutil/types.hh new file mode 100644 index 000000000000..1de378961e46 --- /dev/null +++ b/src/libutil/types.hh @@ -0,0 +1,73 @@ +#ifndef __TYPES_H +#define __TYPES_H + +#include <string> +#include <list> +#include <set> + +#include <boost/format.hpp> + + +namespace nix { + + +/* Inherit some names from other namespaces for convenience. */ +using std::string; +using std::list; +using std::set; +using std::vector; +using boost::format; + + +class Error : public std::exception +{ +protected: + string err; +public: + Error(const format & f); + ~Error() throw () { }; + const char * what() const throw () { return err.c_str(); } + const string & msg() const throw () { return err; } + Error & addPrefix(const format & f); +}; + +class SysError : public Error +{ +public: + SysError(const format & f); +}; + +#define MakeError(newClass, superClass) \ + class newClass : public superClass \ + { \ + public: \ + newClass(const format & f) : superClass(f) { }; \ + }; + +MakeError(UsageError, Error) + + +typedef list<string> Strings; +typedef set<string> StringSet; + + +/* Paths are just strings. */ +typedef string Path; +typedef list<Path> Paths; +typedef set<Path> PathSet; + + +typedef enum { + lvlError, + lvlInfo, + lvlTalkative, + lvlChatty, + lvlDebug, + lvlVomit +} Verbosity; + + +} + + +#endif /* !__TYPES_H */ |