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::config
17 {
18 /** This class implements a config file-like interface over a memory-stored
19  * string list.
20 *
21  * Use base class `CConfigFileBase`'s methods
22  * `read_{int,float,double,string,...}()` and `write()` to actually read and
23  * write values.
24  *
25  * See: \ref config_file_format
26  * \ingroup mrpt_base_grp
27  */
29 {
30  public:
31  /** Empty constructor. Upon construction, call any of the "setContent"
32  * method */
34  /** Constructor and initialize from a list of strings */
35  CConfigFileMemory(const std::vector<std::string>& stringList);
36  /** Constructor and initialize from string with the whole "config file" */
37  CConfigFileMemory(const std::string& str);
38  /** dtor */
39  virtual ~CConfigFileMemory();
40 
41  /** Changes the contents of the virtual "config file" */
42  void setContent(const std::vector<std::string>& stringList);
43  /** Changes the contents of the virtual "config file" */
44  void setContent(const std::string& str);
45  /** Return the current contents of the virtual "config file" */
46  void getContent(std::string& str) const;
47  /** \overload */
48  inline std::string getContent() const
49  {
50  std::string s;
51  getContent(s);
52  return s;
53  }
54 
55  /** Returns a list with all the section names */
56  void getAllSections(std::vector<std::string>& sections) const override;
57  /** Returs a list with all the keys into a section */
58  void getAllKeys(const std::string& section, std::vector<std::string>& keys)
59  const override;
60 
61  private:
62  /** The IniFile object */
63  struct Impl;
65 
66  protected:
67  /** A virtual method to write a generic string */
68  void writeString(
69  const std::string& section, const std::string& name,
70  const std::string& str) override;
71  /** A virtual method to read a generic string */
73  const std::string& section, const std::string& name,
74  const std::string& defaultStr,
75  bool failIfNotFound = false) const override;
76 
77 }; // End of class def.
78 
79 }
80 
This class implements a config file-like interface over a memory-stored string list.
CConfigFileMemory()
Empty constructor.
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
GLdouble s
Definition: glext.h:3676
void getAllKeys(const std::string &section, std::vector< std::string > &keys) const override
Returs a list with all the keys into a section.
This class allows loading and storing values and vectors of different types from a configuration text...
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.
GLsizei const GLchar ** string
Definition: glext.h:4101
void getAllSections(std::vector< std::string > &sections) const override
Returns a list with all the section names.
void setContent(const std::vector< std::string > &stringList)
Changes the contents of the virtual "config file".
GLuint const GLchar * name
Definition: glext.h:4054
void writeString(const std::string &section, const std::string &name, const std::string &str) override
A virtual method to write a generic string.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020