Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Utils / Console / STLSupport.ct
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief VectorSupport non-inline template implementation  */
25
26 //#include "VectorSupport.ih"
27
28 // Custom includes
29 #include <boost/format.hpp>
30
31 #define prefix_
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33
34 #ifndef DOXYGEN
35
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37 // senf::console::detail::CollectionArgumentTraitsBase<Collection>
38
39 template <class Collection>
40 prefix_ std::string
41 senf::console::detail::CollectionArgumentTraitsBase<Collection>::description()
42 {
43     return senf::prettyBaseName(typeid(Collection)) + "<"
44         + ArgumentTraits<typename Collection::value_type>::description() + ">";
45 }
46
47 template <class Collection>
48 prefix_ std::string
49 senf::console::detail::CollectionArgumentTraitsBase<Collection>::str(Collection const & value)
50 {
51     std::stringstream ss;
52     senf::console::format(value, ss);
53     return ss.str();
54 }
55
56 //-/////////////////////////////////////////////////////////////////////////////////////////////////
57 // senf::console::detail::CollectionArgumentTraits<Collection,Adder>
58
59 template <class Collection, class Adder>
60 prefix_ void senf::console::detail::CollectionArgumentTraits<Collection,Adder>::
61 parse(ParseCommandInfo::TokensRange const & tokens, Collection & out)
62 {
63     out.clear();
64     CheckedArgumentIteratorWrapper arg (tokens);
65     while (arg) {
66         typename Collection::value_type v;
67         senf::console::parse( *(arg++), v );
68         Adder::add(out,v);
69     }
70 }
71
72 //-/////////////////////////////////////////////////////////////////////////////////////////////////
73 // senf::console::detail::CollectionReturnValueTraits<Collection>
74
75 template <class Collection>
76 prefix_ void
77 senf::console::detail::CollectionReturnValueTraits<Collection>::format(Collection const & value,
78                                                                        std::ostream & os)
79 {
80     os << "(";
81     typename type::const_iterator i (value.begin());
82     typename type::const_iterator const i_end (value.end());
83     if (i != i_end)
84         for (;;) {
85             os << senf::console::str(*i);
86             if (++i == i_end)
87                 break;
88             else
89                 os << " ";
90         }
91     os << ")";
92 }
93
94 //-/////////////////////////////////////////////////////////////////////////////////////////////////
95 // senf::console::detail::MapArgumentTraits<Collection>
96
97 template <class Collection>
98 prefix_ void senf::console::detail::MapArgumentTraits<Collection>::
99 parse(ParseCommandInfo::TokensRange const & tokens, Collection & out)
100 {
101     out.clear();
102     CheckedArgumentIteratorWrapper arg (tokens);
103     while (arg) {
104         typename Collection::key_type key;
105         typename Collection::mapped_type data;
106         senf::console::parse( *(arg++), key );
107         ParseCommandInfo::TokensRange sep (*(arg++));
108         if (sep.size() != 1 || sep[0].type() != Token::OtherPunctuation || sep[0].value() != "=")
109             throw SyntaxErrorException("'=' expected");
110         senf::console::parse( *(arg++), data );
111         out.insert(std::make_pair(key,data));
112     }
113 }
114
115 template <class Collection>
116 prefix_ std::string senf::console::detail::MapArgumentTraits<Collection>::description()
117 {
118     return senf::prettyBaseName(typeid(Collection)) + "<"
119         + ArgumentTraits<typename Collection::key_type>::description() + ","
120         + ArgumentTraits<typename Collection::mapped_type>::description() + ">";
121 }
122
123 template <class Collection>
124 prefix_ std::string
125 senf::console::detail::MapArgumentTraits<Collection>::str(Collection const & value)
126 {
127     std::stringstream ss;
128     senf::console::format(value, ss);
129     return ss.str();
130 }
131
132 //-/////////////////////////////////////////////////////////////////////////////////////////////////
133 // senf::console::detail::MapReturnValueTraits<Collection>
134
135 template <class Collection>
136 prefix_ void
137 senf::console::detail::MapReturnValueTraits<Collection>::format(Collection const & value,
138                                                                 std::ostream & os)
139 {
140     os << "(";
141     typename type::const_iterator i (value.begin());
142     typename type::const_iterator const i_end (value.end());
143     if (i != i_end)
144         for (;;) {
145             os << senf::console::str(i->first)
146                << "="
147                << senf::console::str(i->second);
148             if (++i == i_end)
149                 break;
150             else
151                 os << " ";
152         }
153     os << ")";
154 }
155
156 //-/////////////////////////////////////////////////////////////////////////////////////////////////
157 // senf::console::ArgumentTraits< std::pair<T1,T2> >
158
159 template <class T1, class T2>
160 prefix_ void senf::console::ArgumentTraits< std::pair<T1,T2> >::
161 parse(ParseCommandInfo::TokensRange const & tokens, type & out)
162 {
163     CheckedArgumentIteratorWrapper arg (tokens);
164     senf::console::parse( *(arg++), out.first );
165     senf::console::parse( *(arg++), out.second );
166 }
167
168 template <class T1, class T2>
169 prefix_ std::string senf::console::ArgumentTraits< std::pair<T1,T2> >::description()
170 {
171     return (boost::format("pair<%s,%s>")
172             % ArgumentTraits<T1>::description()
173             % ArgumentTraits<T2>::description()).str();
174 }
175
176 template <class T1, class T2>
177 prefix_ std::string senf::console::ArgumentTraits< std::pair<T1,T2> >::str(type const & value)
178 {
179     std::stringstream ss;
180     senf::console::format(value, ss);
181     return ss.str();
182 }
183
184 //-/////////////////////////////////////////////////////////////////////////////////////////////////
185 // senf::console::ReturnValueTraits< std::pair<T1,T2> >
186
187 template <class T1, class T2>
188 prefix_ void senf::console::ReturnValueTraits< std::pair<T1,T2> >::format(type const & value,
189                                                                           std::ostream & os)
190 {
191     os << "(" << senf::console::str(value.first)
192        << " " << senf::console::str(value.second) << ")";
193 }
194
195 #endif
196
197 //-/////////////////////////////////////////////////////////////////////////////////////////////////
198 #undef prefix_
199
200 \f
201 // Local Variables:
202 // mode: c++
203 // fill-column: 100
204 // comment-column: 40
205 // c-file-style: "senf"
206 // indent-tabs-mode: nil
207 // ispell-local-dictionary: "american"
208 // compile-command: "scons -u test"
209 // End: