Skip to content
Snippets Groups Projects
Commit 6bfa2766 authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

fixed error in assignment operator for int enums

parent a25a0a58
No related branches found
No related tags found
1 merge request!171Periodic merge of armem/dev into master
...@@ -49,7 +49,7 @@ namespace armarx::aron::cppserializer::serializer ...@@ -49,7 +49,7 @@ namespace armarx::aron::cppserializer::serializer
name_to_enum << "{" << std::endl; name_to_enum << "{" << std::endl;
enum_to_value << "{" << std::endl; enum_to_value << "{" << std::endl;
value_to_enum << "{" << std::endl; value_to_enum << "{" << std::endl;
for (const auto& [key, value] : typenavigator->getAcceptedValues()) for (const auto& [key, value] : typenavigator->getAcceptedValueMap())
{ {
std::string enumKeyWithNamespace = std::string(IMPL_ENUM) + "::" + key; std::string enumKeyWithNamespace = std::string(IMPL_ENUM) + "::" + key;
fields.push_back(std::make_shared<CppField>("const static " + std::string(IMPL_ENUM), key + " = " + enumKeyWithNamespace)); fields.push_back(std::make_shared<CppField>("const static " + std::string(IMPL_ENUM), key + " = " + enumKeyWithNamespace));
...@@ -141,7 +141,7 @@ namespace armarx::aron::cppserializer::serializer ...@@ -141,7 +141,7 @@ namespace armarx::aron::cppserializer::serializer
CppEnumPtr IntEnumClassSerializer::toInnerEnumDefinition() const CppEnumPtr IntEnumClassSerializer::toInnerEnumDefinition() const
{ {
CppEnumPtr e = std::make_shared<CppEnum>(std::string(IMPL_ENUM), "The internal enum definition of the enum of this autogenerated class."); CppEnumPtr e = std::make_shared<CppEnum>(std::string(IMPL_ENUM), "The internal enum definition of the enum of this autogenerated class.");
for (const auto& [key, value] : typenavigator->getAcceptedValues()) for (const auto& [key, value] : typenavigator->getAcceptedValueMap())
{ {
e->addField(std::make_shared<CppEnumField>(key)); e->addField(std::make_shared<CppEnumField>(key));
} }
...@@ -170,6 +170,7 @@ namespace armarx::aron::cppserializer::serializer ...@@ -170,6 +170,7 @@ namespace armarx::aron::cppserializer::serializer
CppMethodPtr m = CppMethodPtr(new CppMethod(getFullCppTypename() + "& operator=(const " + getFullCppTypename() + "& c)", doc.str())); CppMethodPtr m = CppMethodPtr(new CppMethod(getFullCppTypename() + "& operator=(const " + getFullCppTypename() + "& c)", doc.str()));
CppBlockPtr b = std::make_shared<CppBlock>(); CppBlockPtr b = std::make_shared<CppBlock>();
b->addLine("value = c.value;"); b->addLine("value = c.value;");
b->addLine("return *this");
m->setBlock(b); m->setBlock(b);
return m; return m;
} }
...@@ -183,6 +184,7 @@ namespace armarx::aron::cppserializer::serializer ...@@ -183,6 +184,7 @@ namespace armarx::aron::cppserializer::serializer
CppMethodPtr m = CppMethodPtr(new CppMethod(getFullCppTypename() + "& operator=(" + std::string(IMPL_ENUM) + " v)", doc.str())); CppMethodPtr m = CppMethodPtr(new CppMethod(getFullCppTypename() + "& operator=(" + std::string(IMPL_ENUM) + " v)", doc.str()));
CppBlockPtr b = std::make_shared<CppBlock>(); CppBlockPtr b = std::make_shared<CppBlock>();
b->addLine("value = v;"); b->addLine("value = v;");
b->addLine("return *this");
m->setBlock(b); m->setBlock(b);
return m; return m;
} }
...@@ -193,7 +195,7 @@ namespace armarx::aron::cppserializer::serializer ...@@ -193,7 +195,7 @@ namespace armarx::aron::cppserializer::serializer
doc << "@brief operator=() - Assignment operator for the internally defined enum \n"; doc << "@brief operator=() - Assignment operator for the internally defined enum \n";
doc << "@return - nothing"; doc << "@return - nothing";
CppMethodPtr m = CppMethodPtr(new CppMethod("void operator=(int v)", doc.str())); CppMethodPtr m = CppMethodPtr(new CppMethod(getFullCppTypename() + "& operator=(int v)", doc.str()));
CppBlockPtr b = std::make_shared<CppBlock>(); CppBlockPtr b = std::make_shared<CppBlock>();
b->addLine("if (auto it = ValueToEnumMap.find(v); it == ValueToEnumMap.end())"); b->addLine("if (auto it = ValueToEnumMap.find(v); it == ValueToEnumMap.end())");
CppBlockPtr b2 = std::make_shared<CppBlock>(); CppBlockPtr b2 = std::make_shared<CppBlock>();
...@@ -203,6 +205,7 @@ namespace armarx::aron::cppserializer::serializer ...@@ -203,6 +205,7 @@ namespace armarx::aron::cppserializer::serializer
CppBlockPtr b3 = std::make_shared<CppBlock>(); CppBlockPtr b3 = std::make_shared<CppBlock>();
b3->addLine("value = it->second;"); b3->addLine("value = it->second;");
b->addBlock(b3); b->addBlock(b3);
b->addLine("return *this");
m->setBlock(b); m->setBlock(b);
return m; return m;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment