diff --git a/options.cpp b/options.cpp index f40002dd..f45113b8 100644 --- a/options.cpp +++ b/options.cpp @@ -131,6 +131,7 @@ presentoption::execute (void) { * Value option */ + namespace util { template<> bool& @@ -144,9 +145,36 @@ namespace util { return *val; } + + + template + T& + valueoption::get_arg(const std::string &arg, + T *val) + { + std::istringstream stream (arg, std::istringstream::in); + stream.exceptions ( + std::istringstream::failbit + | std::istringstream::badbit + ); + + stream >> *val; + return *val; + } } +template std::string& util::valueoption::get_arg (const std::string&, std::string*); + +template int16_t& util::valueoption< int16_t>::get_arg (const std::string&, int16_t*); +template int32_t& util::valueoption< int32_t>::get_arg (const std::string&, int32_t*); +template int64_t& util::valueoption< int64_t>::get_arg (const std::string&, int64_t*); + +template uint16_t& util::valueoption::get_arg (const std::string&, uint16_t*); +template uint32_t& util::valueoption::get_arg (const std::string&, uint32_t*); +template uint64_t& util::valueoption::get_arg (const std::string&, uint64_t*); + + /* * bytesoption */ diff --git a/options.hpp b/options.hpp index 10c82a68..f60d7a17 100644 --- a/options.hpp +++ b/options.hpp @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with libgim. If not, see . * - * Copyright 2013 Danny Robson + * Copyright 2013-2014 Danny Robson */ @@ -167,18 +167,11 @@ namespace util { protected: // Retrieve string to value conversion + static T& get_arg(const std::string &arg, - T *val) { - std::istringstream stream (arg, std::istringstream::in); - stream.exceptions ( - std::istringstream::failbit - | std::istringstream::badbit - ); - stream >> *val; - - return *val; - } + T *val); + static T& get_arg(const std::string &_arg, T *val, const T &defaultval) { @@ -303,5 +296,4 @@ namespace util { }; } - #endif