/** \file
\brief Traits inline template implementation */
-//#include "Traits.ih"
+#include "Traits.ih"
// Custom includes
+#include <sstream>
+#include <boost/lexical_cast.hpp>
#include "../Utils/TypeInfo.hh"
#define prefix_ inline
prefix_ void senf::console::ReturnValueTraits<Type>::format(Type const & value,
std::ostream & os)
{
+ senf_console_format_value(value, os);
+}
+
+template <class Type>
+prefix_ void senf::console::senf_console_format_value(Type const & value, std::ostream & os)
+{
os << value;
}
prefix_ void senf::console::ArgumentTraits<Type>::
parse(ParseCommandInfo::TokensRange const & tokens, Type & out)
{
- if (tokens.size() != 1)
- throw SyntaxErrorException("parameter syntax error");
+ senf_console_parse_argument(tokens,out);
+}
- try {
- out = boost::lexical_cast<Type>(tokens.begin()[0].value());
- }
- catch (std::bad_cast & ex) {
- throw SyntaxErrorException("parameter syntax error");
- }
+template <class Type>
+prefix_ void senf::console::parse(ParseCommandInfo::TokensRange const & tokens, Type & out)
+{
+ ArgumentTraits<Type>::parse(tokens, out);
}
template <class Type>
template <class Type>
prefix_ std::string senf::console::ArgumentTraits<Type>::str(Type const & value)
{
- return boost::lexical_cast<std::string>(value);
+ std::stringstream ss;
+ senf::console::ReturnValueTraits<Type>::format(value, ss);
+ return ss.str();
}
///////////////////////////////cti.e///////////////////////////////////////