X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fgetopt.h;h=ea1f7d36a33fcea90ba552e58cb8b7546e462f34;hp=bfa2ef2092feb82d62a0f9ced8655df48d67941e;hb=d3b4cafbbb684a6f65ee9cc19162f2546c5326cb;hpb=967785734be5c3fc6f75da122c2d93ebbb338271 diff --git a/source/core/getopt.h b/source/core/getopt.h index bfa2ef2..ea1f7d3 100644 --- a/source/core/getopt.h +++ b/source/core/getopt.h @@ -65,6 +65,9 @@ private: template class Option: public OptBase { + private: + T &data; + public: Option(char s, const std::string &l, T &d, ArgType a): OptBase(s, l, a), data(d) { } @@ -81,13 +84,14 @@ private: throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")"); } } - private: - T &data; }; template class ListOption: public OptBase { + private: + T &data; + public: ListOption(char s, const std::string &l, T &d, ArgType a): OptBase(s, l, a), data(d) { if(arg_type!=REQUIRED_ARG) throw std::invalid_argument("ListOption arg_type!=REQUIRED"); } @@ -105,8 +109,6 @@ private: throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")"); } } - private: - T &data; }; bool help; @@ -156,8 +158,11 @@ public: std::string generate_help() const; }; -template<> inline void GetOpt::Option::store() { data = true; } -template<> inline void GetOpt::Option::store() { ++data; } +template<> inline void GetOpt::Option::store() +{ data = true; } + +template<> inline void GetOpt::Option::store() +{ ++data; } template<> inline void GetOpt::Option::store(const std::string &a) { data = a; }