diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-11-01 15:47:15 +0000 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-11-01 15:47:15 +0000 | 
| commit | 327353ee54b5b58e6d757fa8819a8533ef8fd0eb (patch) | |
| tree | 9b314c2a345778ea96a01cf9b5bfab181c224c48 | |
| parent | Wrap boost::posix_time string conversions (diff) | |
| download | slicer-327353ee54b5b58e6d757fa8819a8533ef8fd0eb.tar.bz2 slicer-327353ee54b5b58e6d757fa8819a8533ef8fd0eb.tar.xz slicer-327353ee54b5b58e6d757fa8819a8533ef8fd0eb.zip | |
Wrap throwing NoConversionFound for cropping up too often
| -rw-r--r-- | slicer/slicer/modelPartsTypes.cpp | 5 | ||||
| -rw-r--r-- | slicer/slicer/modelPartsTypes.h | 1 | ||||
| -rw-r--r-- | slicer/tool/parser.cpp | 4 | 
3 files changed, 8 insertions, 2 deletions
| diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp index 8cc8656..8ebe127 100644 --- a/slicer/slicer/modelPartsTypes.cpp +++ b/slicer/slicer/modelPartsTypes.cpp @@ -199,6 +199,11 @@ namespace Slicer {  	{  		return type;  	} +	void +	ModelPartForConvertedBase::conversion_fail(std::string_view typeName) +	{ +		throw NoConversionFound(std::string {typeName}); +	}  	const ModelPartType ModelPartForConvertedBase::type = ModelPartType::Simple;  	ModelPartType diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 9cc8ac9..ecc965a 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -58,6 +58,7 @@ namespace Slicer {  		static const ModelPartType type;  	protected: +		[[noreturn]] void conversion_fail(std::string_view typeName);  		template<typename ET, typename MT, typename Conv>  		inline static bool tryConvertFrom(ValueSource & vsp, MT * model, const Conv & conv);  		template<typename ET, typename MT> inline static bool tryConvertFrom(ValueSource & vsp, MT * model); diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp index e1cc988..73ace40 100644 --- a/slicer/tool/parser.cpp +++ b/slicer/tool/parser.cpp @@ -163,7 +163,7 @@ namespace Slicer {  						Slice::typeToString(type));  			}  			// Failed to convert -			fprintbf(cpp, "\tthrow NoConversionFound(\"%s\");\n", Slice::typeToString(type)); +			fprintbf(cpp, "\tconversion_fail(\"%s\");\n", Slice::typeToString(type));  			fprintbf(cpp, "}\n\n");  			fprintbf(cpp, "template<> DLL_PUBLIC\nbool\n"); @@ -188,7 +188,7 @@ namespace Slicer {  						Slice::typeToString(type));  			}  			// Failed to convert -			fprintbf(cpp, "\tthrow NoConversionFound(\"%s\");\n", Slice::typeToString(type)); +			fprintbf(cpp, "\tconversion_fail(\"%s\");\n", Slice::typeToString(type));  			fprintbf(cpp, "}\n\n");  		}  	} | 
