33 #include <libxml/parser.h> 44 xmlDocPtr pDoc{xmlNewDoc(BAD_CAST
"1.0")};
46 xmlNodePtr pManifest{xmlNewNode(NULL,BAD_CAST
"manifest")};
48 xmlNodePtr pPlugin{xmlNewChild(pManifest,NULL,BAD_CAST
"plugin",NULL)};
50 xmlNewProp(pPlugin, BAD_CAST
"name", BAD_CAST sName.c_str());
55 xmlNodePtr pConfiguration{xmlNewChild(pPlugin,NULL,BAD_CAST
"configuration",NULL)};
57 for(
const auto & entry : manifest)
59 xmlNodePtr pParam{xmlNewChild(pConfiguration,NULL,BAD_CAST
"parameter",NULL)};
61 xmlNewProp(pParam, BAD_CAST
"name", BAD_CAST entry.getName().c_str());
62 xmlNewProp(pParam, BAD_CAST
"default", BAD_CAST (entry.hasDefault() ?
"yes" :
"no"));
63 xmlNewProp(pParam, BAD_CAST
"required", BAD_CAST (entry.isRequired() ?
"yes" :
"no"));
64 xmlNewProp(pParam, BAD_CAST
"modifiable", BAD_CAST (entry.isModifiable() ?
"yes" :
"no"));
68 std::string sMinValue;
69 std::string sMaxValue;
72 std::vector<std::string> values;
74 const auto & anyValues = entry.getValues();
76 switch(entry.getType())
80 sMinValue = std::to_string(entry.getMinValue().asINT64());
81 sMaxValue = std::to_string(entry.getMaxValue().asINT64());
83 std::transform(anyValues.begin(),
85 std::back_inserter(values),[](
const Any & any)->std::string
87 return std::to_string(any.asINT64());
94 sMinValue = std::to_string(entry.getMinValue().asUINT64());
95 sMaxValue = std::to_string(entry.getMaxValue().asUINT64());
97 std::transform(anyValues.begin(),
99 std::back_inserter(values),[](
const Any & any)->std::string
101 return std::to_string(any.asUINT64());
107 sMinValue = std::to_string(entry.getMinValue().asINT32());
108 sMaxValue = std::to_string(entry.getMaxValue().asINT32());
110 std::transform(anyValues.begin(),
112 std::back_inserter(values),[](
const Any & any)->std::string
114 return std::to_string(any.asINT32());
120 sMinValue = std::to_string(entry.getMinValue().asUINT32());
121 sMaxValue = std::to_string(entry.getMaxValue().asUINT32());
123 std::transform(anyValues.begin(),
125 std::back_inserter(values),[](
const Any & any)->std::string
127 return std::to_string(any.asUINT32());
134 sMinValue = std::to_string(entry.getMinValue().asINT16());
135 sMaxValue = std::to_string(entry.getMaxValue().asINT16());
137 std::transform(anyValues.begin(),
139 std::back_inserter(values),[](
const Any & any)->std::string
141 return std::to_string(any.asINT16());
148 sMinValue = std::to_string(entry.getMinValue().asUINT16());
149 sMaxValue = std::to_string(entry.getMaxValue().asUINT16());
151 std::transform(anyValues.begin(),
153 std::back_inserter(values),[](
const Any & any)->std::string
155 return std::to_string(any.asUINT16());
162 sMinValue = std::to_string(entry.getMinValue().asINT8());
163 sMaxValue = std::to_string(entry.getMaxValue().asINT8());
165 std::transform(anyValues.begin(),
167 std::back_inserter(values),[](
const Any & any)->std::string
169 return std::to_string(any.asINT8());
175 sMinValue = std::to_string(entry.getMinValue().asUINT8());
176 sMaxValue = std::to_string(entry.getMaxValue().asUINT8());
178 std::transform(anyValues.begin(),
180 std::back_inserter(values),[](
const Any & any)->std::string
182 return std::to_string(any.asUINT8());
188 sMinValue = std::to_string(entry.getMinValue().asFloat());
189 sMaxValue = std::to_string(entry.getMaxValue().asFloat());
191 std::transform(anyValues.begin(),
193 std::back_inserter(values),[](
const Any & any)->std::string
195 return std::to_string(any.asFloat());
201 sMinValue = std::to_string(entry.getMinValue().asDouble());
202 sMaxValue = std::to_string(entry.getMaxValue().asDouble());
204 std::transform(anyValues.begin(),
206 std::back_inserter(values),[](
const Any & any)->std::string
208 return std::to_string(any.asDouble());
216 std::transform(anyValues.begin(),
218 std::back_inserter(values),[](
const Any & any)->std::string
220 return any.asINETAddr().str();
230 std::transform(anyValues.begin(),
232 std::back_inserter(values),[](
const Any & any)->std::string
234 return any.asBool() ?
"true" :
"false";
243 std::transform(anyValues.begin(),
245 std::back_inserter(values),[](
const Any & any)->std::string
247 return any.asString();
252 xmlNodePtr pNumericOrNonNumeric{};
256 pNumericOrNonNumeric = xmlNewChild(pParam,NULL,BAD_CAST
"numeric",NULL);
257 xmlNewProp(pNumericOrNonNumeric, BAD_CAST
"minValue", BAD_CAST sMinValue.c_str());
258 xmlNewProp(pNumericOrNonNumeric,BAD_CAST
"maxValue", BAD_CAST sMaxValue.c_str());
262 pNumericOrNonNumeric = xmlNewChild(pParam,NULL,BAD_CAST
"nonnumeric",NULL);
265 const auto & sPattern = entry.getRegexPattern();
267 xmlNewProp(pNumericOrNonNumeric, BAD_CAST
"type", BAD_CAST sType.c_str());
269 xmlNodePtr pValues = xmlNewChild(pNumericOrNonNumeric, NULL, BAD_CAST
"values", NULL);
270 xmlNewProp(pValues,BAD_CAST
"minOccurs", BAD_CAST std::to_string(entry.getMinOccurs()).c_str());
271 xmlNewProp(pValues,BAD_CAST
"maxOccurs", BAD_CAST std::to_string(entry.getMaxOccurs()).c_str());
274 std::for_each(values.begin(),
276 [pValues](
const std::string & s)
278 xmlNewChild(pValues, NULL, BAD_CAST
"value", BAD_CAST s.c_str());
282 if(!sPattern.empty())
284 xmlNodePtr pRegex = xmlNewChild(pNumericOrNonNumeric, NULL, BAD_CAST
"regex", NULL);
285 xmlNodePtr pCDATA = xmlNewCDataBlock(pDoc, BAD_CAST sPattern.c_str(), sPattern.size());
286 xmlAddChild(pRegex,pCDATA);
289 if(!entry.getUsage().empty())
291 xmlNewChild(pNumericOrNonNumeric, NULL, BAD_CAST
"description", BAD_CAST entry.getUsage().c_str());
296 xmlNodePtr pStatistic{xmlNewChild(pPlugin,NULL,BAD_CAST
"statistics",NULL)};
300 xmlNodePtr pStat{xmlNewChild(pStatistic,NULL,BAD_CAST
"element",NULL)};
302 xmlNewProp(pStat, BAD_CAST
"name", BAD_CAST entry.getName().c_str());
304 xmlNewProp(pStat, BAD_CAST
"type", BAD_CAST
anyTypeAsString(entry.getType()).c_str());
306 xmlNewProp(pStat, BAD_CAST
"clearable", BAD_CAST (entry.isClearable() ?
"yes" :
"no"));
308 if(!entry.getDescription().empty())
310 xmlNewChild(pStat, NULL, BAD_CAST
"description", BAD_CAST entry.getDescription().c_str());
314 xmlNodePtr pStatisticTables{xmlNewChild(pPlugin,NULL,BAD_CAST
"statistictables",NULL)};
318 xmlNodePtr pTable{xmlNewChild(pStatisticTables,NULL,BAD_CAST
"table",NULL)};
320 xmlNewProp(pTable, BAD_CAST
"name", BAD_CAST entry.getName().c_str());
322 xmlNewProp(pTable, BAD_CAST
"clearable", BAD_CAST (entry.isClearable() ?
"yes" :
"no"));
324 if(!entry.getDescription().empty())
326 xmlNewChild(pTable, NULL, BAD_CAST
"description", BAD_CAST entry.getDescription().c_str());
330 xmlDocSetRootElement(pDoc,pManifest);
336 xmlDocDumpFormatMemory(pDoc, &xmlbuff, &buffersize, 1);
338 std::string sManifest(reinterpret_cast<char *>(xmlbuff),buffersize);
static StatisticTableManifest getTableManifest(BuildId buildId)
std::string manifest(BuildId buildId, const std::string &sName)
std::string anyTypeAsString(const Any::Type &type)
static ConfigurationManifest getConfigurationManifest(BuildId buildId)
static StatisticManifest getStatisticManifest(BuildId buildId)
The Any class can contain an instance of one of any type in its support type set. ...