// $Id$ // // Copyright (C) 2009 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file \brief VectorSupport non-inline template implementation */ //#include "VectorSupport.ih" // Custom includes #include #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// #ifndef DOXYGEN //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::detail::CollectionArgumentTraitsBase template prefix_ std::string senf::console::detail::CollectionArgumentTraitsBase::description() { return senf::prettyBaseName(typeid(Collection)) + "<" + ArgumentTraits::description() + ">"; } template prefix_ std::string senf::console::detail::CollectionArgumentTraitsBase::str(Collection const & value) { std::stringstream ss; senf::console::format(value, ss); return ss.str(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::detail::CollectionArgumentTraits template prefix_ void senf::console::detail::CollectionArgumentTraits:: parse(ParseCommandInfo::TokensRange const & tokens, Collection & out) { out.clear(); CheckedArgumentIteratorWrapper arg (tokens); while (arg) { typename Collection::value_type v; senf::console::parse( *(arg++), v ); Adder::add(out,v); } } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::detail::CollectionReturnValueTraits template prefix_ void senf::console::detail::CollectionReturnValueTraits::format(Collection const & value, std::ostream & os) { os << "("; typename type::const_iterator i (value.begin()); typename type::const_iterator const i_end (value.end()); if (i != i_end) for (;;) { os << senf::console::str(*i); if (++i == i_end) break; else os << " "; } os << ")"; } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::detail::MapArgumentTraits template prefix_ void senf::console::detail::MapArgumentTraits:: parse(ParseCommandInfo::TokensRange const & tokens, Collection & out) { out.clear(); CheckedArgumentIteratorWrapper arg (tokens); while (arg) { typename Collection::key_type key; typename Collection::mapped_type data; senf::console::parse( *(arg++), key ); ParseCommandInfo::TokensRange sep (*(arg++)); if (sep.size() != 1 || sep[0].type() != Token::OtherPunctuation || sep[0].value() != "=") throw SyntaxErrorException("'=' expected"); senf::console::parse( *(arg++), data ); out.insert(std::make_pair(key,data)); } } template prefix_ std::string senf::console::detail::MapArgumentTraits::description() { return senf::prettyBaseName(typeid(Collection)) + "<" + ArgumentTraits::description() + "," + ArgumentTraits::description() + ">"; } template prefix_ std::string senf::console::detail::MapArgumentTraits::str(Collection const & value) { std::stringstream ss; senf::console::format(value, ss); return ss.str(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::detail::MapReturnValueTraits template prefix_ void senf::console::detail::MapReturnValueTraits::format(Collection const & value, std::ostream & os) { os << "("; typename type::const_iterator i (value.begin()); typename type::const_iterator const i_end (value.end()); if (i != i_end) for (;;) { os << senf::console::str(i->first) << "=" << senf::console::str(i->second); if (++i == i_end) break; else os << " "; } os << ")"; } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::ArgumentTraits< std::pair > template prefix_ void senf::console::ArgumentTraits< std::pair >:: parse(ParseCommandInfo::TokensRange const & tokens, type & out) { CheckedArgumentIteratorWrapper arg (tokens); senf::console::parse( *(arg++), out.first ); senf::console::parse( *(arg++), out.second ); } template prefix_ std::string senf::console::ArgumentTraits< std::pair >::description() { return (boost::format("pair<%s,%s>") % ArgumentTraits::description() % ArgumentTraits::description()).str(); } template prefix_ std::string senf::console::ArgumentTraits< std::pair >::str(type const & value) { std::stringstream ss; senf::console::format(value, ss); return ss.str(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::ReturnValueTraits< std::pair > template prefix_ void senf::console::ReturnValueTraits< std::pair >::format(type const & value, std::ostream & os) { os << "(" << senf::console::str(value.first) << " " << senf::console::str(value.second) << ")"; } #endif //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // End: