INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
hydrolibs/hydroutil/properties.h00001 /* 00002 Orca Project: Components for robotics 00003 http://orca-robotics.sf.net/ 00004 Copyright (c) 2004-2007 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 This copy of Orca is licensed to you under the terms described in the 00007 ORCA_LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef HYDROUTIL_PROPERTIES_H 00012 #define HYDROUTIL_PROPERTIES_H 00013 00014 #include <string> 00015 #include <map> 00016 #include <vector> 00017 00018 namespace hydroutil 00019 { 00020 00026 class Properties 00027 { 00028 public: 00029 00031 struct Config 00032 { 00034 Config( bool warnDefaultProp=false ) : 00035 warnDefaultProperty(warnDefaultProp) {}; 00036 00039 bool warnDefaultProperty; 00040 }; 00041 00043 Properties( const Config& config=Config() ); 00044 00051 Properties( const std::map<std::string,std::string>& props, 00052 const std::string& removePrefix="", 00053 const Config& config=Config(), 00054 const std::string &previouslyStrippedPrefix="" ); 00055 00058 bool isDefined( const ::std::string& key ); 00059 00062 void ensureDefined( const std::string& key ); 00063 00065 int getProperty( const ::std::string& key, std::string &value ) const; 00066 00068 std::string getPropertyWithDefault( const ::std::string& key, const std::string &defaultValue ) const; 00069 00072 int getPropertyAsDouble( const ::std::string& key, double &value ) const; 00073 00076 double getPropertyAsDoubleWithDefault( const ::std::string& key, const double defaultValue ) const; 00077 00082 int getPropertyAsDoubleVector( const ::std::string& key, std::vector<double> &value ) const; 00083 00086 std::vector<double> getPropertyAsDoubleVectorWithDefault( const ::std::string& key, const std::vector<double> &defaultValue ) const; 00087 00090 int getPropertyAsInt( const ::std::string& key, int &value ) const; 00091 00094 int getPropertyAsIntWithDefault( const ::std::string& key, const int defaultValue ) const; 00095 00100 int getPropertyAsIntVector( const ::std::string& key, std::vector<int> &value ) const; 00101 00104 std::vector<int> getPropertyAsIntVectorWithDefault( const ::std::string& key, const std::vector<int> &defaultValue ) const; 00105 00107 void setProperty( const ::std::string& key, const ::std::string& value ); 00108 00110 Properties propertiesWithStrippedPrefix( const std::string &prefixToStrip ) const; 00111 00113 size_t size() const { return props_.size(); }; 00114 00116 std::string toString() const; 00117 00120 std::string missingPropertyWarning( const std::string& key, bool fatal=false ); 00121 00122 const Config &config() const { return config_; } 00123 00124 private: 00125 00126 // Track the stripped prefix so we can report the _entire_ property string when defaults are used 00127 std::string strippedPrefix_; 00128 00129 std::map<std::string,std::string> props_; 00130 Config config_; 00131 }; 00132 00133 } // end namespace 00134 00135 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)