diff options
| -rw-r--r-- | slicer/slicer/modelPartsTypes.cpp | 8 | ||||
| -rw-r--r-- | slicer/slicer/modelPartsTypes.h | 5 | ||||
| -rw-r--r-- | slicer/slicer/modelPartsTypes.impl.h | 7 | ||||
| -rw-r--r-- | slicer/tool/parser.cpp | 17 | 
4 files changed, 19 insertions, 18 deletions
diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp index 8ebe127..f674bd0 100644 --- a/slicer/slicer/modelPartsTypes.cpp +++ b/slicer/slicer/modelPartsTypes.cpp @@ -348,6 +348,14 @@ namespace Slicer {  	{  		return type;  	} +	ChildRef +	ModelPartForSequenceBase::GetChildRef(std::string_view name, const HookFilter & flt, bool matchCase) +	{ +		if (!name.empty() && !optionalCaseEq(name, GetElementName(), matchCase)) { +			throw IncorrectElementName(std::string {name}); +		} +		return GetAnonChildRef(flt); +	}  	const ModelPartType ModelPartForSequenceBase::type = ModelPartType::Sequence;  	bool diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 3dac906..28054a8 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -238,6 +238,9 @@ namespace Slicer {  	public:  		bool HasValue() const override;  		ModelPartType GetType() const override; +		ChildRef GetChildRef(std::string_view, const HookFilter &, bool matchCase = true) override; +		virtual const std::string & GetElementName() const = 0; +  		static const ModelPartType type;  	}; @@ -251,7 +254,7 @@ namespace Slicer {  		ChildRef GetAnonChildRef(const HookFilter &) override; -		ChildRef GetChildRef(std::string_view, const HookFilter &, bool matchCase = true) override; +		const std::string & GetElementName() const override;  		const Metadata & GetMetadata() const override; diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index b75ad36..9048cf2 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -572,6 +572,13 @@ namespace Slicer {  	}  	template<typename T> +	const std::string & +	ModelPartForSequence<T>::GetElementName() const +	{ +		return elementName; +	} + +	template<typename T>  	ModelPartPtr  	ModelPartForSequence<T>::elementModelPart(typename T::value_type & e) const  	{ diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp index ef468e8..79ea98a 100644 --- a/slicer/tool/parser.cpp +++ b/slicer/tool/parser.cpp @@ -488,25 +488,8 @@ namespace Slicer {  		fprintbf(cpp, "// Sequence %s\n", s->name());  		externType(s->type()); -		fprintbf(cpp, "template<>\n"); -		fprintbf(cpp, -				"ChildRef ModelPartForSequence< %s >::GetChildRef(std::string_view name, const HookFilter & flt, " -				"bool matchCase)\n{\n", -				s->scoped());  		const IceMetaData md {s->getMetaData()};  		auto ename = md.value("slicer:element:"); -		if (ename) { -			fprintbf(cpp, -					"\tif (!name.empty() && !optionalCaseEq(name, \"%s\", matchCase)) { throw " -					"IncorrectElementName(std::string{name}); }\n", -					*ename); -		} -		else { -			fprintbf(cpp, "\t(void)matchCase;\n"); -			fprintbf(cpp, "\t(void)name;\n"); -		} -		fprintbf(cpp, "\treturn GetAnonChildRef(flt);\n}\n\n"); -  		fprintbf(cpp, "template<> DLL_PUBLIC\n");  		fprintbf(cpp, "const std::string ModelPartForSequence< %s >::elementName(\"%s\");\n\n", s->scoped(),  				ename ? *ename : "element");  | 
