#define DIRECTORYID 16661
#define FILELOCALID 26662
#define FILEID "FILE: "
+#define VARIABLE_SEPARATOR ':'
//============================================================================
{
string aString = aStringAttr->Value();
- vector<string> aVector = SALOMEDSImpl_Tool::splitString( aString, ':' );
+ vector<string> aVector = SALOMEDSImpl_Tool::splitStringWithEmpty( aString, VARIABLE_SEPARATOR );
for( int i = 0, len = aVector.size(); i < len; i++ )
{
string aStr = aVector[i];
bool isChanged = false;
string aNewString, aCurrentString = aStringAttr->Value();
- vector<string> aVector = SALOMEDSImpl_Tool::splitString( aCurrentString, ':' );
+ vector<string> aVector = SALOMEDSImpl_Tool::splitStringWithEmpty( aCurrentString, VARIABLE_SEPARATOR );
for( int i = 0, len = aVector.size(); i < len; i++ )
{
string aStr = aVector[i];
}
aNewString.append( aStr );
- if( i != len )
+ if( i != len - 1 )
aNewString.append( ":" );
}
return vs;
}
+//============================================================================
+// function :
+// purpose : The functions returns a list of substring of initial string
+// divided by given separator include empty strings
+//============================================================================
+vector<string> SALOMEDSImpl_Tool::splitStringWithEmpty(const string& theValue, char sep)
+{
+ vector<string> aResult;
+ if(theValue[0] == sep ) aResult.push_back(string());
+ int pos = theValue.find(sep);
+ if(pos < 0) {
+ aResult.push_back(theValue);
+ return aResult;
+ }
+
+ 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));
+ s = s.substr(pos+1, s.size());
+ }
+
+ if(!s.empty() && s[0] != sep) aResult.push_back(s);
+ if(theValue[theValue.size()-1] == sep) aResult.push_back(string());
+
+ return aResult;
+}
+
void SALOMEDSImpl_Tool::GetSystemDate(int& year, int& month, int& day, int& hours, int& minutes, int& seconds)
{
//The functions returns a list of substring of initial string divided by given separator
static std::vector<std::string> splitString(const std::string& theValue, char separator);
+ //The functions returns a list of substring of initial string divided by given separator,
+ //include empty strings
+ static std::vector<std::string> splitStringWithEmpty(const std::string& theValue, char separator);
+
+
//Returns a system date
static void GetSystemDate(int& year, int& month, int& day, int& hours, int& minutes, int& seconds);