YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
generate_yarpdev.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024-2024 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include "generator.h"
7#include <sstream>
8#include <iomanip>
9#include <algorithm>
10#include <deque>
11
13{
14 std::ostringstream s;
15 s << " yarpdev --device " << this->m_modulename;
16 for (auto param : m_params)
17 {
18 s << " --" << param.getFullParamName();
19 if (!param.defaultValue.empty())
20 {
21 if (param.type == "vector<int>" || param.type == "vector<double>" || param.type == "vector<string>") { s << " \"";}
22 s << " " << param.defaultValue;
23 if (param.type == "vector<int>" || param.type == "vector<double>" || param.type == "vector<string>") { s << " \"";}
24 }
25 else
26 {
27 if (param.required)
28 {
29 s << " <mandatory_value>";
30 }
31 else
32 {
33 s << " <optional_value>";
34 }
35 }
36 }
37 return escapeQuotes(s.str());
38}
39
41{
42 std::ostringstream s;
43 s << " yarpdev --device " << this->m_modulename;
44 for (auto param : m_params)
45 {
46 if (param.required)
47 {
48 s << " --" << param.getFullParamName();
49 if (!param.defaultValue.empty())
50 {
51 if (param.type == "vector<int>" || param.type == "vector<double>" || param.type == "vector<string>") { s << " \""; }
52 s << " " << param.defaultValue;
53 if (param.type == "vector<int>" || param.type == "vector<double>" || param.type == "vector<string>") { s << " \""; }
54 }
55 else
56 {
57 s << " <mandatory_value>";
58 }
59 }
60 }
61 return escapeQuotes(s.str());
62}
63
65{
66 std::ostringstream s;
67 s << " The device can be launched by yarpdev using one of the following examples (with and without all optional parameters):\n";
68 s << " \\code{.unparsed}\n";
70 s << "\n";
71 s << " \\endcode\n";
72 s << "\n";
73 s << " \\code{.unparsed}\n";
75 s << "\n";
76 s << " \\endcode\n";
77 return s.str();
78}
79
81{
82 std::ostringstream s;
84
85 auto param_old = m_sectionGroup.iterator_get();
86 auto param_curr = m_sectionGroup.iterator_get();
87 do
88 {
89 param_old = param_curr;
90 param_curr = m_sectionGroup.iterator_get();
91
92 //case 1
93 if (param_curr->isParameter())
94 {
95 s << param_curr->param.getParamOnly() << " ";
96
97 if (!param_curr->param.defaultValue.empty())
98 {
99 s << param_curr->param.defaultValue << "\n";
100 }
101 else
102 {
103 if (param_curr->param.required)
104 {
105 s << "<mandatory_value>" << "\n";
106 }
107 else
108 {
109 s << "<optional_value>" << "\n";
110 }
111 }
112 }
113 //case 2: hen this is a group of Parameters. Is this the same group?
114 else if (param_curr != param_old)
115 {
116 s << "\n";
117 s << "[ " << param_curr->name << " ]\n";
118 }
119 }
120 while (m_sectionGroup.iterator_next() != nullptr);
121 return s.str();
122}
std::string m_modulename
Definition generator.h:39
std::string generateYarpdevStringAllParams()
std::string generateYarpdevFile()
std::string generateYarpdevDoxyString()
std::deque< Parameter > m_params
Definition generator.h:34
SectionHandler m_sectionGroup
Definition generator.h:35
std::string generateYarpdevStringMandatoryParamsOnly()
SectionNode * iterator_next()
SectionNode * iterator_start()
SectionNode * iterator_get()
std::string escapeQuotes(const std::string &str)
Definition utils.h:56