From 383b2bf15d4a02b3f1cd951cc7096ef126745632 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 9 Sep 2008 13:53:10 +0000 Subject: [PATCH] *** empty log message *** --- .../SALOMEDSImpl_AttributeTableOfInteger.cxx | 95 +++++++------ .../SALOMEDSImpl_AttributeTableOfReal.cxx | 97 +++++++------ .../SALOMEDSImpl_AttributeTableOfString.cxx | 128 +++++++++--------- 3 files changed, 176 insertions(+), 144 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx index 0539b5e81..27abce57b 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx @@ -432,107 +432,122 @@ vector SALOMEDSImpl_AttributeTableOfInteger::GetSetColumnIndices(const int string SALOMEDSImpl_AttributeTableOfInteger::Save() { - ostrstream theStream; + string aString; + char* buffer = new char[1024]; int i, j, l; - theStream.precision(64); - //Title l = myTitle.size(); - theStream << l << "\n"; - for(i=0; ifirst << "\n"; - theStream << p->second << "\n"; + sprintf(buffer, "%d\n%d\n", p->first, p->second); + aString += buffer; } - string aString((char*)theStream.rdbuf()->str()); + delete []buffer; return aString; } + + void SALOMEDSImpl_AttributeTableOfInteger::Load(const string& value) { - istrstream theStream(value.c_str(), strlen(value.c_str())); - Backup(); + vector v; + int i, j, l, pos, aSize = (int)value.size(); + for(i = 0, pos = 0; i> l; + l = strtol(v[pos++].c_str(), NULL, 10); myTitle = std::string(l, 0); for(i=0; i> anExtChar; - myTitle[i] = anExtChar; + myTitle[i] = v[pos++][0]; } //Nb rows - theStream >> myNbRows; + myNbRows = strtol(v[pos++].c_str(), NULL, 10); //Rows titles myRows.clear(); for(i=1; i<=myNbRows; i++) { - theStream >> l; + l = strtol(v[pos++].c_str(), NULL, 10); aStr = std::string(l,0); for(j=0; j> anExtChar; - aStr[j] = anExtChar; + aStr[j] = v[pos++][0]; } myRows.push_back(aStr); } //Nb columns - theStream >> myNbColumns; + myNbColumns = strtol(v[pos++].c_str(), NULL, 10); //Columns titles myCols.clear(); for(i=1; i<=myNbColumns; i++) { - theStream >> l; + l = strtol(v[pos++].c_str(), NULL, 10); aStr = std::string(l,0); for(j=0; j> anExtChar; - aStr[j] = anExtChar; + aStr[j] = v[pos++][0]; } myCols.push_back(aStr); } //Restore the table values - theStream >> l; + l = strtol(v[pos++].c_str(), NULL, 10); myTable.clear(); for(i=1; i<=l; i++) { - int aKey, aValue; - theStream >> aKey; - theStream >> aValue; + int aKey = strtol(v[pos++].c_str(), NULL, 10); + int aValue = strtol(v[pos++].c_str(), NULL, 10); myTable[aKey] = aValue; } } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx index 64c5f03a6..2c3aba89e 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx @@ -432,109 +432,120 @@ vector SALOMEDSImpl_AttributeTableOfReal::GetSetColumnIndices(const int the string SALOMEDSImpl_AttributeTableOfReal::Save() { - ostrstream theStream; + string aString; + char* buffer = new char[1024]; int i, j, l; //Title l = myTitle.size(); - theStream << l << "\n"; - for(i=0; ifirst << "\n"; - sprintf(aBuffer, "%.64e", p->second); - theStream << aBuffer << "\n"; + sprintf(buffer, "%d\n%.64e\n", p->first, p->second); + aString += buffer; } - - delete []aBuffer; - string aString((char*)theStream.rdbuf()->str()); + + delete []buffer; return aString; } void SALOMEDSImpl_AttributeTableOfReal::Load(const string& value) { - istrstream theStream(value.c_str(), strlen(value.c_str())); - Backup(); + vector v; + int i, j, l, pos, aSize = (int)value.size(); + for(i = 0, pos = 0; i> l; + l = strtol(v[pos++].c_str(), NULL, 10); myTitle = std::string(l, 0); for(i=0; i> anExtChar; - myTitle[i] = anExtChar; + myTitle[i] = v[pos++][0]; } //Nb rows - theStream >> myNbRows; + myNbRows = strtol(v[pos++].c_str(), NULL, 10); //Rows titles myRows.clear(); for(i=1; i<=myNbRows; i++) { - theStream >> l; + l = strtol(v[pos++].c_str(), NULL, 10); aStr = std::string(l,0); for(j=0; j> anExtChar; - aStr[j] = anExtChar; + aStr[j] = v[pos++][0]; } myRows.push_back(aStr); } //Nb columns - theStream >> myNbColumns; + myNbColumns = strtol(v[pos++].c_str(), NULL, 10); //Columns titles myCols.clear(); for(i=1; i<=myNbColumns; i++) { - theStream >> l; + l = strtol(v[pos++].c_str(), NULL, 10); aStr = std::string(l,0); for(j=0; j> anExtChar; - aStr[j] = anExtChar; + aStr[j] = v[pos++][0]; } myCols.push_back(aStr); } //Restore the table values - theStream >> l; + l = strtol(v[pos++].c_str(), NULL, 10); myTable.clear(); for(i=1; i<=l; i++) { - int aKey; - double aValue; - theStream >> aKey; - theStream >> aValue; + int aKey = strtol(v[pos++].c_str(), NULL, 10); + double aValue = strtod(v[pos++].c_str(), NULL); myTable[aKey] = aValue; } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx index 245de358c..350dc0b28 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx @@ -433,131 +433,137 @@ vector SALOMEDSImpl_AttributeTableOfString::GetSetColumnIndices(const int t string SALOMEDSImpl_AttributeTableOfString::Save() { - ostrstream theStream; + string aString; + char* buffer = new char[1024]; int i, j, l; - + //Title l = myTitle.size(); - theStream << l << "\n"; - for(i=0; isecond.size()) { // check empty string in the value table - theStream << p->first << "\n"; + sprintf(buffer, "%d\n", p->first); + aString += buffer; unsigned long aValueSize = p->second.size(); - theStream<second.c_str(),aValueSize); - theStream<<"\n"; + sprintf(buffer, "%ld\n", aValueSize); + aString +=buffer; + aString += p->second; + aString += '\n'; } else { // write index only of kind: "0key"; "05", for an example - theStream << "0" << p->first << "\n"; + sprintf(buffer, "0%d\n", p->first); + aString+=buffer; } } - string aString((char*)theStream.rdbuf()->str()); + + delete []buffer; return aString; } void SALOMEDSImpl_AttributeTableOfString::Load(const string& value) { - istrstream theStream(value.c_str(), strlen(value.c_str())); - Backup(); - - theStream.seekg(0, ios::end); - long aSize = theStream.tellg(); - theStream.seekg(0, ios::beg); + vector v; + int i, j, l, pos, aSize = (int)value.size(); + for(i = 0, pos = 0; i> l; + l = strtol(v[pos++].c_str(), NULL, 10); myTitle = std::string(l, 0); for(i=0; i> anExtChar; - myTitle[i] = anExtChar; + myTitle[i] = v[pos++][0]; } //Nb rows - theStream >> myNbRows; + myNbRows = strtol(v[pos++].c_str(), NULL, 10); //Rows titles myRows.clear(); - for(i=0; i> l; + for(i=1; i<=myNbRows; i++) { + l = strtol(v[pos++].c_str(), NULL, 10); aStr = std::string(l,0); for(j=0; j> anExtChar; - aStr[j] = anExtChar; + aStr[j] = v[pos++][0]; } myRows.push_back(aStr); } //Nb columns - theStream >> myNbColumns; + myNbColumns = strtol(v[pos++].c_str(), NULL, 10); //Columns titles myCols.clear(); - for(i=0; i> l; + for(i=1; i<=myNbColumns; i++) { + l = strtol(v[pos++].c_str(), NULL, 10); aStr = std::string(l,0); for(j=0; j> anExtChar; - aStr[j] = anExtChar; + aStr[j] = v[pos++][0]; } myCols.push_back(aStr); } //Restore the table values - string aValue; - theStream >> l; + l = strtol(v[pos++].c_str(), NULL, 10); myTable.clear(); - theStream.getline(aValueString,aSize,'\n'); for(i=1; i<=l; i++) { - int aKey; - - theStream.getline(aValueString,aSize,'\n'); - aValue = aValueString; - aKey = atoi(aValue.c_str()); - if (aValue[0] == '0') + aStr = v[pos++]; //Ket as a string + int aKey = strtol(aStr.c_str(), NULL, 10); + string aValue; + if(aStr[0] == '0') //If the first character of the key is 0, then empty value aValue = ""; else { - unsigned long aValueSize; - theStream >> aValueSize; - theStream.read(aValueString, 1); // an '\n' omitting - theStream.read(aValueString, aValueSize); - theStream.read(aValueString, 1); // an '\n' omitting - aValue = aValueString; + long aSize = strtol(v[pos++].c_str(), NULL, 10); + aValue = v[pos++]; } myTable[aKey] = aValue; } - delete(aValueString); } -- 2.39.2