diff --git a/six/modules/c++/six.sicd/include/six/sicd/DataParser.h b/six/modules/c++/six.sicd/include/six/sicd/DataParser.h index c7f59837e..457ee5781 100644 --- a/six/modules/c++/six.sicd/include/six/sicd/DataParser.h +++ b/six/modules/c++/six.sicd/include/six/sicd/DataParser.h @@ -43,7 +43,6 @@ namespace sicd class DataParser final { six::DataParser mDataParser; - XMLControlRegistry mXmlRegistry; public: diff --git a/six/modules/c++/six.sicd/source/DataParser.cpp b/six/modules/c++/six.sicd/source/DataParser.cpp index 64055e9bc..a493464b1 100644 --- a/six/modules/c++/six.sicd/source/DataParser.cpp +++ b/six/modules/c++/six.sicd/source/DataParser.cpp @@ -38,13 +38,12 @@ namespace fs = std::filesystem; six::sicd::DataParser::DataParser(const std::vector* pSchemaPaths, logging::Logger* pLog) : mDataParser(pSchemaPaths, pLog) { - mXmlRegistry.addCreator(); + mDataParser.addCreator(); } std::unique_ptr six::sicd::DataParser::DataParser::fromXML(::io::InputStream& xmlStream) const { - auto pData = mDataParser.fromXML(xmlStream, mXmlRegistry, DataType::NOT_SET); - return std::unique_ptr(static_cast(pData.release())); + return mDataParser.fromXML(xmlStream); } std::unique_ptr six::sicd::DataParser::DataParser::fromXML(const std::filesystem::path& pathname) const @@ -62,7 +61,7 @@ std::unique_ptr six::sicd::DataParser::DataParser::fromX std::u8string six::sicd::DataParser::DataParser::toXML(const six::sicd::ComplexData& data) const { - return mDataParser.toXML(data, mXmlRegistry); + return mDataParser.toXML(data); } void six::sicd::DataParser::DataParser::preserveCharacterData(bool preserve) diff --git a/six/modules/c++/six.sidd/include/six/sidd/DataParser.h b/six/modules/c++/six.sidd/include/six/sidd/DataParser.h index badf46004..04d132bea 100644 --- a/six/modules/c++/six.sidd/include/six/sidd/DataParser.h +++ b/six/modules/c++/six.sidd/include/six/sidd/DataParser.h @@ -44,7 +44,6 @@ class DataParser final { std::vector mAdjustedSchemaPaths; // used to initialized six::DataParser six::DataParser mDataParser; - XMLControlRegistry mXmlRegistry; public: diff --git a/six/modules/c++/six.sidd/source/DataParser.cpp b/six/modules/c++/six.sidd/source/DataParser.cpp index d9041d2a5..cc99c5a0d 100644 --- a/six/modules/c++/six.sidd/source/DataParser.cpp +++ b/six/modules/c++/six.sidd/source/DataParser.cpp @@ -70,13 +70,12 @@ static auto adjustSchemaPaths(const std::vector* pSchemaP six::sidd::DataParser::DataParser(const std::vector* pSchemaPaths, logging::Logger* pLog) : mDataParser(adjustSchemaPaths(pSchemaPaths, mAdjustedSchemaPaths), pLog) { - mXmlRegistry.addCreator(); + mDataParser.addCreator(); } std::unique_ptr six::sidd::DataParser::DataParser::fromXML(::io::InputStream& xmlStream) const { - auto pData = mDataParser.fromXML(xmlStream, mXmlRegistry, DataType::NOT_SET); - return std::unique_ptr(static_cast(pData.release())); + return mDataParser.fromXML(xmlStream); } std::unique_ptr six::sidd::DataParser::DataParser::fromXML(const std::filesystem::path& pathname) const @@ -94,7 +93,7 @@ std::unique_ptr six::sidd::DataParser::DataParser::fromX std::u8string six::sidd::DataParser::DataParser::toXML(const six::sidd::DerivedData& data) const { - return mDataParser.toXML(data, mXmlRegistry); + return mDataParser.toXML(data); } void six::sidd::DataParser::DataParser::preserveCharacterData(bool preserve) diff --git a/six/modules/c++/six/include/six/Utilities.h b/six/modules/c++/six/include/six/Utilities.h index b72e617ff..f178367ee 100644 --- a/six/modules/c++/six/include/six/Utilities.h +++ b/six/modules/c++/six/include/six/Utilities.h @@ -323,6 +323,7 @@ class DataParser final const std::vector* mpSchemaPaths = nullptr; logging::NullLogger mNullLogger; logging::Logger& mLog; + XMLControlRegistry mXmlRegistry; // The default is `true` because: // * many (most?) other parts of SIX unconditionally set `preserveCharacterData(true)`. @@ -353,6 +354,12 @@ class DataParser final */ void preserveCharacterData(bool preserve); + template + void addCreator() + { + mXmlRegistry.addCreator(); + } + /* Parses the XML in 'xmlStream'. * * \param xmlStream Input stream containing XML @@ -360,6 +367,12 @@ class DataParser final * \return Data representation of 'xmlStr' */ std::unique_ptr fromXML(::io::InputStream& xmlStream, const XMLControlRegistry&, DataType) const; + template + std::unique_ptr fromXML(::io::InputStream& xmlStream) const + { + auto pData = fromXML(xmlStream, mXmlRegistry, DataType::NOT_SET); + return std::unique_ptr(static_cast(pData.release())); + } /* * Parses the XML in 'pathname'. @@ -383,6 +396,7 @@ class DataParser final * Additionally performs schema validation -- */ std::u8string toXML(const Data&, const XMLControlRegistry&) const; + std::u8string toXML(const Data&) const; }; namespace testing diff --git a/six/modules/c++/six/source/Utilities.cpp b/six/modules/c++/six/source/Utilities.cpp index 167844738..a2ae89346 100644 --- a/six/modules/c++/six/source/Utilities.cpp +++ b/six/modules/c++/six/source/Utilities.cpp @@ -956,6 +956,10 @@ std::u8string six::DataParser::DataParser::toXML(const Data& data, const XMLCon { return ::six::toValidXMLString(data, mpSchemaPaths, &mLog, &xmlReg); } +std::u8string six::DataParser::DataParser::toXML(const Data& data) const +{ + return toXML(data, mXmlRegistry); +} void six::DataParser::DataParser::preserveCharacterData(bool preserve) {