From 06c9fef83dbbb1363bd69f48b5801d4e7365c389 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 2 Jan 2017 19:57:46 +0000 Subject: Use compile time formatter instead of boost::format --- slicer/db/sqlCommon.cpp | 6 +++--- slicer/slicer/slicer.cpp | 26 +++++++++++++------------- slicer/xml/serializer.cpp | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/slicer/db/sqlCommon.cpp b/slicer/db/sqlCommon.cpp index 645c10f..d484967 100644 --- a/slicer/db/sqlCommon.cpp +++ b/slicer/db/sqlCommon.cpp @@ -1,5 +1,5 @@ #include -#include +#include namespace Slicer { void TooManyRowsReturned::ice_print(std::ostream & s) const @@ -17,10 +17,10 @@ namespace Slicer { s << "No rows found"; } + AdHocFormatter(UnsuitableIdFieldTypeMsg, "Unsuitable id field type [%?]"); void UnsuitableIdFieldType::ice_print(std::ostream & s) const { - static boost::format f("Unsuitable id field type [%s]"); - s << f % type; + UnsuitableIdFieldTypeMsg::write(s, type); } } diff --git a/slicer/slicer/slicer.cpp b/slicer/slicer/slicer.cpp index ee2a95f..dbda326 100644 --- a/slicer/slicer/slicer.cpp +++ b/slicer/slicer/slicer.cpp @@ -1,6 +1,6 @@ #include "slicer.h" #include -#include +#include namespace Slicer { Slicer::MemberChildRef::MemberChildRef(Slicer::ModelPartPtr mp, const Slicer::Metadata & md) : @@ -38,32 +38,32 @@ namespace Slicer { return emptyMetadata; } + AdHocFormatter(InvalidEnumerationSymbolMsg, "Invalid enumeration symbol [%?] for type [%?]"); void InvalidEnumerationSymbol::ice_print(std::ostream & s) const { - static boost::format f("Invalid enumeration symbol [%s] for type [%s]"); - s << f % symbol % type; + InvalidEnumerationSymbolMsg::write(s, symbol, type); } + AdHocFormatter(InvalidEnumerationValueMsg, "Invalid enumeration symbol [%?] for type [%?]"); void InvalidEnumerationValue::ice_print(std::ostream & s) const { - static boost::format f("Invalid enumeration symbol [%d] for type [%s]"); - s << f % value % type; + InvalidEnumerationValueMsg::write(s, value, type); } + AdHocFormatter(UnknownTypeMsg, "Unknown type [%?]"); void UnknownType::ice_print(std::ostream & s) const { - static boost::format f("Unknown type [%s]"); - s << f % type; + UnknownTypeMsg::write(s, type); } + AdHocFormatter(NoConversionFoundMsg, "No conversion found for type [%?]"); void NoConversionFound::ice_print(std::ostream & s) const { - static boost::format f("No conversion found for type [%s]"); - s << f % type; + NoConversionFoundMsg::write(s, type); } void @@ -78,11 +78,11 @@ namespace Slicer { s << "Unsupported model type"; } + AdHocFormatter(IncorrectElementNameMsg, "Incorrect element name [%?]"); void IncorrectElementName::ice_print(std::ostream & s) const { - static boost::format f("Incorrect element name [%s]"); - s << f % name; + IncorrectElementNameMsg::write(s, name); } void @@ -103,11 +103,11 @@ namespace Slicer { s << "General runtime error"; } + AdHocFormatter(CompilerErrorMsg, "Slicer compiler: %?"); void CompilerError::ice_print(std::ostream & s) const { - static boost::format f("Slicer compiler: %s"); - s << f % what; + CompilerErrorMsg::write(s, what); } } diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp index 307819a..08101ba 100644 --- a/slicer/xml/serializer.cpp +++ b/slicer/xml/serializer.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include NAMEDFACTORY(".xml", Slicer::XmlFileSerializer, Slicer::FileSerializerFactory); NAMEDFACTORY(".xml", Slicer::XmlFileDeserializer, Slicer::FileDeserializerFactory); @@ -438,10 +438,10 @@ namespace Slicer { modelRoot->OnEachChild(boost::bind(&XmlSerializer::ModelTreeIterateRoot, doc, _1, _2)); } + AdHocFormatter(BadBooleanValueMsg, "Bad boolean value [%?]"); void BadBooleanValue::ice_print(std::ostream & s) const { - static boost::format f("Bad boolean value [%s]"); - s << f % text; + BadBooleanValueMsg::write(s, text); } } -- cgit v1.2.3