ParsedCommand.cc
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 #include "ParsedCommand.hh"
18 #include "ParsedCommand.ih"
19 
20 // Custom includes
21 
22 #include "ParsedCommand.mpp"
23 #define prefix_
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 // senf::console::detail::ArgumentInfoBase
28 
29 prefix_ senf::console::detail::ArgumentInfoBase::~ArgumentInfoBase()
30 {}
31 
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33 // senf::console::ParsedCommandOverloadBase
34 
35 prefix_ unsigned senf::console::ParsedCommandOverloadBase::v_numArguments()
36  const
37 {
38  return parameters_.size();
39 }
40 
41 prefix_ void senf::console::ParsedCommandOverloadBase::v_argumentDoc(unsigned index,
42  ArgumentDoc & doc)
43  const
44 {
45  BOOST_ASSERT( index < parameters_.size() );
46  detail::ArgumentInfoBase & arg (*parameters_[index]);
47  doc.name = arg.name.empty()
48  ? (boost::format("arg%d%d") % overloadIndex() % (index+1)).str()
49  : arg.name;
50  doc.type = arg.type;
51  if (arg.hasDefault) {
52  doc.defaultValue = arg.defaultDoc.empty()
53  ? arg.defaultValueStr()
54  : arg.defaultDoc;
55  if (doc.defaultValue.empty())
56  doc.defaultValue = "(empty)";
57  }
58  doc.doc = arg.doc;
59  doc.singleToken = arg.singleToken;
60 }
61 
62 prefix_ std::string senf::console::ParsedCommandOverloadBase::v_doc()
63  const
64 {
65  return doc_;
66 }
67 
68 //-/////////////////////////////////////////////////////////////////////////////////////////////////
69 #undef prefix_
70 #include "ParsedCommand.mpp"
71 
72 
73 // Local Variables:
74 // mode: c++
75 // fill-column: 100
76 // comment-column: 40
77 // c-file-style: "senf"
78 // indent-tabs-mode: nil
79 // ispell-local-dictionary: "american"
80 // compile-command: "scons -u test"
81 // End:
#define prefix_
ParsedCommand public header.
detail::ArgumentInfoBase & arg(unsigned n) const
unsigned overloadIndex() const
Get index of overload in it&#39;s OverloadedCommandNode.
std::string doc() const
Get overload documentation.
void format(Type const &value, std::ostream &os)
Format return value.