#ifndef CONF_PAIR_H #define CONF_PAIR_H #include #include #include #include #include "confpairbase.h" /** * */ template class ConfPair : public ConfPairBase { public: ConfPair( const std::string &sName ) : sName( sName ) { } virtual ~ConfPair() { } T &value() { return tValue; } const std::string &name() { return sName; } virtual void setFromString( const std::string &sStr ) { std::stringstream(sStr) >> tValue; } virtual std::string getAsString() { std::stringstream tmp; tmp << tValue; return tmp.str(); } private: std::string sName; T tValue; }; template<> void ConfPair::setFromString( const std::string &sStr ) { tValue = sStr; } template<> std::string ConfPair::getAsString() { return tValue; } template<> void ConfPair::setFromString( const std::string &sStr ) { if( !strcasecmp( sStr.c_str(), "true" ) || !strcasecmp( sStr.c_str(), "yes" ) || !strcasecmp( sStr.c_str(), "on" ) ) tValue = true; else tValue = false; } template<> std::string ConfPair::getAsString() { if( tValue == true ) return "True"; return "False"; } #endif