aboutsummaryrefslogtreecommitdiff
path: root/nix/libutil/types.hh
blob: 4b5ce9a78c489fb367eac85f521c2a6960d286f7 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once

#include "config.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;


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);
    ~BaseError() throw () { };
    const char * what() const throw () { return err.c_str(); }
    const string & msg() const throw () { return err; }
    const string & prefix() const throw () { 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;


}
x-boot: Don't ignore flags when mounting root file system....Guillaume Le Vaillant 2019-11-18linux-boot: Don't ignore options when mounting root file system....Guillaume Le Vaillant 2019-11-18linux-boot: Fix indentation....Maxim Cournoyer 2019-09-25linux-boot: Fix typo....Maxim Cournoyer 2019-08-16linux-modules: Add 'load-linux-modules-from-directory'....Ludovic Courtès 2019-06-03linux-boot: Fix e2fsck warning....Danny Milosavljevic 2019-03-24system: Initialize console keyboard layout in the initrd....Ludovic Courtès 2018-05-28file-systems: Remove 'title' field and add <file-system-label>....Ludovic Courtès 2018-02-06gnu: build: linux-boot: Remove bind-mount export....Christopher Baines 2018-02-01linux-boot: Add find-long-options....Danny Milosavljevic 2018-01-19gnu: Consistently Write ‘file system(s)’....Tobias Geerinckx-Rice 2018-01-08linux-boot: Add #:on-error for initrd error handling....Ludovic Courtès 2017-12-16linux-boot: Add make-static-device-nodes....Danny Milosavljevic 2017-12-02linux-boot: Remove unneeded import....Ludovic Courtès 2017-11-29linux-boot: Ensure /etc exists on the root file system....Ludovic Courtès 2017-11-08build: Use overlayfs instead of unionfs....Hartmut Goebel 2017-10-11file-systems: 'mount-file-system' now takes a <file-system> object....Ludovic Courtès 2017-04-11build: Fix compilation warnings....Mathieu Othacehe