91 if (!config.
open(file))
118 if (!
getBool(
"saveconf",
true))
129 if (!config.
open(file))
169 for (ConfigFile::DomainList::const_iterator d = domains.begin(); d != domains.end(); ++d) {
174 if (domainPath.
empty())
178 return (*d)->getName();
204 if (!
_config->hasDomain(target))
207 for (
uint32 i = 0; i < 65536; i++) {
210 if (!
_config->hasDomain(targetNumbered))
211 return targetNumbered;
218 if (target.
empty()) {
238 return _config->getDomain(gameID) != 0;
393 if (current == value)
407 setKey(key, value, update);
441 setKey(realm, key, value);
481 throw Exception(
"No such default config key \"%s\"", key.
c_str());
526 return domain && domain->
hasKey(key);
530 return domain && domain->
getKey(key, value);
537 domain->
setKey(key, value);
This class allows reading/writing INI style config files.
void setDefaults()
Overwrite the current config with the defaults.
bool hasKey(const UString &key) const
void setString(const UString &key, const UString &value, bool update=false)
A class holding an UTF-8 string.
Temporary game settings/properties.
The global config manager.
ScopedPtr< ConfigDomain > _domainDefaultGame
Game defaults domain.
UString composeString(T value)
Convert any POD integer, float/double or bool type into a string.
void setString(const UString &key, const UString &value)
UString createGame(const UString &path, UString target="")
Create the game domain with this path and target.
A simple streaming file reading class.
bool load()
Load from the default config file.
bool fileExists() const
Does the config file exist?
bool setGame(const UString &gameID="")
Set the game domain to gameID.
int getDefaultInt(const UString &key) const
void clear()
Clear everything except the command line options.
bool getKey(const UString &key, UString &value) const
UString getDefaultKey(const UString &key) const
double getDefaultDouble(const UString &key) const
ScopedPtr< ConfigDomain > _domainDefaultApp
Application defaults domain.
The global config manager, storing all config keys.
Utility templates and functions for working with strings and streams.
void setConfigFile(const UString &file="")
Set the config file to use.
void setBool(const UString &key, bool value, bool update=false)
UString createGameID(const UString &path)
void exceptionDispatcherWarning(const char *s,...)
Exception dispatcher that prints the exception as a warning, and adds another reason on top...
utf8::iterator< std::string::const_iterator > iterator
const char * c_str() const
Return the (utf8 encoded) string data.
bool open(const UString &fileName)
Try to open the file with the given fileName.
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
ConfigDomain * _domainApp
Application domain, pointer into the config file.
bool open(const UString &fileName)
Try to open the file with the given fileName.
static bool isRegularFile(const UString &p)
Does specified path exist and is it a regular file?
bool getKey(const UString &key, UString &value) const
#define DECLARE_SINGLETON(T)
Note that you need to use this macro from the global namespace.
A class storing a basic configuration file.
static const char * kDomainApp
The name of the application domain.
UString _configFile
The config file to use.
static UString canonicalize(const UString &p, bool resolveSymLinks=true)
Return the canonical, absolutized and normalized path.
bool getDefaultBool(const UString &key) const
bool empty() const
Is the string empty?
ConfigRealm
Special config realms.
ConfigDomain * _domainGame
Game domain, pointer into the config file.
void create()
Create a new, empty config.
static UString getDirectory(const UString &p)
Return a path's directory.
ScopedPtr< ConfigDomain > _domainCommandline
Command line domain.
UString getDefaultString(const UString &key) const
Generic interface for a writable data stream.
Implementing the stream reading interfaces for files.
UString findGame(const UString &path)
Find the game domain using this path.
bool changed() const
Was at least on setting changed?
static UString getConfigDirectory()
Return the OS-specific path of the config directory.
static UString getStem(const UString &p)
Return a file name's stem.
ScopedPtr< ConfigFile > _config
The actual config.
Application or game defaults.
void clearCommandline()
Clear the command line options.
void setKey(const UString &key, const UString &value, bool update=false)
static bool createDirectories(const UString &path)
Create all directories in this path.
Accessor for a domain (section) in a config file.
bool hasDefaultKey(const UString &key) const
void set(const ConfigDomain &domain, bool clobber=true)
Add the keys of another domain.
bool getBool(const UString &key) const
UString getConfigFile() const
Return the config file that's currently in use.
static UString getDefaultConfigFile()
void setDouble(const UString &key, double value, bool update=false)
double getDouble(const UString &key) const
Implementing the stream writing interfaces for files.
bool save()
Save to the default config file.
ScopedPtr< ConfigDomain > _domainGameTemp
Temporary game settings domain.
const Exception kOpenError("Can't open file")
Exception when a file couldn't be opened.
bool isInGame() const
Are we currently in a game?
A simple streaming file writing class.
UString getString(const UString &key) const
void setKey(const UString &key, const UString &value)
bool hasGame(const UString &gameID)
Does the specified game domain exist?
bool hasKey(const UString &key) const
Interface for a seekable & readable data stream.
void parseString(const UString &str, T &value, bool allowEmpty)
Parse a string into any POD integer, float/double or bool type.
Utility class for manipulating file paths.
static bool isAlNum(uint32 c)
Is the character an ASCII alphanumeric character?
void setCommandlineKey(const UString &key, const UString &value)
Set a config value that came from the command line.
int getInt(const UString &key) const
void setInt(const UString &key, int value, bool update=false)