Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
rviz::Config Class Reference

#include <config.h>

List of all members.

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_

Detailed Description

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.

Definition at line 44 of file config.h.


Member Typedef Documentation

typedef Map::iterator rviz::Config::Iterator

Definition at line 78 of file config.h.

typedef std::map<std::string, std::string, DirectoryCompare> rviz::Config::Map

Definition at line 77 of file config.h.


Member Function Documentation

Definition at line 80 of file config.h.

void rviz::Config::clear ( void  ) [inline]

Definition at line 83 of file config.h.

Definition at line 81 of file config.h.

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().

Definition at line 88 of file config.h.

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)
Returns:
success or failure of the initial file-open.

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]

Remove a key/value pair. This will invalidate iterators pointing at the given element.

Definition at line 65 of file config.h.

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)
Returns:
success or failure of the initial file-open.

Definition at line 55 of file config.cpp.


Member Data Documentation

std::string rviz::Config::error_message_ [private]

Definition at line 107 of file config.h.

Definition at line 105 of file config.h.


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


rviz
Author(s): Dave Hershberger, Josh Faust
autogenerated on Mon Jan 6 2014 11:54:33