Parameterlist.h
Go to the documentation of this file.00001
00002
00003 #pragma once
00004
00005
00006 #include <string.h>
00007 #include <iostream>
00008 #include <assert.h>
00009 #include <vector>
00019 using namespace std;
00020
00025 class Parameter
00026 {
00027 friend class Parameterlist;
00028
00029 public:
00030
00033 string name_m;
00034 string value_m;
00035 string comment_m;
00036 bool bUsed_m;
00037 bool bDefaultValue_m;
00038
00039 unsigned short order_m;
00040
00043
00044 Parameter(const string &name, const string &value, const string &comment, bool fromDefault=false) ;
00045
00048 std::string getName( );
00049 void setName( const string & value);
00050
00051 std::string & getValue( );
00052 std::string & getValueAsString( );
00053 void setValue( const string & value);
00054
00055 unsigned short getPrintOrder( ) const;
00056 void setPrintOrder(unsigned short order);
00057
00058 bool isUsed() const;
00059
00060 bool isDefaultValue() const;
00061
00062 void markUsed();
00063
00071 static bool compareParameterOrder( Parameter * const & par1, Parameter * const & par2)
00072 {
00073 return par1->order_m < par2->order_m;
00074 }
00080
00081 ostream & printParameter(ostream & os) const;
00082
00084 ostream & printParameterWithComment(ostream & os) const;
00086 ostream & printParameterDetailed(ostream & os) const;
00089 };
00090
00091 std::ostream & operator<<(std::ostream & out, const Parameter & z);
00092
00093
00094
00095
00096
00109 class Parameterlist
00110 {
00111 public:
00112 Parameterlist();
00113 virtual ~Parameterlist();
00114
00115
00116 static const string emptyString;
00117
00118 typedef std::vector < Parameter * > ParamListType;
00119
00122 size_t getParameterCount() const;
00123
00124 Parameter& getParameterRef(unsigned int idx) ;
00125
00126 string & getParameterValueByName (const string & paramName );
00127
00128 string & getParameterValueByName (const char * paramName );
00129
00130 Parameter& getParameterRefByName( const string & paramName ) ;
00131
00132 Parameter & getParameterRefByName (const char * paramName ) ;
00133
00141 bool paramExists (const string & paramName ) const;
00142
00143 void addParameter (const string & paramName, const string & paramVal, const string &_comment = emptyString );
00144 void addDefaultParameter(const string & paramName, const string & paramVal, const string &_comment = emptyString );
00145
00146 void setParameterValue (const string & paramName, const string ¶mVal);
00147
00148 void markAsUsed (const string & paramName);
00149
00150 void resetUsedStatus();
00151
00157 void printNotUsedParameters (ostream & os) const;
00158 void printUsedParameters (ostream & os) const;
00161 private:
00162
00165 int getParameterIdx(const string & paramName) const;
00166
00171 ParamListType parameters_m;
00173 };
00174
00175