diff --git a/cmdopt.cpp b/cmdopt.cpp index 968bdc7f..5ab3d2d2 100644 --- a/cmdopt.cpp +++ b/cmdopt.cpp @@ -20,7 +20,6 @@ #include #include -#include using util::cmdopt::option::base; using util::cmdopt::option::bytes; @@ -77,53 +76,6 @@ base::name (void) const /////////////////////////////////////////////////////////////////////////////// -template -value::value (std::string _name, T &_data): - base (_name), - m_data (_data) -{ ; } - - -//----------------------------------------------------------------------------- -template -void -value::execute (const char *restrict str) -{ - try { - std::istringstream os (str); - os.exceptions ( - std::istringstream::failbit - | std::istringstream::badbit - ); - os >> m_data; - - if (!os.eof ()) - throw invalid_value (__func__); - } catch (...) { - throw invalid_value (__func__); - } -} - - -//----------------------------------------------------------------------------- -template -T -value::data (void) const -{ - return m_data; -} - - -//----------------------------------------------------------------------------- -template -T& -value::data (void) -{ - return m_data; -} - - -//----------------------------------------------------------------------------- namespace util { namespace cmdopt { namespace option { template class value; template class value; diff --git a/cmdopt.ipp b/cmdopt.ipp index 8b17c131..8a041c28 100644 --- a/cmdopt.ipp +++ b/cmdopt.ipp @@ -19,7 +19,57 @@ #endif #define __UTIL_CMDLINE_IPP +#include + namespace util { namespace cmdopt { + /////////////////////////////////////////////////////////////////////////// + template + option::value::value (std::string _name, T &_data): + base (std::move (_name)), + m_data (_data) + { ; } + + + //------------------------------------------------------------------------- + template + void + option::value::execute (const char *restrict str) + { + try { + std::istringstream os (str); + os.exceptions ( + std::istringstream::failbit + | std::istringstream::badbit + ); + os >> m_data; + + if (!os.eof ()) + throw invalid_value (__func__); + } catch (...) { + throw invalid_value (__func__); + } + } + + + //----------------------------------------------------------------------------- + template + T + option::value::data (void) const + { + return m_data; + } + + + //----------------------------------------------------------------------------- + template + T& + option::value::data (void) + { + return m_data; + } + + + /////////////////////////////////////////////////////////////////////////// template T& parser::add (char shortname, std::string longname, std::string description, Args&&... args)