-// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <PartSetPlugin_Part.h>
-#include <OSD_OpenFile.hxx>
-
#include <fstream>
+#include <iomanip>
+#include <cctype>
+#include <cmath>
// =========== Implementation of storage of dumped data ===========
static const int THE_DUMP_PRECISION = 16;
bool ModelHighAPI_Dumper::DumpStorage::exportTo(const std::string& theFilename,
const ModulesSet& theUsedModules)
{
- std::ofstream aFile;
- OSD_OpenStream(aFile, theFilename.c_str(), std::ofstream::out);
+ std::ofstream aFile(theFilename.c_str(), std::ofstream::out);
if (!aFile.is_open())
return false;
std::list<ResultPtr> allRes;
ModelAPI_Tools::allResults(theFeature, allRes);
for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- std::pair<std::wstring, bool> aName = ModelAPI_Tools::getDefaultName(*aRes);
+ std::pair<std::wstring, bool> aName = ModelAPI_Tools::getDefaultName(*aRes, true, true);
std::string aDefaultName = Locale::Convert::toString(aName.first);
std::string aResName = Locale::Convert::toString((*aRes)->data()->name());
bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName);
ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
const std::shared_ptr<ModelAPI_AttributeString>& theAttrStr)
{
- *myDumpStorage << "\"" << theAttrStr->value() << "\"";
+ // escaping the quote signs in the string under dumping
+ std::string aStr = theAttrStr->value();
+ /*
+ size_t aPos = aStr.find("\"");
+ while (aPos != std::string::npos) {
+ aStr.insert(aPos, "\\");
+ aPos = aStr.find("\"", aPos + 2);
+ }
+ aPos = aStr.find("\'");
+ while (aPos != std::string::npos) {
+ aStr.insert(aPos, "\\");
+ aPos = aStr.find("\'", aPos + 2);
+ }
+ */
+ size_t aPos = aStr.find_first_of("\"\'");
+ while (aPos != std::string::npos) {
+ aStr.insert(aPos, "\\");
+ aPos = aStr.find_first_of("\"\'", aPos + 2);
+ }
+ *myDumpStorage << "'" << aStr << "'";
return *this;
}
bool isAdded = false;
std::list<ObjectPtr>::const_iterator anIt = aList.begin();
for (; anIt != aList.end(); ++anIt) {
+ if (!(*anIt))
+ continue;
if (!isDumped(ModelAPI_Feature::feature(*anIt)))
break; // stop if the object is not dumped yet (parent feature should be postponed)