Main MRPT website > C++ reference
MRPT logo

CConfigFileMemory.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef  CConfigFileMemory_H
00029 #define  CConfigFileMemory_H
00030 
00031 #include <mrpt/utils/utils_defs.h>
00032 #include <mrpt/utils/CConfigFileBase.h>
00033 #include <mrpt/utils/CStringList.h>
00034 #include <mrpt/utils/safe_pointers.h>
00035 
00036 /*---------------------------------------------------------------
00037         Class
00038   ---------------------------------------------------------------*/
00039 namespace mrpt
00040 {
00041 namespace utils
00042 {
00043         /** This class implements a config file-like interface over a memory-stored string list.
00044           */
00045         class BASE_IMPEXP CConfigFileMemory : public CConfigFileBase
00046         {
00047         private:
00048                 /** The IniFile object
00049                   */
00050                 void_ptr_noncopy                m_ini;
00051 
00052         protected:
00053                 /** A virtual method to write a generic string.
00054                   */
00055                 void  writeString(const std::string &section,const std::string &name, const std::string &str);
00056 
00057                 /** A virtual method to read a generic string.
00058                   */
00059                 std::string  readString(
00060             const std::string &section,
00061             const std::string &name,
00062             const std::string &defaultStr,
00063             bool failIfNotFound = false) const;
00064 
00065         public:
00066                 /** Constructor and initialize from a list of strings */
00067                 CConfigFileMemory( const utils::CStringList &stringList );
00068 
00069                 /** Constructor and initialize from string with the whole "config file"  */
00070                 CConfigFileMemory( const std::string &str );
00071 
00072                 /** Empty constructor. Upon construction, call any of the "setContent" method. */
00073                 CConfigFileMemory();
00074 
00075                 /** Copy constructor */
00076                 CConfigFileMemory(const CConfigFileMemory& o);
00077 
00078                 /** Copy operator */
00079                 CConfigFileMemory& operator = (const CConfigFileMemory& o);
00080 
00081                 /** Changes the contents of the virtual "config file" */
00082                 void setContent(  const utils::CStringList &stringList  );
00083 
00084                 /** Changes the contents of the virtual "config file" */
00085                 void setContent(  const std::string &str );
00086 
00087                 /** Return the currnet contents of the virtual "config file" */
00088                 void getContent(  std::string &str ) const;
00089 
00090                 /** Return the currnet contents of the virtual "config file" */
00091                 inline std::string getContent() const {  std::string s; getContent(s); return s; }
00092 
00093                 /** Destructor
00094                  */
00095                 virtual ~CConfigFileMemory( );
00096 
00097                 /** Returns a list with all the section names.
00098                   */
00099                 virtual void getAllSections( vector_string      &sections ) const;
00100 
00101                 /** Returs a list with all the keys into a section.
00102                   */
00103                 virtual void getAllKeys( const std::string section, vector_string       &keys ) const;
00104 
00105         }; // End of class def.
00106 
00107         } // End of namespace
00108 } // end of namespace
00109 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011