48 G_EXCEPTION( ReadError ,
"cannot open map file" ) ;
49 G_EXCEPTION( WriteError ,
"cannot write map file" ) ;
50 G_EXCEPTION( Missing ,
"cannot find map file item" ) ;
58 explicit MapFile(
const OptionMap & map ,
const std::string & yes = std::string() ) ;
73 explicit MapFile( std::istream & ) ;
84 void add(
const std::string & key ,
const std::string &
value ) ;
87 void writeItem( std::ostream & ,
const std::string & key )
const ;
90 static void writeItem( std::ostream & ,
const std::string & key ,
const std::string & value ) ;
94 bool allow_read_error ,
bool allow_write_error )
const ;
98 bool contains(
const std::string & key )
const ;
108 unsigned int numericValue(
const std::string & key ,
unsigned int default_ )
const ;
111 std::string
value(
const std::string & key ,
const std::string & default_ = std::string() )
const ;
115 std::string
value(
const std::string & key ,
const char * default_ )
const ;
118 bool booleanValue(
const std::string & key ,
bool default_ )
const ;
123 void remove(
const std::string & key ) ;
132 std::string
expand(
const std::string & value )
const ;
148 typedef std::list<std::string> List ;
149 void readFrom(
const G::Path & ) ;
150 void readFrom( std::istream & ss ) ;
151 static std::string quote(
const std::string & ) ;
152 List read(
const G::Path & ,
bool )
const ;
153 void commentOut( List & )
const ;
154 void replace( List & )
const ;
155 bool expand_( std::string & )
const ;
156 std::string expandAll(
const std::string & )
const ;
157 static void backup(
const G::Path & ) ;
158 static void save(
const G::Path & , List & ,
bool ) ;
159 void log(
const std::string & ,
const std::string & )
const ;
160 static void log(
bool ,
const std::string & ,
const std::string & ) ;
161 std::string mandatoryValue(
const std::string & )
const ;
162 bool ignore(
const std::string & )
const ;
std::string value(const std::string &key, const std::string &default_=std::string()) const
Returns a string value from the map.
const G::StringArray & keys() const
Returns a reference to the ordered list of keys.
std::vector< std::string > StringArray
A std::vector of std::strings.
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.
static void check(const G::Path &)
Throws if the file is invalid.
A multimap-like container for command-line options and their values.
G::Path pathValue(const std::string &key) const
Returns a mandatory path value from the map.
bool contains(const std::string &key) const
Returns true if the map contains the given key.
const G::StringMap & map() const
Returns a reference to the internal map.
G::Path expandedPathValue(const std::string &key) const
Returns a mandatory path value from the map with expand().
A class for reading and editing key=value files, supporting comments, creation of backup files...
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)
Adds or updates a single item in the map.
std::string expand(const std::string &value) const
Does one-pass variable substitution for the given string.
MapFile()
Constructor for an empty map.
bool booleanValue(const std::string &key, bool default_) const
Returns a boolean value from the map.
void writeItem(std::ostream &, const std::string &key) const
Writes a single item from this map to the stream.
std::map< std::string, std::string > StringMap
A std::map of std::strings.
A Path object represents a file system path.
void log() const
Logs the contents.