Salome HOME
projects
/
modules
/
kernel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0de3061
)
Bug IPAL19426, fixed methods Save/Load
TG_start_Deformed_CutPlanes
V4_1_2
V4_1_2rc3
author
srn
<srn@opencascade.com>
Fri, 25 Apr 2008 09:49:37 +0000
(09:49 +0000)
committer
srn
<srn@opencascade.com>
Fri, 25 Apr 2008 09:49:37 +0000
(09:49 +0000)
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx
patch
|
blob
|
history
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx
patch
|
blob
|
history
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx
patch
|
blob
|
history
diff --git
a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx
b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx
index 0539b5e8125c0b9b21818fb1eaaeebf824bfd9c0..27abce57b26852d221aa90680860d6233bf13359 100644
(file)
--- a/
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx
+++ b/
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx
@@
-432,107
+432,122
@@
vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetSetColumnIndices(const int
string SALOMEDSImpl_AttributeTableOfInteger::Save()
{
string SALOMEDSImpl_AttributeTableOfInteger::Save()
{
- ostrstream theStream;
+ string aString;
+ char* buffer = new char[1024];
int i, j, l;
int i, j, l;
- theStream.precision(64);
-
//Title
l = myTitle.size();
//Title
l = myTitle.size();
- theStream << l << "\n";
- for(i=0; i<l; i++)
- theStream << myTitle[i] << "\n";
-
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(i=0; i<l; i++) {
+ aString += myTitle[i];
+ aString +='\n';
+ }
+
//Nb rows
//Nb rows
- theStream << myNbRows << "\n";
+ sprintf(buffer, "%d\n", myNbRows);
+ aString+=buffer;
- //Row
s
titles
+ //Row titles
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myRows[i][j] << "\n";
- }
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myRows[i][j];
+ aString += '\n';
+ }
+ }
//Nb columns
//Nb columns
- theStream << myNbColumns << "\n";
+ sprintf(buffer, "%d\n", myNbColumns);
+ aString+=buffer;
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myCols[i][j] << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myCols[i][j];
+ aString += '\n';
+ }
}
//Store the table values
l = myTable.size();
}
//Store the table values
l = myTable.size();
- theStream << l << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
for(MI p = myTable.begin(); p != myTable.end(); p++) {
for(MI p = myTable.begin(); p != myTable.end(); p++) {
-
theStream << p->first << "\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;
}
return aString;
}
+
+
void SALOMEDSImpl_AttributeTableOfInteger::Load(const string& value)
{
void SALOMEDSImpl_AttributeTableOfInteger::Load(const string& value)
{
- istrstream theStream(value.c_str(), strlen(value.c_str()));
- Backup();
+ vector<string> v;
+ int i, j, l, pos, aSize = (int)value.size();
+ for(i = 0, pos = 0; i<aSize; i++) {
+ if(value[i] == '\n') {
+ v.push_back(value.substr(pos, i-pos));
+ pos = i+1;
+ }
+ }
-
int i, j, l
;
+
Backup()
;
-
char anExtChar
;
+
pos = 0
;
std::string aStr;
//Title
std::string aStr;
//Title
-
theStream >> l
;
+
l = strtol(v[pos++].c_str(), NULL, 10)
;
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
- theStream >> anExtChar;
- myTitle[i] = anExtChar;
+ myTitle[i] = v[pos++][0];
}
//Nb rows
}
//Nb rows
-
theStream >> myNbRows
;
+
myNbRows = strtol(v[pos++].c_str(), NULL, 10)
;
//Rows titles
myRows.clear();
for(i=1; i<=myNbRows; i++) {
//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<l; j++) {
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myRows.push_back(aStr);
}
//Nb columns
}
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++) {
//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<l; j++) {
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myCols.push_back(aStr);
}
//Restore the table values
}
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++) {
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;
}
}
myTable[aKey] = aValue;
}
}
diff --git
a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx
b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx
index 64c5f03a6bd6f124960d059749992a33b07fa662..2c3aba89e3ef811ed4d59cd737efaad6c69d0e8f 100644
(file)
--- a/
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx
+++ b/
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx
@@
-432,109
+432,120
@@
vector<int> SALOMEDSImpl_AttributeTableOfReal::GetSetColumnIndices(const int the
string SALOMEDSImpl_AttributeTableOfReal::Save()
{
string SALOMEDSImpl_AttributeTableOfReal::Save()
{
- ostrstream theStream;
+ string aString;
+ char* buffer = new char[1024];
int i, j, l;
//Title
l = myTitle.size();
int i, j, l;
//Title
l = myTitle.size();
- theStream << l << "\n";
- for(i=0; i<l; i++)
- theStream << myTitle[i] << "\n";
-
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(i=0; i<l; i++) {
+ aString += myTitle[i];
+ aString +='\n';
+ }
+
//Nb rows
//Nb rows
- theStream << myNbRows << "\n";
+ sprintf(buffer, "%d\n", myNbRows);
+ aString+=buffer;
- //Row
s
titles
+ //Row titles
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myRows[i][j] << "\n";
- }
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myRows[i][j];
+ aString += '\n';
+ }
+ }
//Nb columns
//Nb columns
- theStream << myNbColumns << "\n";
+ sprintf(buffer, "%d\n", myNbColumns);
+ aString+=buffer;
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myCols[i][j] << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myCols[i][j];
+ aString += '\n';
+ }
}
//Store the table values
l = myTable.size();
}
//Store the table values
l = myTable.size();
-
theStream << l << "\n"
;
-
char *aBuffer = new char[128]
;
+
sprintf(buffer, "%d\n", l)
;
+
aString+=buffer
;
for(MI p = myTable.begin(); p != myTable.end(); p++) {
for(MI p = myTable.begin(); p != myTable.end(); p++) {
- theStream << p->first << "\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)
{
return aString;
}
void SALOMEDSImpl_AttributeTableOfReal::Load(const string& value)
{
- istrstream theStream(value.c_str(), strlen(value.c_str()));
- Backup();
+ vector<string> v;
+ int i, j, l, pos, aSize = (int)value.size();
+ for(i = 0, pos = 0; i<aSize; i++) {
+ if(value[i] == '\n') {
+ v.push_back(value.substr(pos, i-pos));
+ pos = i+1;
+ }
+ }
-
int i, j, l
;
+
Backup()
;
-
char anExtChar
;
+
pos = 0
;
std::string aStr;
//Title
std::string aStr;
//Title
-
theStream >> l
;
+
l = strtol(v[pos++].c_str(), NULL, 10)
;
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
- theStream >> anExtChar;
- myTitle[i] = anExtChar;
+ myTitle[i] = v[pos++][0];
}
//Nb rows
}
//Nb rows
-
theStream >> myNbRows
;
+
myNbRows = strtol(v[pos++].c_str(), NULL, 10)
;
//Rows titles
myRows.clear();
for(i=1; i<=myNbRows; i++) {
//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<l; j++) {
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myRows.push_back(aStr);
}
//Nb columns
}
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++) {
//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<l; j++) {
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myCols.push_back(aStr);
}
//Restore the table values
}
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++) {
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;
}
myTable[aKey] = aValue;
}
diff --git
a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx
b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx
index 245de358c6b933b1e3d98cee20d2705797a1b4f2..350dc0b284ebed33530d6879dd18d82acd4ea9f0 100644
(file)
--- a/
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx
+++ b/
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx
@@
-433,131
+433,137
@@
vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetColumnIndices(const int t
string SALOMEDSImpl_AttributeTableOfString::Save()
{
string SALOMEDSImpl_AttributeTableOfString::Save()
{
- ostrstream theStream;
+ string aString;
+ char* buffer = new char[1024];
int i, j, l;
int i, j, l;
-
+
//Title
l = myTitle.size();
//Title
l = myTitle.size();
- theStream << l << "\n";
- for(i=0; i<l; i++)
- theStream << myTitle[i] << "\n";
-
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(i=0; i<l; i++) {
+ aString += myTitle[i];
+ aString +='\n';
+ }
+
//Nb rows
//Nb rows
- theStream << myNbRows << "\n";
+ sprintf(buffer, "%d\n", myNbRows);
+ aString+=buffer;
- //Row
s
titles
+ //Row titles
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myRows[i][j] << "\n";
- }
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myRows[i][j];
+ aString += '\n';
+ }
+ }
//Nb columns
//Nb columns
- theStream << myNbColumns << "\n";
+ sprintf(buffer, "%d\n", myNbColumns);
+ aString+=buffer;
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myCols[i][j] << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myCols[i][j];
+ aString += '\n';
+ }
}
//Store the table values
l = myTable.size();
}
//Store the table values
l = myTable.size();
- theStream << l << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
for(MI p = myTable.begin(); p!=myTable.end(); p++) {
if (p->second.size()) { // check empty string in the value table
for(MI p = myTable.begin(); p!=myTable.end(); p++) {
if (p->second.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();
unsigned long aValueSize = p->second.size();
- theStream<<aValueSize << "\n";
- theStream.write(p->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
} 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)
{
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<string> v;
+ int i, j, l, pos, aSize = (int)value.size();
+ for(i = 0, pos = 0; i<aSize; i++) {
+ if(value[i] == '\n') {
+ v.push_back(value.substr(pos, i-pos));
+ pos = i+1;
+ }
+ }
- int i, j, l;
- char *aValueString = new char[aSize];
+ Backup();
-
char anExtChar
;
+
pos = 0
;
std::string aStr;
//Title
std::string aStr;
//Title
-
theStream >> l
;
+
l = strtol(v[pos++].c_str(), NULL, 10)
;
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
- theStream >> anExtChar;
- myTitle[i] = anExtChar;
+ myTitle[i] = v[pos++][0];
}
//Nb rows
}
//Nb rows
-
theStream >> myNbRows
;
+
myNbRows = strtol(v[pos++].c_str(), NULL, 10)
;
//Rows titles
myRows.clear();
//Rows titles
myRows.clear();
- for(i=
0; i<
myNbRows; i++) {
-
theStream >> l
;
+ for(i=
1; i<=
myNbRows; i++) {
+
l = strtol(v[pos++].c_str(), NULL, 10)
;
aStr = std::string(l,0);
for(j=0; j<l; j++) {
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myRows.push_back(aStr);
}
//Nb columns
}
myRows.push_back(aStr);
}
//Nb columns
-
theStream >> myNbColumns
;
+
myNbColumns = strtol(v[pos++].c_str(), NULL, 10)
;
//Columns titles
myCols.clear();
//Columns titles
myCols.clear();
- for(i=
0; i<
myNbColumns; i++) {
-
theStream >> l
;
+ for(i=
1; i<=
myNbColumns; i++) {
+
l = strtol(v[pos++].c_str(), NULL, 10)
;
aStr = std::string(l,0);
for(j=0; j<l; j++) {
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myCols.push_back(aStr);
}
//Restore the table values
}
myCols.push_back(aStr);
}
//Restore the table values
- string aValue;
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
myTable.clear();
myTable.clear();
- theStream.getline(aValueString,aSize,'\n');
for(i=1; i<=l; i++) {
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 {
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;
}
}
myTable[aKey] = aValue;
}
- delete(aValueString);
}
}