Main MRPT website > C++ reference for MRPT 1.9.9
config/CConfigFileMemory.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-2018, 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 
12 #include <mrpt/core/pimpl.h>
13 #include <string>
14 #include <vector>
15 
16 namespace mrpt
17 {
18 namespace config
19 {
20 /** This class implements a config file-like interface over a memory-stored
21  * string list.
22 *
23  * Use base class `CConfigFileBase`'s methods
24  * `read_{int,float,double,string,...}()` and `write()` to actually read and
25  * write values.
26  *
27  * See: \ref config_file_format
28  * \ingroup mrpt_base_grp
29  */
31 {
32  public:
33  /** Empty constructor. Upon construction, call any of the "setContent"
34  * method */
36  /** Constructor and initialize from a list of strings */
37  CConfigFileMemory(const std::vector<std::string>& stringList);
38  /** Constructor and initialize from string with the whole "config file" */
39  CConfigFileMemory(const std::string& str);
40  /** dtor */
41  virtual ~CConfigFileMemory();
42 
43  /** Changes the contents of the virtual "config file" */
44  void setContent(const std::vector<std::string>& stringList);
45  /** Changes the contents of the virtual "config file" */
46  void setContent(const std::string& str);
47  /** Return the current contents of the virtual "config file" */
48  void getContent(std::string& str) const;
49  /** \overload */
50  inline std::string getContent() const
51  {
52  std::string s;
53  getContent(s);
54  return s;
55  }
56 
57  /** Returns a list with all the section names */
58  void getAllSections(std::vector<std::string>& sections) const override;
59  /** Returs a list with all the keys into a section */
60  void getAllKeys(const std::string& section, std::vector<std::string>& keys)
61  const override;
62 
63  private:
64  /** The IniFile object */
65  struct Impl;
67 
68  protected:
69  /** A virtual method to write a generic string */
70  void writeString(
71  const std::string& section, const std::string& name,
72  const std::string& str) override;
73  /** A virtual method to read a generic string */
75  const std::string& section, const std::string& name,
76  const std::string& defaultStr,
77  bool failIfNotFound = false) const override;
78 
79 }; // End of class def.
80 
81 } // End of namespace
82 } // end of namespace
mrpt::config::CConfigFileMemory::getAllSections
void getAllSections(std::vector< std::string > &sections) const override
Returns a list with all the section names.
Definition: CConfigFileMemory.cpp:116
s
GLdouble s
Definition: glext.h:3676
mrpt::config::CConfigFileMemory::readString
std::string readString(const std::string &section, const std::string &name, const std::string &defaultStr, bool failIfNotFound=false) const override
A virtual method to read a generic string.
Definition: CConfigFileMemory.cpp:84
mrpt::config::CConfigFileMemory::getAllKeys
void getAllKeys(const std::string &section, std::vector< std::string > &keys) const override
Returs a list with all the keys into a section.
Definition: CConfigFileMemory.cpp:128
mrpt::pimpl
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
name
GLuint const GLchar * name
Definition: glext.h:4054
CConfigFileBase.h
mrpt::config::CConfigFileMemory::Impl
Definition: CConfigFileMemory.cpp:24
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::config::CConfigFileMemory::setContent
void setContent(const std::vector< std::string > &stringList)
Changes the contents of the virtual "config file".
Definition: CConfigFileMemory.cpp:53
mrpt::config::CConfigFileMemory::CConfigFileMemory
CConfigFileMemory()
Empty constructor.
Definition: CConfigFileMemory.cpp:48
mrpt::config::CConfigFileMemory::writeString
void writeString(const std::string &section, const std::string &name, const std::string &str) override
A virtual method to write a generic string.
Definition: CConfigFileMemory.cpp:72
mrpt::config::CConfigFileMemory::m_impl
mrpt::pimpl< Impl > m_impl
Definition: config/CConfigFileMemory.h:65
pimpl.h
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::config::CConfigFileMemory
This class implements a config file-like interface over a memory-stored string list.
Definition: config/CConfigFileMemory.h:30
mrpt::config::CConfigFileMemory::~CConfigFileMemory
virtual ~CConfigFileMemory()
dtor
Definition: CConfigFileMemory.cpp:71
mrpt::config::CConfigFileMemory::getContent
std::string getContent() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: config/CConfigFileMemory.h:50



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST