diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-09-24 14:38:38 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-09-24 14:38:38 +0100 |
commit | 463dc58bead7bfe8cf8d5b95ccbebcf8a097f42f (patch) | |
tree | b0d5e3f666155d1307f39b02c9be2d0661ed931e | |
parent | Merge branch 'remove-void-star' (diff) | |
download | slicer-463dc58bead7bfe8cf8d5b95ccbebcf8a097f42f.tar.bz2 slicer-463dc58bead7bfe8cf8d5b95ccbebcf8a097f42f.tar.xz slicer-463dc58bead7bfe8cf8d5b95ccbebcf8a097f42f.zip |
Single thrower of IncorrectElementName
-rw-r--r-- | slicer/slicer/modelPartsTypes.cpp | 6 | ||||
-rw-r--r-- | slicer/slicer/modelPartsTypes.h | 3 | ||||
-rw-r--r-- | slicer/slicer/modelPartsTypes.impl.h | 4 |
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; |