STLSupport.ih
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 
14 /** \file
15  \brief STLSupport internal header */
16 
17 #ifndef IH_SENF_senf_Utils_Console_STLSupport_
18 #define IH_SENF_senf_Utils_Console_STLSupport_ 1
19 
20 // Custom includes
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 namespace senf {
25 namespace console {
26 namespace detail {
27 
28  template <class Collection>
29  struct CollectionArgumentTraitsBase
30  {
31  typedef Collection type;
32  static bool const singleToken = false;
33 
34  static std::string description();
35  static std::string str(Collection const & value);
36  };
37 
38  template <class Collection, class Adder>
39  struct CollectionArgumentTraits
40  : detail::CollectionArgumentTraitsBase<Collection>
41  {
42  static void parse(ParseCommandInfo::TokensRange const & tokens, Collection & out);
43  };
44 
45  template <class Collection>
46  struct CollectionReturnValueTraits
47  {
48  typedef Collection type;
49 
50  static void format(Collection const & value, std::ostream & os);
51  };
52 
53  struct PushBackFunctor
54  {
55  template <class Sequence, class ValueType>
56  static void add(Sequence & seq, ValueType const & value);
57  };
58 
59  struct InsertFunctor
60  {
61  template <class Collection, class ValueType>
62  static void add(Collection & seq, ValueType const & value);
63  };
64 
65  template <class Collection>
66  struct MapArgumentTraits
67  {
68  typedef Collection type;
69  static bool const singleToken = false;
70 
71  static void parse(ParseCommandInfo::TokensRange const & tokens, Collection & out);
72  static std::string description();
73  static std::string str(Collection const & value);
74  };
75 
76  template <class Collection>
77  struct MapReturnValueTraits
78  {
79  typedef Collection type;
80 
81  static void format(Collection const & value, std::ostream & os);
82  };
83 
84 #ifdef SENF_CXX11_ENABLED
85 
86  template <typename TupleType, std::size_t Index, std::size_t MaxIndex>
87  struct TupleHelper
88  {
89  static void parse(CheckedArgumentIteratorWrapper & arg, TupleType & out);
90  static void description(std::stringstream & ss);
91  static void format(TupleType const & value, std::ostream & os);
92  };
93 
94  template <typename TupleType, std::size_t MaxIndex>
95  struct TupleHelper<TupleType, MaxIndex, MaxIndex>
96  {
97  static void parse(CheckedArgumentIteratorWrapper & arg, TupleType & out);
98  static void description(std::stringstream & ss);
99  static void format(TupleType const & value, std::ostream & os);
100  };
101 
102 #endif
103 
104 }}}
105 
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
107 #endif
108 
109 
110 // Local Variables:
111 // mode: c++
112 // fill-column: 100
113 // comment-column: 40
114 // c-file-style: "senf"
115 // indent-tabs-mode: nil
116 // ispell-local-dictionary: "american"
117 // compile-command: "scons -u test"
118 // End: