diff --git a/cmdopt.cpp b/cmdopt.cpp index 4ead8eda..e2aab6a2 100644 --- a/cmdopt.cpp +++ b/cmdopt.cpp @@ -18,7 +18,6 @@ #include "debug.hpp" -#include #include #include #include @@ -154,48 +153,6 @@ present::finish (void) } -/////////////////////////////////////////////////////////////////////////////// -namespace util { namespace cmdopt { namespace option { - template <> - void - value::execute (const char *restrict str) - { - static const std::string TRUE_STRING[] = { - "true", - "yes", - "y", - "1" - }; - - if (std::any_of (std::begin (TRUE_STRING), - std::end (TRUE_STRING), - [str] (auto i) { return i == str; })) - { - m_data = true; - return; - } - - static const std::string FALSE_STRING[] = { - "false", - "no", - "n", - "0" - }; - - if (std::any_of (std::begin (FALSE_STRING), - std::end (FALSE_STRING), - [str] (auto i) { return i == str; })) - { - m_data = false; - return; - } - - base::execute (str); - seen (true); - } -} } } - - //----------------------------------------------------------------------------- namespace util { namespace cmdopt { namespace option { template class value; diff --git a/cmdopt.ipp b/cmdopt.ipp index c77711ee..f4c3f878 100644 --- a/cmdopt.ipp +++ b/cmdopt.ipp @@ -20,6 +20,7 @@ #define __UTIL_CMDLINE_IPP #include +#include #include "./introspection.hpp" #include "./iterator.hpp" @@ -34,7 +35,7 @@ namespace util { namespace cmdopt { //------------------------------------------------------------------------- template - void + inline void option::value::execute (const char *restrict str) { try { @@ -53,6 +54,48 @@ namespace util { namespace cmdopt { } + //------------------------------------------------------------------------- + namespace option { + template <> + inline void + value::execute (const char *restrict str) + { + static const std::string TRUE_STRING[] = { + "true", + "yes", + "y", + "1" + }; + + if (std::any_of (std::begin (TRUE_STRING), + std::end (TRUE_STRING), + [str] (auto i) { return i == str; })) + { + m_data = true; + return; + } + + static const std::string FALSE_STRING[] = { + "false", + "no", + "n", + "0" + }; + + if (std::any_of (std::begin (FALSE_STRING), + std::end (FALSE_STRING), + [str] (auto i) { return i == str; })) + { + m_data = false; + return; + } + + base::execute (str); + seen (true); + } + } + + //------------------------------------------------------------------------- namespace detail { template