#include <config.h>
Classes | |
class | DirectoryCompare |
Public Types | |
typedef Map::iterator | Iterator |
typedef std::map< std::string, std::string, DirectoryCompare > | Map |
Public Member Functions | |
Iterator | begin () |
void | clear () |
Iterator | end () |
bool | get (const std::string &key, std::string *output, const std::string &default_value="") |
bool | get (const std::string &key, float *output, float default_value=0) |
bool | get (const std::string &key, int *output, int default_value=0) |
std::string | getErrorMessage () const |
Return the latest error message. | |
void | read (std::istream &input) |
bool | readFromFile (const std::string &filename) |
void | set (const std::string &key, const std::string &value) |
void | set (const std::string &key, float value) |
void | set (const std::string &key, int value) |
void | unset (const std::string &key) |
void | write (std::ostream &output) |
bool | writeToFile (const std::string &filename) |
Private Member Functions | |
std::string | escapeKey (const std::string &raw_key) |
const std::string | stripFirstSlash (const std::string &str) |
std::string | unescapeKey (const std::string &cooked_key) |
void | writeDirectory (std::ostream &output, const std::string &new_dir, const std::string &prev_dir) |
Private Attributes | |
std::string | error_message_ |
Map | map_ |
Configuration data structure. Inspired by rviz's use of wxConfigBase. Current implementation uses a flat ordered map, but in the long run it may more sense to use a recursive data structure.
typedef Map::iterator rviz::Config::Iterator |
typedef std::map<std::string, std::string, DirectoryCompare> rviz::Config::Map |
Iterator rviz::Config::begin | ( | ) | [inline] |
void rviz::Config::clear | ( | void | ) | [inline] |
Iterator rviz::Config::end | ( | ) | [inline] |
std::string rviz::Config::escapeKey | ( | const std::string & | raw_key | ) | [private] |
Escape ' ' and ':' characters with '\'.
Definition at line 204 of file config.cpp.
bool rviz::Config::get | ( | const std::string & | key, |
std::string * | output, | ||
const std::string & | default_value = "" |
||
) |
Definition at line 273 of file config.cpp.
bool rviz::Config::get | ( | const std::string & | key, |
float * | output, | ||
float | default_value = 0 |
||
) |
Definition at line 285 of file config.cpp.
bool rviz::Config::get | ( | const std::string & | key, |
int * | output, | ||
int | default_value = 0 |
||
) |
Definition at line 302 of file config.cpp.
std::string rviz::Config::getErrorMessage | ( | ) | const [inline] |
Return the latest error message.
Currently error messages are only generated by writeToFile() and readFromFile().
void rviz::Config::read | ( | std::istream & | input | ) |
Read settings from a stream. Invalid lines are ignored.
Definition at line 71 of file config.cpp.
bool rviz::Config::readFromFile | ( | const std::string & | filename | ) |
Definition at line 39 of file config.cpp.
void rviz::Config::set | ( | const std::string & | key, |
const std::string & | value | ||
) |
Definition at line 254 of file config.cpp.
void rviz::Config::set | ( | const std::string & | key, |
float | value | ||
) |
Definition at line 259 of file config.cpp.
void rviz::Config::set | ( | const std::string & | key, |
int | value | ||
) |
Definition at line 266 of file config.cpp.
const std::string rviz::Config::stripFirstSlash | ( | const std::string & | str | ) | [private] |
If the first char of str is a '/', return everything but the first char in a new string. If it is not, return str.
Definition at line 319 of file config.cpp.
std::string rviz::Config::unescapeKey | ( | const std::string & | cooked_key | ) | [private] |
Un-escape ' ' and ':' characters with '\'.
Definition at line 227 of file config.cpp.
void rviz::Config::unset | ( | const std::string & | key | ) | [inline] |
void rviz::Config::write | ( | std::ostream & | output | ) |
Write settings to a stream.
Definition at line 113 of file config.cpp.
void rviz::Config::writeDirectory | ( | std::ostream & | output, |
const std::string & | new_dir, | ||
const std::string & | prev_dir | ||
) | [private] |
Write a directory description of new_dir to output, given that we were previously "in" prev_dir.
Definition at line 168 of file config.cpp.
bool rviz::Config::writeToFile | ( | const std::string & | filename | ) |
Definition at line 55 of file config.cpp.
std::string rviz::Config::error_message_ [private] |
Map rviz::Config::map_ [private] |