Fix SCons 1.2.0 build failure
[senf.git] / 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 ///////////////////////////////ct.p////////////////////////////////////////
33
34 #ifndef DOXYGEN
35
36 template <class Sequence>
37 prefix_ void senf::console::SequenceArgumentTraits<Sequence>::
38 parse(ParseCommandInfo::TokensRange const & tokens, type & out)
39 {
40     out.clear();
41     CheckedArgumentIteratorWrapper arg (tokens);
42     while (arg) {
43         out.push_back(typename Sequence::value_type());
44         senf::console::parse( *(arg++), out.back() );
45     }
46 }
47
48 template <class Sequence>
49 prefix_ std::string senf::console::SequenceArgumentTraits<Sequence>::description()
50 {
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() + ">";
58 }
59
60 template <class Sequence>
61 prefix_ std::string senf::console::SequenceArgumentTraits<Sequence>::str(type const & value)
62 {
63     std::stringstream ss;
64     senf::console::format(value, ss);
65     return ss.str();
66 }
67
68 template <class Sequence>
69 prefix_ void senf::console::SequenceReturnValueTraits<Sequence>::format(type const & value,
70                                                                         std::ostream & os)
71 {
72     os << "(";
73     typename type::const_iterator i (value.begin());
74     typename type::const_iterator const i_end (value.end());
75     if (i != i_end)
76         for (;;) {
77             senf::console::format(*i, os);
78             if (++i == i_end) 
79                 break;
80             else
81                 os << " ";
82         }
83     os << ")";
84 }
85
86 template <class T1, class T2>
87 prefix_ void senf::console::ArgumentTraits< std::pair<T1,T2> >::
88 parse(ParseCommandInfo::TokensRange const & tokens, type & out)
89 {
90     CheckedArgumentIteratorWrapper arg (tokens);
91     senf::console::parse( *(arg++), out.first );
92     senf::console::parse( *(arg++), out.second );
93 }
94
95 template <class T1, class T2>
96 prefix_ std::string senf::console::ArgumentTraits< std::pair<T1,T2> >::description()
97 {
98     return (boost::format("pair<%s,%s>")
99             % ArgumentTraits<T1>::description()
100             % ArgumentTraits<T2>::description()).str();
101 }
102
103 template <class T1, class T2>
104 prefix_ std::string senf::console::ArgumentTraits< std::pair<T1,T2> >::str(type const & value)
105 {
106     std::stringstream ss;
107     senf::console::format(value, ss);
108     return ss.str();
109 }
110
111 template <class T1, class T2>
112 prefix_ void senf::console::ReturnValueTraits< std::pair<T1,T2> >::format(type const & value,
113                                                                           std::ostream & os)
114 {
115     os << "(";
116     senf::console::format(value.first, os);
117     os << " ";
118     senf::console::format(value.second, os);
119     os << ")";
120 }
121
122 #endif
123
124 ///////////////////////////////ct.e////////////////////////////////////////
125 #undef prefix_
126
127 \f
128 // Local Variables:
129 // mode: c++
130 // fill-column: 100
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"
136 // End: