26 #include <SimoxUtility/algorithm/string/string_tools.h>
27 #include <boost/format.hpp>
33 name(name),
value(-1), hasValue(false)
48 writer->body.line(name +
" = " +
std::to_string(value) + (addComma ?
"," :
""));
50 return writer->body.line(name + (addComma ?
"," :
""));
55 namespaces(namespaces)
59 CppEnum::CppEnum(
const std::vector<std::string> namespaces,
const std::string& name,
const std::vector<CppEnumFieldPtr>& fields) :
61 namespaces(namespaces), fields(fields)
68 CppWriterPtr w = std::dynamic_pointer_cast<CppWriter>(writer);
84 for (
const auto& ns : namespaces)
86 writer->body.startBlock(std::string(
"namespace ") + ns);
91 std::string delimiters =
"\n";
93 writer->body.line(
"/**");
95 for (
auto& line : doclines)
97 writer->body.line(
" * " + line);
100 writer->body.line(
" */");
103 writer->body.line(
"enum class " +
name);
104 writer->body.startBlock();
105 for (
unsigned int i = 0; i < fields.size(); ++i)
108 f->writeCpp(writer, (i != (fields.size()-1)));
110 writer->body.endBlock(
"; // enum class " +
name);
112 for (std::vector<std::string>::reverse_iterator it = namespaces.rbegin(); it != namespaces.rend(); it++)
114 writer->body.endBlockComment(std::string(
"namespace ") + *it);