Main MRPT website
>
C++ reference for MRPT 1.4.0
mrpt
utils
CConfigFilePrefixer.h
Go to the documentation of this file.
1
/* +---------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+---------------------------------------------------------------------------+ */
9
#pragma once
10
11
#include <
mrpt/utils/CConfigFileBase.h
>
12
13
namespace
mrpt
14
{
15
namespace
utils
16
{
17
/** A wrapper for other CConfigFileBase-based objects that prefixes a given token to every key and/or section.
18
* If, for example, your code expect:
19
* \code
20
* [params1]
21
* foo = 34.0
22
* bar = /dev/ttyUSB0
23
* \endcode
24
*
25
* Using this class with key entries prefix "s1_" will enable the same existing code to transparently parse this file content:
26
*
27
* \code
28
* [params1]
29
* s1_foo = 34.0
30
* s1_bar = /dev/ttyUSB0
31
* \endcode
32
*
33
* \sa CConfigFileBase
34
* \ingroup mrpt_base_grp
35
*/
36
class
BASE_IMPEXP
CConfigFilePrefixer
:
public
CConfigFileBase
37
{
38
private
:
39
CConfigFileBase
*
m_bound_object
;
//!< The object we are wrapping
40
std::string
m_prefix_sections
, m_prefix_keys;
41
42
protected
:
43
void
writeString(
const
std::string §ion,
const
std::string &name,
const
std::string &str)
MRPT_OVERRIDE
;
44
std::string readString(
const
std::string §ion,
const
std::string &name,
const
std::string &defaultStr,
bool
failIfNotFound =
false
) const
MRPT_OVERRIDE
;
45
46
public:
47
/** Unbound constructor: must bind this object to CConfigFileBase before usage with \a bind() and \a setPrefixes() */
48
CConfigFilePrefixer
();
49
/** Construct and bind to (wrap) a given object with given prefix texts */
50
CConfigFilePrefixer
(const
CConfigFileBase
&o, const std::
string
&prefix_sections, const std::
string
&prefix_keys);
51
52
/** Make this object to wrap the given existing CConfigFileBase object. Can be changed at any moment after construction */
53
void
bind(const
CConfigFileBase
&o);
54
55
/** Change the prefix for sections and keys. Can be called at any moment. */
56
void
setPrefixes(const std::
string
&prefix_sections, const std::
string
&prefix_keys);
57
58
std::
string
getSectionPrefix() const;
59
std::
string
getKeyPrefix() const;
60
CConfigFileBase
*getBoundConfigFileBase() const;
//!< Returns the currently-bounded config source, or NULL if none.
61
62
virtual ~
CConfigFilePrefixer
();
63
64
void
getAllSections(
vector_string
§ions ) const
MRPT_OVERRIDE
;
// See base class docs
65
void
getAllKeys( const std::
string
§ion,
vector_string
&keys ) const
MRPT_OVERRIDE
;
// See base class docs
66
67
};
// End of class def.
68
}
// End of namespace
69
}
// end of namespace
mrpt::utils::CConfigFilePrefixer::m_prefix_sections
std::string m_prefix_sections
Definition:
CConfigFilePrefixer.h:40
mrpt::vector_string
std::vector< std::string > vector_string
A type for passing a vector of strings.
Definition:
types_simple.h:30
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition:
CParticleFilter.h:16
mrpt::utils::CConfigFilePrefixer::m_bound_object
CConfigFileBase * m_bound_object
The object we are wrapping.
Definition:
CConfigFilePrefixer.h:39
mrpt::utils::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition:
CConfigFileBase.h:30
CConfigFileBase.h
MRPT_OVERRIDE
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition:
mrpt_macros.h:28
mrpt::utils::CConfigFilePrefixer
A wrapper for other CConfigFileBase-based objects that prefixes a given token to every key and/or sec...
Definition:
CConfigFilePrefixer.h:36
BASE_IMPEXP
#define BASE_IMPEXP
Definition:
base/include/mrpt/base/link_pragmas.h:90
Page generated by
Doxygen 1.8.17
for MRPT 1.4.0 SVN: at Tue Mar 3 09:15:16 UTC 2020