From b0f7123713d75b534b846cae371a6ae81a74253e Mon Sep 17 00:00:00 2001 From: caremoli Date: Fri, 18 Jun 2010 12:42:35 +0000 Subject: [PATCH] CCAR:synchronize with V5_1_main head --- .../SALOMEDSImpl_ScalarVariable.cxx | 29 +++++++++++++++---- .../SALOMEDSImpl_StudyBuilder.cxx | 10 +++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx index 0bc795290..e6bb38616 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx @@ -23,10 +23,13 @@ // #include "SALOMEDSImpl_ScalarVariable.hxx" #include "SALOMEDSImpl_GenericVariable.hxx" +#include "Basics_Utils.hxx" #include #include #include +#define OLDSTUDY_COMPATIBILITY + //============================================================================ /*! Function : SALOMEDSImpl_ScalarVariable * Purpose : @@ -101,6 +104,8 @@ std::string SALOMEDSImpl_ScalarVariable::getStringValue() const */ //============================================================================ std::string SALOMEDSImpl_ScalarVariable::Save() const{ + Kernel_Utils::Localizer loc; + char buffer[255]; switch(Type()) { @@ -132,6 +137,8 @@ std::string SALOMEDSImpl_ScalarVariable::Save() const{ //============================================================================ std::string SALOMEDSImpl_ScalarVariable::SaveToScript() const { + Kernel_Utils::Localizer loc; + char buffer[255]; switch(Type()) { @@ -147,10 +154,7 @@ std::string SALOMEDSImpl_ScalarVariable::SaveToScript() const } case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR: { - if((bool)myValue) - sprintf(buffer, "%s", "True"); - else - sprintf(buffer, "%s", "False"); + sprintf(buffer, "%s", ((bool)myValue) ? "True" : "False"); break; } case SALOMEDSImpl_GenericVariable::STRING_VAR: @@ -181,6 +185,19 @@ std::string SALOMEDSImpl_ScalarVariable::SaveType() const{ //============================================================================ void SALOMEDSImpl_ScalarVariable::Load(const std::string& theStrValue) { - double aValue = atof(theStrValue.c_str()); - setValue(aValue); + Kernel_Utils::Localizer loc; + + if ( Type() == SALOMEDSImpl_GenericVariable::STRING_VAR ) { + setStringValue( theStrValue ); + } + else { + std::string strCopy = theStrValue; +#ifdef OLDSTUDY_COMPATIBILITY + int dotpos = strCopy.find(','); + if (dotpos != std::string::npos) + strCopy.replace(dotpos, 1, "."); +#endif // OLDSTUDY_COMPATIBILITY + double aValue = atof(strCopy.c_str()); + setValue(aValue); + } } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index f49c7d0c6..fad7a39ce 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -77,7 +77,7 @@ SALOMEDSImpl_SComponent SALOMEDSImpl_StudyBuilder::NewComponent(const std::strin //std::cerr << "I'm here newComponent " << std::endl; _errorCode = ""; CheckLocked(); - + SALOMEDSImpl_SComponent sco; if(DataType.size() == 0) return sco; @@ -326,6 +326,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO, char aMultifileState[2]; char ASCIIfileState[2]; + bool hasModuleData = false; try { std::string scoid = anSCO.GetID(); hdf_file->OpenOnDisk(HDF_RDONLY); @@ -333,6 +334,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO, hdf_group->OpenOnDisk(); HDFgroup *hdf_sco_group = new HDFgroup((char*)scoid.c_str(), hdf_group); hdf_sco_group->OpenOnDisk(); + hasModuleData = true; unsigned char* aStreamFile = NULL; int aStreamSize = 0; @@ -403,6 +405,10 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO, } if (aLocked) _study->GetProperties()->SetLocked(true); + + if (!hasModuleData) + return true; + _errorCode = "No persistent file"; return false; } @@ -418,7 +424,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO, } else { _errorCode = "No persistent file"; } - + return true; } -- 2.39.2