STLSupport.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_Console_STLSupport_
18 #define HH_SENF_Utils_Console_STLSupport_ 1
19 
20 // Custom includes
21 #include <vector>
22 #include <list>
23 #include "Traits.hh"
24 #ifdef SENF_CXX11_ENABLED
25 # include <tuple>
26 #endif
27 
28 #include "STLSupport.ih"
29 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30 
31 namespace senf {
32 namespace console {
33 
34 #ifndef DOXYGEN
35 
36  template <class T, class Alloc>
37  struct ArgumentTraits< std::vector<T,Alloc> >
38  : public detail::CollectionArgumentTraits< std::vector<T,Alloc>,
39  detail::PushBackFunctor >
40  {};
41 
42  template <class T, class Alloc>
43  struct ReturnValueTraits< std::vector<T,Alloc> >
44  : public detail::CollectionReturnValueTraits< std::vector<T,Alloc> >
45  {};
46 
47  template <class T, class Alloc>
48  struct ArgumentTraits< std::list<T,Alloc> >
49  : public detail::CollectionArgumentTraits< std::list<T,Alloc>,
50  detail::PushBackFunctor >
51  {};
52 
53  template <class T, class Alloc>
54  struct ReturnValueTraits< std::list<T,Alloc> >
55  : public detail::CollectionReturnValueTraits< std::list<T,Alloc> >
56  {};
57 
58  template <class Key, class Compare, class Alloc>
59  struct ArgumentTraits< std::set<Key,Compare,Alloc> >
60  : public detail::CollectionArgumentTraits< std::set<Key,Compare,Alloc>,
61  detail::InsertFunctor >
62  {};
63 
64  template <class Key, class Compare, class Alloc>
65  struct ReturnValueTraits< std::set<Key,Compare,Alloc> >
66  : public detail::CollectionReturnValueTraits< std::set<Key,Compare,Alloc> >
67  {};
68 
69  template <class Key, class Compare, class Alloc>
70  struct ArgumentTraits< std::multiset<Key,Compare,Alloc> >
71  : public detail::CollectionArgumentTraits< std::multiset<Key,Compare,Alloc>,
72  detail::InsertFunctor >
73  {};
74 
75  template <class Key, class Compare, class Alloc>
76  struct ReturnValueTraits< std::multiset<Key,Compare,Alloc> >
77  : public detail::CollectionReturnValueTraits< std::multiset<Key,Compare,Alloc> >
78  {};
79 
80  template <class Key, class Data, class Compare, class Alloc>
81  struct ArgumentTraits< std::map<Key,Data,Compare,Alloc> >
82  : public detail::MapArgumentTraits< std::map<Key,Data,Compare,Alloc> >
83  {};
84 
85  template <class Key, class Data, class Compare, class Alloc>
86  struct ReturnValueTraits< std::map<Key,Data,Compare,Alloc> >
87  : public detail::MapReturnValueTraits< std::map<Key,Data,Compare,Alloc> >
88  {};
89 
90  template <class Key, class Data, class Compare, class Alloc>
91  struct ArgumentTraits< std::multimap<Key,Data,Compare,Alloc> >
92  : public detail::MapArgumentTraits< std::multimap<Key,Data,Compare,Alloc> >
93  {};
94 
95  template <class Key, class Data, class Compare, class Alloc>
96  struct ReturnValueTraits< std::multimap<Key,Data,Compare,Alloc> >
97  : public detail::MapReturnValueTraits< std::multimap<Key,Data,Compare,Alloc> >
98  {};
99 
100  template <class T1, class T2>
101  struct ArgumentTraits< std::pair<T1,T2> >
102  {
103  typedef std::pair<T1,T2> type;
104  static bool const singleToken = false;
105 
106  static void parse(ParseCommandInfo::TokensRange const & tokens, type & out);
107  static std::string description();
108  static std::string str(type const & value);
109  };
110 
111  template <class T1, class T2>
112  struct ReturnValueTraits< std::pair<T1,T2> >
113  {
114  typedef std::pair<T1,T2> type;
115 
116  static void format(type const & value, std::ostream & os);
117  };
118 
119 #ifdef SENF_CXX11_ENABLED
120 
121  template<typename ...Types>
122  struct ArgumentTraits< std::tuple<Types...> >
123  {
124  typedef std::tuple<Types...> type;
125  static bool const singleToken = false;
126 
127  static void parse(ParseCommandInfo::TokensRange const & tokens, type & out);
128  static std::string description();
129  static std::string str(type const & value);
130  };
131 
132  template<typename ...Types>
133  struct ReturnValueTraits< std::tuple<Types...> >
134  {
135  typedef std::tuple<Types...> type;
136 
137  static void format(type const & value, std::ostream & os);
138  };
139 
140 #endif
141 #endif
142 
143 }}
144 
145 //-/////////////////////////////////////////////////////////////////////////////////////////////////
146 //#include "STLSupport.cci"
147 #include "STLSupport.ct"
148 #include "STLSupport.cti"
149 #endif
150 
151 
152 // Local Variables:
153 // mode: c++
154 // fill-column: 100
155 // comment-column: 40
156 // c-file-style: "senf"
157 // indent-tabs-mode: nil
158 // ispell-local-dictionary: "american"
159 // compile-command: "scons -u test"
160 // End:
STL namespace.
__u32 set
Definition: Config.hh:28
static std::string str(Type const &value)
Stringify value.
static void parse(ParseCommandInfo::TokensRange const &tokens, Type &out)
Parse token range into value.
Traits public header.
static std::string description()
String description of type.
boost::iterator_range< token_iterator > TokensRange
Definition: Parse.hh:378
static bool const singleToken
Definition: Traits.hh:56
void format(Type const &value, std::ostream &os)
Format return value.