From 97f18076383155b7db218d7bf119f1b758adc340 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 23 Nov 2010 16:08:28 +0000 Subject: [PATCH] Merge from V5_1_5_BR 23/11/2010 --- .../SALOMEDSImpl_ScalarVariable.cxx | 10 ++-- src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx | 50 +++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx index e6bb38616..1bd9fb353 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx @@ -122,7 +122,7 @@ std::string SALOMEDSImpl_ScalarVariable::Save() const{ } case SALOMEDSImpl_GenericVariable::STRING_VAR: { - sprintf(buffer, "\"%s\"", myStrValue.c_str()); + sprintf(buffer, "%s", myStrValue.c_str()); break; } default:break; @@ -187,11 +187,15 @@ void SALOMEDSImpl_ScalarVariable::Load(const std::string& theStrValue) { Kernel_Utils::Localizer loc; + std::string strCopy = theStrValue; if ( Type() == SALOMEDSImpl_GenericVariable::STRING_VAR ) { - setStringValue( theStrValue ); +#ifdef OLDSTUDY_COMPATIBILITY + if (strCopy.size() > 1 && strCopy[0] == '\"' && strCopy[strCopy.size()-1] == '\"') + strCopy = strCopy.substr(1, strCopy.size()-2); +#endif // OLDSTUDY_COMPATIBILITY + setStringValue( strCopy ); } else { - std::string strCopy = theStrValue; #ifdef OLDSTUDY_COMPATIBILITY int dotpos = strCopy.find(','); if (dotpos != std::string::npos) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx index 7f63ea527..9cd5b05ca 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "SALOMEDSImpl_Tool.hxx" @@ -241,24 +243,66 @@ std::vector SALOMEDSImpl_Tool::splitString(const std::string& theVa // purpose : The functions returns a list of substring of initial string // divided by given separator include empty strings //============================================================================ + +std::vector treatRepetation(const std::string& theValue); + +std::vector treatRepetation(const std::string& theValue) +{ + std::vector aResult; + int pos = theValue.find(";*="); + if(pos < 0 ) + { + aResult.push_back(theValue); + return aResult; + } + std::string val(theValue.substr(0, pos)); + std::string suffix(theValue.substr(pos+3)); + int nb; + std::istringstream tmp(suffix); + tmp >> nb; + for(int i=0; i SALOMEDSImpl_Tool::splitStringWithEmpty(const std::string& theValue, char sep) { std::vector aResult; if(theValue[0] == sep ) aResult.push_back(std::string()); int pos = theValue.find(sep); if(pos < 0 ) { - aResult.push_back(theValue); + if(sep == '|') + { + std::vector tmp = treatRepetation(theValue); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(theValue); return aResult; } std::string s = theValue; if(s[0] == sep) s = s.substr(1, s.size()); while((pos = s.find(sep)) >= 0) { - aResult.push_back(s.substr(0, pos)); + if(sep == '|') + { + std::vector tmp = treatRepetation(s.substr(0, pos)); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(s.substr(0, pos)); s = s.substr(pos+1, s.size()); } - if(!s.empty() && s[0] != sep) aResult.push_back(s); + if(!s.empty() && s[0] != sep) { + if(sep == '|') + { + std::vector tmp = treatRepetation(s); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(s); + } if(theValue[theValue.size()-1] == sep) aResult.push_back(std::string()); return aResult; -- 2.39.2