Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Properties.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00019 /*
00020  * $Log: Properties.h,v $
00021  * Revision 1.4  2007/01/06 17:59:23  n-ando
00022  * getProperty() is now const function.
00023  *
00024  * Revision 1.3  2006/10/17 10:10:21  n-ando
00025  * Some escape/unescape related bugs are fixed.
00026  * The following some functions were moved to StringUtil.h
00027  * - eraseHeadBlank(), eraseTailBlank(), replaceString()
00028  *
00029  * Revision 1.2  2006/10/13 03:50:00  n-ando
00030  * The bug that white space delimiter did not work properly was fixed.
00031  *
00032  * Revision 1.1  2006/09/11 18:09:57  n-ando
00033  * Java compatible properties class.
00034  *
00035  *
00036  */
00037 
00038 #ifndef Properties_h
00039 #define Properties_h
00040 
00041 
00042 #include <string>
00043 #include <map>
00044 #include <vector>
00045 
00046 
00047 namespace RTC
00048 {
00108   class Properties
00109     : public std::map<std::string, std::string>
00110   {
00111   public:
00127     Properties(){};
00128     
00129     
00145     Properties(const std::map<std::string, std::string>& defaults);
00146     
00147     
00193     Properties(const char* defaults[], long num = LONG_MAX);
00194     
00195     
00207     virtual ~Properties();
00208     
00209     
00237     std::string getProperty(const std::string& key) const;
00238     
00268     std::string getProperty(const std::string& key,
00269                             const std::string& defaultValue) const;
00270     
00292     void list(std::ostream& out);
00293     
00294     
00453     void load(std::istream& inStream);
00454     
00455     
00481     std::vector<std::string> propertyNames();
00482     
00483     
00507     void save(std::ostream& out, const std::string& header);
00508     
00509     
00536     std::string setProperty(const std::string& key, const std::string& value);
00537     
00538     
00619     void store(std::ostream& out, const std::string& header);
00620     
00621   protected:
00622     void splitKeyValue(const std::string& str, std::string& key,
00623                        std::string& value);
00624     
00625     std::map<std::string, std::string> m_defaults;
00626     typedef std::map<std::string, std::string>::iterator Itr;
00627     
00628   };   // class Properties
00629 };     // namespace RTC  
00630 #endif // Properties_h
00631   

Generated on Mon Jan 15 12:15:35 2007 for OpenRTM by  doxygen 1.4.1