summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-09-04 18:01:14 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-09-04 18:01:14 +0100
commit9163348c049c67b14b39a0218ba7762ded370ca0 (patch)
treee2d997639b1a453f1acf9a74f25087d825cfd65d
parentSimplify className and typeName setup with string_views (diff)
downloadslicer-9163348c049c67b14b39a0218ba7762ded370ca0.tar.bz2
slicer-9163348c049c67b14b39a0218ba7762ded370ca0.tar.xz
slicer-9163348c049c67b14b39a0218ba7762ded370ca0.zip
Simplify defining ModelPartForRoots for base types
-rw-r--r--slicer/slicer/modelPartsTypes.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp
index dcfd338..a65d2e7 100644
--- a/slicer/slicer/modelPartsTypes.cpp
+++ b/slicer/slicer/modelPartsTypes.cpp
@@ -74,32 +74,20 @@ namespace Slicer {
return name;
}
- template<> const std::string Slicer::ModelPartForRoot<std::string>::rootName = "String";
- template<> const std::string Slicer::ModelPartForRoot<bool>::rootName = "Boolean";
- template<> const std::string Slicer::ModelPartForRoot<Ice::Float>::rootName = "Float";
- template<> const std::string Slicer::ModelPartForRoot<Ice::Double>::rootName = "Double";
- template<> const std::string Slicer::ModelPartForRoot<Ice::Byte>::rootName = "Byte";
- template<> const std::string Slicer::ModelPartForRoot<Ice::Short>::rootName = "Short";
- template<> const std::string Slicer::ModelPartForRoot<Ice::Int>::rootName = "Int";
- template<> const std::string Slicer::ModelPartForRoot<Ice::Long>::rootName = "Long";
-
- template<> const std::string Slicer::ModelPartForRoot<Ice::optional<std::string>>::rootName = "OptionalString";
- template<> const std::string Slicer::ModelPartForRoot<Ice::optional<bool>>::rootName = "OptionalBoolean";
- template<> const std::string Slicer::ModelPartForRoot<Ice::optional<Ice::Float>>::rootName = "OptionalFloat";
- template<> const std::string Slicer::ModelPartForRoot<Ice::optional<Ice::Double>>::rootName = "OptionalDouble";
- template<> const std::string Slicer::ModelPartForRoot<Ice::optional<Ice::Byte>>::rootName = "OptionalByte";
- template<> const std::string Slicer::ModelPartForRoot<Ice::optional<Ice::Short>>::rootName = "OptionalShort";
- template<> const std::string Slicer::ModelPartForRoot<Ice::optional<Ice::Int>>::rootName = "OptionalInt";
- template<> const std::string Slicer::ModelPartForRoot<Ice::optional<Ice::Long>>::rootName = "OptionalLong";
-
- MODELPARTFOR(std::string, ModelPartForSimple)
- MODELPARTFOR(bool, ModelPartForSimple)
- MODELPARTFOR(Ice::Float, ModelPartForSimple)
- MODELPARTFOR(Ice::Double, ModelPartForSimple)
- MODELPARTFOR(Ice::Byte, ModelPartForSimple)
- MODELPARTFOR(Ice::Short, ModelPartForSimple)
- MODELPARTFOR(Ice::Int, ModelPartForSimple)
- MODELPARTFOR(Ice::Long, ModelPartForSimple)
+#define Roots(Type, Name) \
+ template<> constinit const std::string Slicer::ModelPartForRoot<Type>::rootName {#Name}; \
+ template<> constinit const std::string Slicer::ModelPartForRoot<Ice::optional<Type>>::rootName {"Optional" #Name}; \
+ MODELPARTFOR(Type, ModelPartForSimple)
+
+ Roots(std::string, String);
+ Roots(bool, Boolean);
+ Roots(Ice::Float, Float);
+ Roots(Ice::Double, Double);
+ Roots(Ice::Byte, Byte);
+ Roots(Ice::Short, Short);
+ Roots(Ice::Int, Int);
+ Roots(Ice::Long, Long);
+#undef RootNames
bool
optionalCaseEq(std::string_view a, std::string_view b, bool matchCase)