Skip to content

Commit

Permalink
XML strings are only UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Sep 11, 2023
1 parent 8cca000 commit 6f93611
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 62 deletions.
4 changes: 0 additions & 4 deletions six/modules/c++/cphd/include/cphd/CPHDXMLControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ class CPHDXMLControl
const Metadata& metadata,
const std::vector<std::string>& schemaPaths = std::vector<std::string>(),
bool prettyPrint = false);
std::string toXMLString_(
const Metadata& metadata,
const std::vector<std::string>& schemaPaths = std::vector<std::string>(),
bool prettyPrint = false);
virtual std::u8string toXMLString(
const Metadata& metadata,
const std::vector<std::filesystem::path>* pSchemaPaths,
Expand Down
8 changes: 0 additions & 8 deletions six/modules/c++/cphd/source/CPHDXMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ std::u8string CPHDXMLControl::toXMLString(

return toXMLString(metadata, &schemaPaths, prettyPrint);
}
std::string CPHDXMLControl::toXMLString_(
const Metadata& metadata,
const std::vector<std::string>& schemaPaths,
bool prettyPrint)
{
const auto result = toXMLString(metadata, schemaPaths, prettyPrint);
return str::to_native(result);
}

std::unique_ptr<xml::lite::Document> CPHDXMLControl::toXML(
const Metadata& metadata,
Expand Down
3 changes: 0 additions & 3 deletions six/modules/c++/cphd03/include/cphd03/CPHDXMLControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ class CPHDXMLControl : public six::XMLParser
std::unique_ptr<Metadata> fromXML(const xml::lite::Document* doc);
Metadata fromXML(const xml::lite::Document& doc);

std::unique_ptr<Metadata> fromXML(const std::string& xmlString);
std::unique_ptr<Metadata> fromXML(const std::u8string& xmlString);

std::string toXMLString_(const Metadata& metadata);
std::u8string toXMLString(const Metadata& metadata);

size_t getXMLsize(const Metadata& metadata);
Expand Down
9 changes: 0 additions & 9 deletions six/modules/c++/cphd03/source/CPHDXMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ std::u8string CPHDXMLControl::toXMLString(const Metadata& metadata)

return str::u8FromNative("<?xml version=\"1.0\"?>") + ss.stream().str();
}
std::string CPHDXMLControl::toXMLString_(const Metadata& metadata)
{
return str::to_native(toXMLString(metadata));
}

size_t CPHDXMLControl::getXMLsize(const Metadata& metadata)
{
Expand Down Expand Up @@ -491,11 +487,6 @@ XMLElem CPHDXMLControl::areaSampleDirectionParametersToXML(
return adpXML;
}

std::unique_ptr<Metadata> CPHDXMLControl::fromXML(const std::string& xmlString)
{
auto result = fromXML(str::u8FromNative(xmlString));
return std::unique_ptr<Metadata>(result.release());
}
std::unique_ptr<Metadata> CPHDXMLControl::fromXML(const std::u8string& xmlString)
{
io::U8StringStream stringStream;
Expand Down
4 changes: 0 additions & 4 deletions six/modules/c++/six.sicd/include/six/sicd/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,6 @@ struct Utilities final
*
* \return XML string representation of 'data'
*/
static std::string toXMLString(
const ComplexData& data,
const std::vector<std::string>& schemaPaths = std::vector<std::string>(),
logging::Logger* logger = nullptr);
static std::u8string toXMLString(const ComplexData&,
const std::vector<std::filesystem::path>*, logging::Logger* pLogger = nullptr);
/*!
Expand Down
11 changes: 0 additions & 11 deletions six/modules/c++/six.sicd/source/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,17 +1040,6 @@ std::unique_ptr<ComplexData> Utilities::parseDataFromString(const std::u8string&
return parser.fromXML(xmlStr);
}

std::string Utilities::toXMLString(const ComplexData& data,
const std::vector<std::string>& schemaPaths_,
logging::Logger* logger)
{
std::vector<std::filesystem::path> schemaPaths;
std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths),
[](const std::string& s) { return s; });

const auto result = toXMLString(data, &schemaPaths, logger);
return str::to_native(result);
}
std::u8string Utilities::toXMLString(const ComplexData& data,
const std::vector<std::filesystem::path>* pSchemaPaths, logging::Logger* pLogger)
{
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ TEST_CASE(FakeComplexData)
const auto data = six::sicd::Utilities::createFakeComplexData();

const std::vector<std::string> schemaPaths;
const auto result = six::sicd::Utilities::toXMLString(*data, schemaPaths);
const auto result = six::sicd::Utilities::toXMLString(*data, nullptr);
TEST_ASSERT_FALSE(result.empty());
}

Expand Down
10 changes: 0 additions & 10 deletions six/modules/c++/six.sidd/source/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,16 +580,6 @@ std::unique_ptr<DerivedData> Utilities::parseDataFromString(const std::u8string&
return dataParser.fromXML(xmlStr);
}

std::string Utilities::toXMLString(const DerivedData& data,
const std::vector<std::string>& schemaPaths_, logging::Logger* logger)
{
std::vector<std::filesystem::path> schemaPaths;
std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths),
[](const std::string& s) { return s; });

const auto result = toXMLString(data, &schemaPaths, logger);
return str::to_native(result);
}
std::u8string Utilities::toXMLString(const DerivedData& data,
const std::vector<std::filesystem::path>* pSchemaPaths, logging::Logger* pLogger)
{
Expand Down
2 changes: 0 additions & 2 deletions six/modules/c++/six/include/six/XMLControlFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ struct XMLControlRegistry
*/
std::u8string toXMLString(const Data* data,
const XMLControlRegistry *xmlRegistry = nullptr);
std::string toXMLString_(const Data* data,
const XMLControlRegistry* xmlRegistry = nullptr);

/*!
* Additionally performs schema validation --
Expand Down
6 changes: 0 additions & 6 deletions six/modules/c++/six/source/XMLControlFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ std::u8string six::toXMLString(const Data* data,
return toValidXMLString(data, std::vector<std::string>(),
&log, xmlRegistry);
}
std::string six::toXMLString_(const Data* data,
const six::XMLControlRegistry* xmlRegistry)
{
const auto result = toXMLString(data, xmlRegistry);
return str::to_native(result);
}

template<typename TSchemaPaths>
std::u8string six_toValidXMLString(const Data& data,
Expand Down
4 changes: 2 additions & 2 deletions six/projects/csm/source/SICDSensorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ void SICDSensorModel::initializeFromFile(const std::string& pathname)
container->getData(0)->clone()));

// get xml as string for sensor model state
const auto xmlStr = six::toXMLString_(mData.get(), &xmlRegistry);
mSensorModelState = NAME + std::string(" ") + xmlStr;
const auto xmlStr = six::toXMLString(mData.get(), &xmlRegistry);
mSensorModelState = NAME + std::string(" ") + str::to_native(xmlStr);
reinitialize();
}
catch (const except::Exception& ex)
Expand Down
4 changes: 2 additions & 2 deletions six/projects/csm/source/SIDDSensorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ void SIDDSensorModel::initializeFromFile(const std::string& pathname,
mData.reset(reinterpret_cast<six::sidd::DerivedData*>(data->clone()));

// get xml as string for sensor model state
const auto xmlStr = six::toXMLString_(mData.get(), &xmlRegistry);
mSensorModelState = NAME + std::string(" ") + xmlStr;
const auto xmlStr = six::toXMLString(mData.get(), &xmlRegistry);
mSensorModelState = NAME + std::string(" ") + str::to_native(xmlStr);
reinitialize();
}
catch (const except::Exception& ex)
Expand Down

0 comments on commit 6f93611

Please sign in to comment.