79 explicit MapFile(
const G::Path & ,
const std::string & kind = std::string() ) ;
85 explicit MapFile( std::istream & ) ;
91 static void check(
const G::Path & ,
const std::string & kind = std::string() ) ;
96 void add(
const std::string & key ,
const std::string &
value ,
bool clear =
false ) ;
101 void writeItem( std::ostream & ,
const std::string & key )
const ;
104 static void writeItem( std::ostream & ,
const std::string & key ,
const std::string &
value ) ;
108 bool allow_read_error ,
bool allow_write_error )
const ;
112 bool contains(
const std::string & key )
const ;
122 unsigned int numericValue(
const std::string & key ,
unsigned int default_ )
const ;
125 std::string
value(
const std::string & key ,
const std::string & default_ = std::string() )
const ;
129 std::string
value(
const std::string & key ,
const char * default_ )
const ;
132 bool booleanValue(
const std::string & key ,
bool default_ )
const ;
137 void remove(
const std::string & key ) ;
143 void log(
const std::string & prefix = std::string() )
const ;
146 std::string
expand(
const std::string &
value )
const ;
162 using List = std::list<std::string> ;
163 void readFrom(
const G::Path & ,
const std::string & ) ;
164 void readFrom( std::istream & ss ) ;
165 static std::string quote(
const std::string & ) ;
166 List read(
const G::Path & ,
const std::string & ,
bool )
const ;
167 void commentOut( List & )
const ;
168 void replace( List & )
const ;
169 bool expand_( std::string & )
const ;
170 std::string expandAll(
const std::string & )
const ;
171 static void backup(
const G::Path & ) ;
172 static void save(
const G::Path & , List & ,
bool ) ;
173 std::string mandatoryValue(
const std::string & )
const ;
174 bool ignore(
const std::string & )
const ;
175 static std::string ekind(
const std::string & ) ;
176 static std::string epath(
const G::Path & ) ;
177 static Error readError(
const G::Path & ,
const std::string & ) ;
178 static Error writeError(
const G::Path & ,
const std::string & = std::string() ) ;
179 static Error missingValueError(
const G::Path & ,
const std::string & ,
const std::string & ) ;
A general-purpose exception class derived from std::exception and containing an error message.
Exception(const char *what)
Constructor.
A class for reading, writing and editing key=value files, supporting variable expansion of percent-ke...
static void check(const G::Path &, const std::string &kind=std::string())
Throws if the file is invalid.
std::string expand(const std::string &value) const
Does one-pass variable substitution for the given string.
void editInto(const G::Path &path, bool make_backup, bool allow_read_error, bool allow_write_error) const
Edits an existing file so that its contents reflect this map.
bool booleanValue(const std::string &key, bool default_) const
Returns a boolean value from the map.
unsigned int numericValue(const std::string &key, unsigned int default_) const
Returns a numeric value from the map.
void add(const std::string &key, const std::string &value, bool clear=false)
Adds or updates a single item in the map.
const G::StringMap & map() const
Returns a reference to the internal map.
void remove(const std::string &key)
Removes a value (if it exists).
G::Path pathValue(const std::string &key) const
Returns a mandatory path value from the map.
MapFile()
Constructor for an empty map.
bool contains(const std::string &key) const
Returns true if the map contains the given key.
G::Path expandedPathValue(const std::string &key) const
Returns a mandatory path value from the map with expand().
const G::StringArray & keys() const
Returns a reference to the internal ordered list of keys.
void log(const std::string &prefix=std::string()) const
Logs the contents.
void writeItem(std::ostream &, const std::string &key) const
Writes a single item from this map to the stream.
std::string value(const std::string &key, const std::string &default_=std::string()) const
Returns a string value from the map.
A multimap-like container for command-line options and their values.
A Path object represents a file system path.
std::vector< std::string > StringArray
A std::vector of std::strings.
std::map< std::string, std::string > StringMap
A std::map of std::strings.
Exception class for G::MapFile.