Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
basic-setup.hpp
Go to the documentation of this file.
1/*
2 BASIC-SETUP.hpp - elementary self-configuration of the application
3
4 Copyright (C)
5 2011, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
44#ifndef COMMON_BASIC_SETUP_H
45#define COMMON_BASIC_SETUP_H
46
47#include "lib/error.hpp"
48#include "lib/symbol.hpp"
49#include "lib/nocopy.hpp"
50#include "lib/util.hpp"
51
52#include <boost/program_options.hpp>
53#include <string>
54
55
57#define LUMIERA_LOCATION_OF_BOOTSTRAP_INI "$ORIGIN/setup.ini"
58
59
60
61namespace lumiera {
62
63 using std::string;
64
65 namespace opt = boost::program_options;
66
67
90 {
91 opt::options_description syntax;
92 opt::variables_map settings;
93
94 public:
95 BasicSetup (string bootstrapIni);
96
97 string
99 {
100 return get (key).as<string>();
101 }
102
103 opt::variable_value const&
104 get (lib::Literal key) const
105 {
106 string keyID (key);
107 __ensure_hasKey(keyID);
108 return settings[keyID];
109 }
110
111
112 private:
113 void
114 __ensure_hasKey (string const& key) const
115 {
116 if (!util::contains (settings, key))
117 throw error::Logic ("Key \""+key+"\" not found in setup.ini");
118 }
119 };
120
121
122} // namespace lumiera
123#endif
Inline string literal.
Definition symbol.hpp:78
Represents the elementary self-configuration of a running Lumiera application instance.
opt::variable_value const & get(lib::Literal key) const
string operator[](lib::Literal key) const
void __ensure_hasKey(string const &key) const
opt::options_description syntax
opt::variables_map settings
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
Lumiera error handling (C++ interface).
LumieraError< LERR_(LOGIC)> Logic
Definition error.hpp:207
Lumiera public interface.
Definition advice.hpp:102
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
Definition util.hpp:230
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...