summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-09-24 14:38:38 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-09-24 14:38:38 +0100
commit463dc58bead7bfe8cf8d5b95ccbebcf8a097f42f (patch)
treeb0d5e3f666155d1307f39b02c9be2d0661ed931e
parentMerge branch 'remove-void-star' (diff)
downloadslicer-463dc58bead7bfe8cf8d5b95ccbebcf8a097f42f.tar.bz2
slicer-463dc58bead7bfe8cf8d5b95ccbebcf8a097f42f.tar.xz
slicer-463dc58bead7bfe8cf8d5b95ccbebcf8a097f42f.zip
Single thrower of IncorrectElementName
-rw-r--r--slicer/slicer/modelPartsTypes.cpp6
-rw-r--r--slicer/slicer/modelPartsTypes.h3
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h4
3 files changed, 11 insertions, 2 deletions
diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp
index ffaec04..04fc859 100644
--- a/slicer/slicer/modelPartsTypes.cpp
+++ b/slicer/slicer/modelPartsTypes.cpp
@@ -357,6 +357,12 @@ namespace Slicer {
const ModelPartType ModelPartForDictionaryBase::type = ModelPartType::Dictionary;
+ void
+ ModelPartForDictionaryBase::throwIncorrectElementName(const std::string_view name)
+ {
+ throw IncorrectElementName(std::string {name});
+ }
+
// Streams
ModelPartType
ModelPartForStreamBase::GetType() const
diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h
index f581c49..c81e014 100644
--- a/slicer/slicer/modelPartsTypes.h
+++ b/slicer/slicer/modelPartsTypes.h
@@ -297,6 +297,9 @@ namespace Slicer {
[[nodiscard]] bool HasValue() const override;
[[nodiscard]] ModelPartType GetType() const override;
static const ModelPartType type;
+
+ protected:
+ [[noreturn]] static void throwIncorrectElementName(const std::string_view);
};
template<typename T> class ModelPartForDictionary : public ModelPartForDictionaryBase, protected ModelPartModel<T> {
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index 60f221d..692437e 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -681,8 +681,8 @@ namespace Slicer {
const SubPartHandler & ch, std::string_view name, const HookFilter &, MatchCase matchCase)
{
BOOST_ASSERT(this->Model);
- if (!optionalCaseEq(name, pairName, matchCase == MatchCase::Yes)) {
- throw IncorrectElementName(std::string {name});
+ if (!optionalCaseEq(name, pairName, matchCase == MatchCase::Yes)) [[unlikely]] {
+ ModelPartForDictionaryBase::throwIncorrectElementName(name);
}
ch(ModelPartForDictionaryElementInserter<T>(this->Model), emptyMetadata);
return true;