2006-09-05 00:06:23 +03:00
|
|
|
#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;
|
|
|
|
|
|
|
|
|
2007-08-12 03:29:28 +03:00
|
|
|
/* BaseError should generally not be caught, as it has Interrupted as
|
|
|
|
a subclass. Catch Error instead. */
|
|
|
|
class BaseError : public std::exception
|
2006-09-05 00:06:23 +03:00
|
|
|
{
|
|
|
|
protected:
|
2009-06-30 16:28:29 +03:00
|
|
|
string prefix_; // used for location traces etc.
|
2006-09-05 00:06:23 +03:00
|
|
|
string err;
|
|
|
|
public:
|
2007-08-12 03:29:28 +03:00
|
|
|
BaseError(const format & f);
|
|
|
|
~BaseError() throw () { };
|
2006-09-05 00:06:23 +03:00
|
|
|
const char * what() const throw () { return err.c_str(); }
|
|
|
|
const string & msg() const throw () { return err; }
|
2009-06-30 16:28:29 +03:00
|
|
|
const string & prefix() const throw () { return prefix_; }
|
2007-08-12 03:29:28 +03:00
|
|
|
BaseError & addPrefix(const format & f);
|
2006-09-05 00:06:23 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MakeError(newClass, superClass) \
|
|
|
|
class newClass : public superClass \
|
|
|
|
{ \
|
|
|
|
public: \
|
|
|
|
newClass(const format & f) : superClass(f) { }; \
|
|
|
|
};
|
|
|
|
|
2007-08-12 03:29:28 +03:00
|
|
|
MakeError(Error, BaseError)
|
|
|
|
|
|
|
|
class SysError : public Error
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int errNo;
|
|
|
|
SysError(const format & f);
|
|
|
|
};
|
|
|
|
|
2006-09-05 00:06:23 +03:00
|
|
|
|
|
|
|
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 */
|