52 explicit MapFile(
const OptionMap & map ,
const std::string & yes = std::string() ) ;
62 explicit MapFile( std::istream & ,
bool utf8 =
false ) ;
68 static void check(
const G::Path & ,
bool utf8 =
false ) ;
73 void add(
const std::string & key ,
const std::string &
value ) ;
76 void writeItem( std::ostream & ,
const std::string & key ,
bool utf8 =
false )
const ;
79 static void writeItem( std::ostream & ,
const std::string & key ,
const std::string & value ,
bool utf8 =
false ) ;
83 bool allow_read_error =
false ,
bool allow_write_error =
false ,
bool utf8 =
false )
const ;
86 bool contains(
const std::string & key )
const ;
101 unsigned int numericValue(
const std::string & key ,
unsigned int default_ )
const ;
104 std::string
value(
const std::string & key ,
const std::string & default_ = std::string() )
const ;
107 std::string
value(
const std::string & key ,
const char * default_ )
const ;
110 bool booleanValue(
const std::string & key ,
bool default_ )
const ;
113 void remove(
const std::string & key ) ;
122 std::string
expand(
const std::string & value )
const ;
131 typedef std::list<std::string> List ;
132 void readFrom(
const G::Path & ,
bool ) ;
133 void readFrom( std::istream & ss ,
bool ) ;
134 static std::string quote(
const std::string & ) ;
135 List read(
const G::Path & ,
bool )
const ;
136 void commentOut( List & )
const ;
137 void replace( List & ,
bool )
const ;
138 bool expand_( std::string & )
const ;
139 std::string expandAll(
const std::string & )
const ;
140 static void backup(
const G::Path & ) ;
141 static void save(
const G::Path & , List & ,
bool ) ;
142 void log(
const std::string & ,
const std::string & )
const ;
143 static void log(
bool ,
const std::string & ,
const std::string & ) ;
144 static std::string fromUtf(
const std::string & value ,
bool utf8 ) ;
145 static std::string toUtf(
const std::string & value ,
bool utf8 ) ;
146 std::string mandatoryValue(
const std::string & )
const ;
void editInto(const G::Path &path, bool make_backup=true, bool allow_read_error=false, bool allow_write_error=false, bool utf8=false) const
Edits an existing file so that its contents reflect this map.
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.
A map-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. Throws if it does not exist.
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.
void writeItem(std::ostream &, const std::string &key, bool utf8=false) const
Writes a single item from this map to the stream.
G::Path expandedPathValue(const std::string &key) const
Returns a mandatory path value from the map with expand(). Throws if it does not exist.
A class for reading and editing key=value files, supporting the 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.
std::map< std::string, std::string > StringMap
A std::map of std::strings.
A Path object represents a file system path.
static void check(const G::Path &, bool utf8=false)
Throws if the file is invalid.
void log() const
Logs the contents.