4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief VectorSupport non-inline template implementation */
26 //#include "VectorSupport.ih"
29 #include <boost/format.hpp>
32 ///////////////////////////////ct.p////////////////////////////////////////
36 template <class Sequence>
37 prefix_ void senf::console::SequenceArgumentTraits<Sequence>::
38 parse(ParseCommandInfo::TokensRange const & tokens, type & out)
41 CheckedArgumentIteratorWrapper arg (tokens);
43 out.push_back(typename Sequence::value_type());
44 senf::console::parse( *(arg++), out.back() );
48 template <class Sequence>
49 prefix_ std::string senf::console::SequenceArgumentTraits<Sequence>::description()
51 std::string type (prettyName(typeid(Sequence)));
52 std::string::size_type e (type.find('<'));
53 if (e == std::string::npos) e = type.size();
54 std::string::size_type b (type.rfind(':', e));
55 if (b == std::string::npos) b = 0; else ++b;
56 return type.substr(b,e-b) + "<"
57 + ArgumentTraits<typename Sequence::value_type>::description() + ">";
60 template <class Sequence>
61 prefix_ std::string senf::console::SequenceArgumentTraits<Sequence>::str(type const & value)
64 senf::console::format(value, ss);
68 template <class Sequence>
69 prefix_ void senf::console::SequenceReturnValueTraits<Sequence>::format(type const & value,
73 typename type::const_iterator i (value.begin());
74 typename type::const_iterator const i_end (value.end());
77 senf::console::format(*i, os);
86 template <class T1, class T2>
87 prefix_ void senf::console::ArgumentTraits< std::pair<T1,T2> >::
88 parse(ParseCommandInfo::TokensRange const & tokens, type & out)
90 CheckedArgumentIteratorWrapper arg (tokens);
91 senf::console::parse( *(arg++), out.first );
92 senf::console::parse( *(arg++), out.second );
95 template <class T1, class T2>
96 prefix_ std::string senf::console::ArgumentTraits< std::pair<T1,T2> >::description()
98 return (boost::format("pair<%s,%s>")
99 % ArgumentTraits<T1>::description()
100 % ArgumentTraits<T2>::description()).str();
103 template <class T1, class T2>
104 prefix_ std::string senf::console::ArgumentTraits< std::pair<T1,T2> >::str(type const & value)
106 std::stringstream ss;
107 senf::console::format(value, ss);
111 template <class T1, class T2>
112 prefix_ void senf::console::ReturnValueTraits< std::pair<T1,T2> >::format(type const & value,
116 senf::console::format(value.first, os);
118 senf::console::format(value.second, os);
124 ///////////////////////////////ct.e////////////////////////////////////////
131 // comment-column: 40
132 // c-file-style: "senf"
133 // indent-tabs-mode: nil
134 // ispell-local-dictionary: "american"
135 // compile-command: "scons -u test"