#pragma once #include "config.h" #include #include #include #include /* Before 4.7, gcc's std::exception uses empty throw() specifiers for * its (virtual) destructor and what() in c++11 mode, in violation of spec */ #ifdef __GNUC__ #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) #define EXCEPTION_NEEDS_THROW_SPEC #endif #endif 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; struct FormatOrString { string s; FormatOrString(const string & s) : s(s) { }; FormatOrString(const format & f) : s(f.str()) { }; FormatOrString(const char * s) : s(s) { }; }; /* BaseError should generally not be caught, as it has Interrupted as a subclass. Catch Error instead. */ class BaseError : public std::exception { protected: string prefix_; // used for location traces etc. string err; public: unsigned int status; // exit status BaseError(const FormatOrString & fs, unsigned int status = 1); #ifdef EXCEPTION_NEEDS_THROW_SPEC ~BaseError() throw () { }; const char * what() const throw () { return err.c_str(); } #else const char * what() const noexcept { return err.c_str(); } #endif const string & msg() const { return err; } const string & prefix() const { return prefix_; } BaseError & addPrefix(const FormatOrString & fs); }; #define MakeError(newClass, superClass) \ class newClass : public superClass \ { \ public: \ newClass(const FormatOrString & fs, unsigned int status = 1) : superClass(fs, status) { }; \ }; MakeError(Error, BaseError) class SysError : public Error { public: int errNo; SysError(const FormatOrString & fs); }; typedef list Strings; typedef set StringSet; /* Paths are just strings. */ typedef string Path; typedef list Paths; typedef set PathSet; typedef enum { lvlError = 0, lvlInfo, lvlTalkative, lvlChatty, lvlDebug, lvlVomit } Verbosity; } ft'>AgeCommit message (Expand)Author 2016-07-18Thank Thomas.Ricardo Wurmus 2015-11-23Thank Jan.Ludovic Courtès 2015-11-17Thank Chris.Ludovic Courtès 2015-10-09Thank Chris.Ludovic Courtès 2015-09-20Thank Petter.Ludovic Courtès 2015-08-27Thank Eric Hanchrow.Ludovic Courtès 2015-07-23Thank Anders.Ludovic Courtès 2015-07-22Thank Malcolm.Ludovic Courtès 2015-07-22Thank Dave.Ludovic Courtès 2015-07-04Clean up 'THANKS' and 'AUTHORS'....* THANKS: Add Konrad Hinsen, Cyprien Nicolas, Yakkala Yagnesh Raghava and Alexander Shendi. Remove Federico Beffa, Marek Benc, John Darrington, rekado, Cyrill Schenkel and Andy Wingo because they are placed in AUTHORS. Move Amirouche Boubekki and Alex Kost to ... * AUTHORS: ... here. Add Arne Babenhauserheide, Ian Denhardt, Kevin Lemonnier, Mathieu Lirzin, Pierre-Antoine Rault and Ben Woodcroft. Fix some names and emails. Alex Kost 2015-06-07Thank Thomas.Ludovic Courtès 2015-05-01Thank Joshua.Ludovic Courtès 2015-04-14Thank Pjotr.Ludovic Courtès 2015-02-24Thank Daniel.Ludovic Courtès 2015-02-07Thank Andrei.Ludovic Courtès 2015-01-28Thank Amirouche.Ludovic Courtès 2014-12-09Thank rekado.Ludovic Courtès