Ocular Engine
Ocular::Utils::Config Class Reference

#include <Config.hpp>

Public Member Functions

bool read ()
bool write ()
void setFile (Core::File const &file)
std::string get (std::string const &option) const
void set (std::string const &option, std::string const &value)

Protected Member Functions

bool isValidReadFile (Core::File const &file) const
bool isValidWriteFile (Core::File const &file) const

Detailed Description

Simple configuration utility.

Configuration options can be retrieved or set via the get and set methods:

std::string resolutionX = config->get("ResolutionX"); config->set("ResolutionY", 600);

All options are returned and set as strings. These strings can be converted to other types via the Ocular::Utils::String helper class (see OcularString).

There can be any number of configuration files in use, but the engine itself uses only one. This file is expected to be at 'engine.oconf' in the same directory as the executable being run.

If this configuration file is missing, it should generally be re-generated automatically by the engine during initialization. If it fails to be created, then one can be downloaded from: ...

Member Function Documentation

std::string Ocular::Utils::Config::get ( std::string const &  option) const

Retrieves the value of the specified option. If the option is not present, returns an empty string.

The validity of an option may be checked via hasOption.

The returned value may be converted to a non-string type via OcularString->fromString

[in]optionString option name
String option value
bool Ocular::Utils::Config::read ( )

Reads the set configuration file and populates the options map with it's contents.

void Ocular::Utils::Config::set ( std::string const &  option,
std::string const &  value 

Sets the value of the specified option.

void Ocular::Utils::Config::setFile ( Core::File const &  file)

Sets the configuration (.oconf) file to read from/write to.

bool Ocular::Utils::Config::write ( )

Overwrites the set configuration file with the current contents of the options map.

The documentation for this class was generated from the following files: