aboutsummaryrefslogtreecommitdiff
#pragma once

#include "config.h"

#include <string>
#include <list>
#include <set>

#include <boost/format.hpp>

/* 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<string> Strings;
typedef set<string> StringSet;


/* Paths are just strings. */
typedef string Path;
typedef list<Path> Paths;
typedef set<Path> PathSet;


typedef enum {
    lvlError = 0,
    lvlInfo,
    lvlTalkative,
    lvlChatty,
    lvlDebug,
    lvlVomit
} Verbosity;


}
uix/commit/configure.ac?id=dde49cfe5312b95f44060155256036532f3cb22a'>build: Fine-tune the forbidden M4 patterns....Ludovic Courtès 2018-10-12build: Remove obsolete reference to 'GUIX_ASSERT_LIBGCRYPT_USABLE'....Ludovic Courtès 2018-09-04Switch to Guile-Gcrypt....Ludovic Courtès 2018-06-18build: Remove checks for 'nix-instantiate'....Ludovic Courtès 2018-06-14build: Require Guile-SQLite3....Ludovic Courtès 2018-06-01build: Check for Guile-SQLite3....Ludovic Courtès 2018-04-19gnu: doc: Allow documentation to be translated....Julien Lepiller 2018-02-26build: Require Guile >= 2.0.13....Ludovic Courtès 2018-02-07etc: Add SELinux policy for the daemon....Ricardo Wurmus 2018-01-23build: Expand ‘scripts/guix’ at Make time....Mathieu Lirzin 2018-01-16etc: Add completions for fish....ng0 2018-01-06build: Detect broken 'equal?' in Guile 2.2.1....Ludovic Courtès 2017-10-09build: Update automake version requirement to 1.14....Eric Bavier 2017-09-05build: Negate ‘--disable-daemon’ help string....Tobias Geerinckx-Rice 2017-08-02build: Make Guile-Git a hard requirement....Ludovic Courtès 2017-06-30build: Remove check for broken (srfi srfi-37)....Ludovic Courtès 2017-06-09guix: git: Add new module....Mathieu Othacehe 2017-05-05Revert "guix: git: Add new module."...Leo Famulari 2017-05-05guix: git: Add new module....Mathieu Othacehe 2017-05-04build: Use Gnulib's 'git-version-gen'....Ludovic Courtès 2017-03-20build: Install .go files to $libdir/guile/X.Y....Ludovic Courtès 2017-03-18build: Require Guile >= 2.0.9....Ludovic Courtès 2017-03-15build: Prefer Guile 2.2 over 2.0....Ludovic Courtès 2017-03-12build: GnuTLS is now a hard dependency....Ludovic Courtès 2017-02-07build: Warn about lack of substitutes for non-standard stores....Ludovic Courtès 2017-01-13etc: Support indentation of whole files....Ludovic Courtès 2017-01-12etc: Add 'indent-package.el' script....Ludovic Courtès 2016-12-31Add (guix ssh) module....Ludovic Courtès 2016-12-29Remove Emacs interface....Alex Kost 2016-12-20build: Bump version number....Ricardo Wurmus 2016-10-25build: 'guilemoduledir' honors $GUILE_EFFECTIVE_VERSION....Ludovic Courtès 2016-09-20build: Allow builds with Guile 2.2....Ludovic Courtès 2016-09-07Add Zsh completion file....Eric Le Bihan 2016-07-29Merge branch 'master' into core-updatesMark H Weaver 2016-07-29build: Bump version number....Ludovic Courtès 2016-07-20Merge branch 'master' into core-updatesLudovic Courtès 2016-07-19Add (guix zlib)....Ludovic Courtès 2016-06-23build: Remove unneeded conditionals for (guix build syscalls)....Manolis Ragkousis