mirror of
https://github.com/NixOS/nix
synced 2025-06-26 15:51:15 +02:00
* Use a proper namespace.
* Optimise header file usage a bit. * Compile the parser as C++.
This commit is contained in:
parent
aab8812732
commit
75068e7d75
61 changed files with 650 additions and 268 deletions
73
src/libutil/types.hh
Normal file
73
src/libutil/types.hh
Normal file
|
@ -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 */
|
Loading…
Add table
Add a link
Reference in a new issue