Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix c++ stringification of enums #445

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aas_core_codegen/cpp/stringification/_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _generate_model_type_from_string_implementation(
{I}if (it == {map_name}.end()) {{
{II}throw std::invalid_argument(
{III}common::Concat(
{IIII}"Unexpected model type literal: ",
{IIII}"Unexpected {enum_name} literal: ",
{IIII}text
{III})
{II});
Expand Down Expand Up @@ -364,7 +364,7 @@ def _generate_enum_from_string_implementation(
{I}if (it == {map_name}.end()) {{
{II}throw std::invalid_argument(
{III}common::Concat(
{IIII}"Unexpected model type literal: ",
{IIII}"Unexpected {enum_name} literal: ",
{IIII}text
{III})
{II});
Expand Down
8 changes: 4 additions & 4 deletions aas_core_codegen/cpp/wstringification/_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _generate_model_type_from_wstring_implementation(
{II}throw std::invalid_argument(
{III}common::WstringToUtf8(
{IIII}common::Concat(
{IIIII}L"Unexpected model type literal: ",
{IIIII}L"Unexpected {enum_name} literal: ",
{IIIII}text
{IIII})
{III})
Expand Down Expand Up @@ -214,7 +214,7 @@ def _generate_model_type_to_wstring_implementation(
default:
{I}throw std::invalid_argument(
{II}common::Concat(
{III}"Unexpected model type: ",
{III}"Unexpected {enum_name} literal: ",
{III}std::to_string(
{IIII}static_cast<std::uint32_t>({model_type_arg})
{III})
Expand Down Expand Up @@ -365,7 +365,7 @@ def _generate_enum_from_wstring_implementation(
{II}throw std::invalid_argument(
{III}common::WstringToUtf8(
{IIII}common::Concat(
{IIIII}L"Unexpected model type literal: ",
{IIIII}L"Unexpected {enum_name} literal: ",
{IIIII}text
{IIII})
{III})
Expand Down Expand Up @@ -432,7 +432,7 @@ def _generate_enum_to_wstring_implementation(
default:
{I}throw std::invalid_argument(
{II}common::Concat(
{III}"Unexpected literal: ",
{III}"Unexpected {enum_name} literal: ",
{III}std::to_string(
{IIII}static_cast<std::uint32_t>({literal_arg})
{III})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ types::ModelType MustModelTypeFromString(
if (it == kModelTypeFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected ModelType literal: ",
text
)
);
Expand Down Expand Up @@ -327,7 +327,7 @@ types::ModellingKind MustModellingKindFromString(
if (it == kModellingKindFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected ModellingKind literal: ",
text
)
);
Expand Down Expand Up @@ -396,7 +396,7 @@ types::QualifierKind MustQualifierKindFromString(
if (it == kQualifierKindFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected QualifierKind literal: ",
text
)
);
Expand Down Expand Up @@ -467,7 +467,7 @@ types::AssetKind MustAssetKindFromString(
if (it == kAssetKindFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected AssetKind literal: ",
text
)
);
Expand Down Expand Up @@ -594,7 +594,7 @@ types::AasSubmodelElements MustAasSubmodelElementsFromString(
if (it == kAasSubmodelElementsFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected AasSubmodelElements literal: ",
text
)
);
Expand Down Expand Up @@ -689,7 +689,7 @@ types::EntityType MustEntityTypeFromString(
if (it == kEntityTypeFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected EntityType literal: ",
text
)
);
Expand Down Expand Up @@ -754,7 +754,7 @@ types::Direction MustDirectionFromString(
if (it == kDirectionFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected Direction literal: ",
text
)
);
Expand Down Expand Up @@ -819,7 +819,7 @@ types::StateOfEvent MustStateOfEventFromString(
if (it == kStateOfEventFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected StateOfEvent literal: ",
text
)
);
Expand Down Expand Up @@ -884,7 +884,7 @@ types::ReferenceTypes MustReferenceTypesFromString(
if (it == kReferenceTypesFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected ReferenceTypes literal: ",
text
)
);
Expand Down Expand Up @@ -1037,7 +1037,7 @@ types::KeyTypes MustKeyTypesFromString(
if (it == kKeyTypesFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected KeyTypes literal: ",
text
)
);
Expand Down Expand Up @@ -1258,7 +1258,7 @@ types::DataTypeDefXsd MustDataTypeDefXsdFromString(
if (it == kDataTypeDefXsdFromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected DataTypeDefXsd literal: ",
text
)
);
Expand Down Expand Up @@ -1447,7 +1447,7 @@ types::DataTypeIec61360 MustDataTypeIec61360FromString(
if (it == kDataTypeIec61360FromStringMap.end()) {
throw std::invalid_argument(
common::Concat(
"Unexpected model type literal: ",
"Unexpected DataTypeIec61360 literal: ",
text
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ types::ModelType MustModelTypeFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected ModelType literal: ",
text
)
)
Expand Down Expand Up @@ -283,7 +283,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected model type: ",
"Unexpected ModelType literal: ",
std::to_string(
static_cast<std::uint32_t>(model_type)
)
Expand Down Expand Up @@ -328,7 +328,7 @@ types::ModellingKind MustModellingKindFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected ModellingKind literal: ",
text
)
)
Expand All @@ -348,7 +348,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected ModellingKind literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -397,7 +397,7 @@ types::QualifierKind MustQualifierKindFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected QualifierKind literal: ",
text
)
)
Expand All @@ -419,7 +419,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected QualifierKind literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -468,7 +468,7 @@ types::AssetKind MustAssetKindFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected AssetKind literal: ",
text
)
)
Expand All @@ -490,7 +490,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected AssetKind literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -595,7 +595,7 @@ types::AasSubmodelElements MustAasSubmodelElementsFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected AasSubmodelElements literal: ",
text
)
)
Expand Down Expand Up @@ -645,7 +645,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected AasSubmodelElements literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -690,7 +690,7 @@ types::EntityType MustEntityTypeFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected EntityType literal: ",
text
)
)
Expand All @@ -710,7 +710,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected EntityType literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -755,7 +755,7 @@ types::Direction MustDirectionFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected Direction literal: ",
text
)
)
Expand All @@ -775,7 +775,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected Direction literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -820,7 +820,7 @@ types::StateOfEvent MustStateOfEventFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected StateOfEvent literal: ",
text
)
)
Expand All @@ -840,7 +840,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected StateOfEvent literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -885,7 +885,7 @@ types::ReferenceTypes MustReferenceTypesFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected ReferenceTypes literal: ",
text
)
)
Expand All @@ -905,7 +905,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected ReferenceTypes literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -1038,7 +1038,7 @@ types::KeyTypes MustKeyTypesFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected KeyTypes literal: ",
text
)
)
Expand Down Expand Up @@ -1102,7 +1102,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected KeyTypes literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -1259,7 +1259,7 @@ types::DataTypeDefXsd MustDataTypeDefXsdFromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected DataTypeDefXsd literal: ",
text
)
)
Expand Down Expand Up @@ -1335,7 +1335,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected DataTypeDefXsd literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down Expand Up @@ -1448,7 +1448,7 @@ types::DataTypeIec61360 MustDataTypeIec61360FromWstring(
throw std::invalid_argument(
common::WstringToUtf8(
common::Concat(
L"Unexpected model type literal: ",
L"Unexpected DataTypeIec61360 literal: ",
text
)
)
Expand Down Expand Up @@ -1502,7 +1502,7 @@ std::wstring to_wstring(
default:
throw std::invalid_argument(
common::Concat(
"Unexpected literal: ",
"Unexpected DataTypeIec61360 literal: ",
std::to_string(
static_cast<std::uint32_t>(literal)
)
Expand Down
Loading