ParsedCommand.cci
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 ParsedCommand inline non-template implementation */
16 
17 #include "ParsedCommand.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::console::detail::ArgumentInfoBase
26 
27 prefix_ senf::console::detail::ArgumentInfoBase::ArgumentInfoBase(std::string const & type_,
28  bool singleToken_)
29  : type (type_), name (), hasDefault (false), singleToken (singleToken_)
30 {}
31 
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33 // senf::console::ParsedCommandOverloadBase
34 
35 prefix_ senf::console::ParsedCommandOverloadBase::ParsedCommandOverloadBase()
36 {}
37 
38 prefix_ senf::console::detail::ArgumentInfoBase &
39 senf::console::ParsedCommandOverloadBase::arg(unsigned n)
40  const
41 {
42  BOOST_ASSERT(n < parameters_.size());
43  return * parameters_[n];
44 }
45 
46 prefix_ void senf::console::ParsedCommandOverloadBase::doc(std::string const & d)
47 {
48  doc_ = d;
49 }
50 
51 //-/////////////////////////////////////////////////////////////////////////////////////////////////
52 // senf::console::ParsedCommandAttributorBase
53 
54 prefix_ senf::console::OverloadedCommandNode &
55 senf::console::ParsedCommandAttributorBase::create(DirectoryNode & dir,
56  std::string const & name)
57  const
58 {
59  OverloadedCommandNode & node (OverloadedCommandNode::insertOverload(dir, name, overload_));
60  if (doc_) node.doc(*doc_);
61  if (shortdoc_) node.shortdoc(*shortdoc_);
62  return node;
63 }
64 
65 prefix_ senf::console::ParsedCommandAttributorBase::
66 ParsedCommandAttributorBase(ParsedCommandOverloadBase::ptr overload, unsigned index)
67  : overload_ (overload), index_ (index)
68 {}
69 
70 prefix_ senf::console::ParsedCommandAttributorBase::
71 ParsedCommandAttributorBase(ParsedCommandAttributorBase const & other, unsigned index)
72  : overload_ (other.overload_), index_ (index), doc_ (other.doc_), shortdoc_ (other.shortdoc_)
73 {}
74 
75 prefix_ senf::console::ParsedCommandOverloadBase &
76 senf::console::ParsedCommandAttributorBase::overload()
77  const
78 {
79  return *overload_;
80 }
81 
82 prefix_ void senf::console::ParsedCommandAttributorBase::argName(std::string const & name)
83 {
84  overload().arg(index_).name = name;
85 }
86 
87 prefix_ void senf::console::ParsedCommandAttributorBase::argDoc(std::string const & doc)
88 {
89  overload().arg(index_).doc = doc;
90 }
91 
92 prefix_ void senf::console::ParsedCommandAttributorBase::typeName(std::string const & doc)
93 {
94  overload().arg(index_).type = doc;
95 }
96 
97 prefix_ void senf::console::ParsedCommandAttributorBase::defaultDoc(std::string const & doc)
98 {
99  overload().arg(index_).defaultDoc = doc;
100 }
101 
102 prefix_ void senf::console::ParsedCommandAttributorBase::overloadDoc(std::string const & doc)
103 {
104  overload().doc(doc);
105 }
106 
107 prefix_ void senf::console::ParsedCommandAttributorBase::nodeDoc(std::string const & doc)
108 {
109  doc_ = doc;
110 }
111 
112 prefix_ void senf::console::ParsedCommandAttributorBase::shortDoc(std::string const & doc)
113 {
114  shortdoc_ = doc;
115 }
116 
117 //-/////////////////////////////////////////////////////////////////////////////////////////////////
118 #undef prefix_
119 
120 
121 // Local Variables:
122 // mode: c++
123 // fill-column: 100
124 // comment-column: 40
125 // c-file-style: "senf"
126 // indent-tabs-mode: nil
127 // ispell-local-dictionary: "american"
128 // compile-command: "scons -u test"
129 // End: