Whitespce cleanup: Remove whitespace at end-on-line, remove tabs, wrap
[senf.git] / senf / Utils / Console / Traits.ih
index 85213bb..f979e9e 100644 (file)
@@ -1,6 +1,6 @@
 // $Id$
 //
-// Copyright (C) 2008 
+// Copyright (C) 2008
 // Fraunhofer Institute for Open Communication Systems (FOKUS)
 // Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 
 // Custom includes
 #include <string>
+#include <limits>
 #include <boost/preprocessor/seq/for_each.hpp>
 #include <boost/preprocessor/stringize.hpp>
 #include <boost/preprocessor/facilities/empty.hpp>
 #include <boost/bimap.hpp>
 #include <boost/assign/list_inserter.hpp>
 #include <boost/algorithm/string/case_conv.hpp>
-#include <senf/Utils/singleton.hh>
+#include <boost/mpl/if.hpp>
 
 ///////////////////////////////ih.p////////////////////////////////////////
 
 namespace senf {
 namespace console {
+
+    template <class _> struct ArgumentTraits;
+    template <class _> struct ReturnValueTraits;
+
 namespace detail {
 
+    template <class CharT>
+    struct MatchingShortType
+        : public boost::mpl::if_c<std::numeric_limits<CharT>::is_signed,short,unsigned short>
+    {};
+
+    template <class CharT>
+    struct CharArgumentTraits
+        : public ArgumentTraits<typename MatchingShortType<CharT>::type>
+    {
+        typedef ArgumentTraits<typename MatchingShortType<CharT>::type> base;
+        typedef CharT type;
+        static void parse(ParseCommandInfo::TokensRange const & tokens, CharT & out);
+        static std::string description();
+    };
+
+    template <class CharT>
+    struct CharReturnValueTraits
+        : public ReturnValueTraits<typename MatchingShortType<CharT>::type>
+    {
+        typedef CharT type;
+    };
+
 #ifndef DOXYGEN
     struct StringILess
     {
         bool operator()(std::string const & left, std::string const & right) const
-            { return boost::algorithm::to_lower_copy(left) 
+            { return boost::algorithm::to_lower_copy(left)
                   < boost::algorithm::to_lower_copy(right); }
     };