-// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
// File : SALOMEDSImpl_AttributeTableOfString.cxx
// Author : Sergey Ruin
// Module : SALOME
+//
+#include "SALOMEDSImpl_AttributeTableOfString.hxx"
-#include <SALOMEDSImpl_AttributeTableOfString.hxx>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strstream>
-
-using namespace std;
+#include <sstream>
+#include <algorithm>
#define SEPARATOR '\1'
-
-typedef map<int, string>::const_iterator MI;
+typedef std::map<int, std::string>::const_iterator MI;
static std::string getUnit(std::string theString)
{
CheckLocked();
Backup();
- map<int, string> aMap;
+ std::map<int, std::string> aMap;
aMap = myTable;
myTable.clear();
}
void SALOMEDSImpl_AttributeTableOfString::SetRowTitle(const int theRow,
- const std::string& theTitle)
+ const std::string& theTitle)
{
CheckLocked();
Backup();
}
void SALOMEDSImpl_AttributeTableOfString::SetRowUnit(const int theRow,
- const std::string& theUnit)
+ const std::string& theUnit)
{
CheckLocked();
Backup();
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-void SALOMEDSImpl_AttributeTableOfString::SetRowUnits(const vector<string>& theUnits)
+void SALOMEDSImpl_AttributeTableOfString::SetRowUnits(const std::vector<std::string>& theUnits)
{
if (theUnits.size() != GetNbRows()) throw DFexception("Invalid number of rows");
int aLength = theUnits.size(), i;
for(i = 1; i <= aLength; i++) SetRowUnit(i, theUnits[i-1]);
}
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetRowUnits()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetRowUnits()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myRows.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(getUnit(myRows[i]));
return aSeq;
}
-void SALOMEDSImpl_AttributeTableOfString::SetRowTitles(const vector<string>& theTitles)
+void SALOMEDSImpl_AttributeTableOfString::SetRowTitles(const std::vector<std::string>& theTitles)
{
if (theTitles.size() != GetNbRows()) throw DFexception("Invalid number of rows");
int aLength = theTitles.size(), i;
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetRowTitles()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetRowTitles()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myRows.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(getTitle(myRows[i]));
return aSeq;
}
-
std::string SALOMEDSImpl_AttributeTableOfString::GetRowTitle(const int theRow) const
{
return getTitle(myRows[theRow-1]);
}
-
std::string SALOMEDSImpl_AttributeTableOfString::GetRowUnit(const int theRow) const
{
return getUnit(myRows[theRow-1]);
}
void SALOMEDSImpl_AttributeTableOfString::SetRowData(const int theRow,
- const vector<string>& theData)
+ const std::vector<std::string>& theData)
{
CheckLocked();
if(theData.size() > myNbColumns) SetNbColumns(theData.size());
return myTitle;
}
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetRowData(const int theRow)
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetRowData(const int theRow)
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int i, aShift = (theRow-1)*myNbColumns;
for(i = 1; i <= myNbColumns; i++) {
if(myTable.find(aShift+i) != myTable.end())
}
void SALOMEDSImpl_AttributeTableOfString::SetColumnData(const int theColumn,
- const vector<string>& theData)
+ const std::vector<std::string>& theData)
{
CheckLocked();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetColumnData(const int theColumn)
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetColumnData(const int theColumn)
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int i, anIndex;
for(i = 1; i <= myNbRows; i++) {
}
void SALOMEDSImpl_AttributeTableOfString::SetColumnTitle(const int theColumn,
- const std::string& theTitle)
+ const std::string& theTitle)
{
CheckLocked();
Backup();
return myCols[theColumn-1];
}
-
-void SALOMEDSImpl_AttributeTableOfString::SetColumnTitles(const vector<string>& theTitles)
+void SALOMEDSImpl_AttributeTableOfString::SetColumnTitles(const std::vector<std::string>& theTitles)
{
if (theTitles.size() != myNbColumns) throw DFexception("Invalid number of columns");
int aLength = theTitles.size(), i;
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetColumnTitles()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetColumnTitles()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myCols.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(myCols[i]);
return aSeq;
}
-
int SALOMEDSImpl_AttributeTableOfString::GetNbRows() const
{
return myNbRows;
}
void SALOMEDSImpl_AttributeTableOfString::PutValue(const std::string& theValue,
- const int theRow,
- const int theColumn)
+ const int theRow,
+ const int theColumn)
{
CheckLocked();
+ //Backup();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
int anIndex = (theRow-1)*myNbColumns + theColumn;
}
bool SALOMEDSImpl_AttributeTableOfString::HasValue(const int theRow,
- const int theColumn)
+ const int theColumn)
{
if(theRow > myNbRows || theRow < 1) return false;
if(theColumn > myNbColumns || theColumn < 1) return false;
}
std::string SALOMEDSImpl_AttributeTableOfString::GetValue(const int theRow,
- const int theColumn)
+ const int theColumn)
{
if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
return "";
}
+void SALOMEDSImpl_AttributeTableOfString::RemoveValue(const int theRow, const int theColumn)
+{
+ CheckLocked();
+ if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
+ if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
+
+ int anIndex = (theRow-1)*myNbColumns + theColumn;
+ if (myTable.find(anIndex) != myTable.end()) {
+ //Backup();
+ myTable.erase(anIndex);
+ SetModifyFlag(); // table is modified
+ }
+}
+
const std::string& SALOMEDSImpl_AttributeTableOfString::ID() const
{
return GetID();
aTable->myCols.push_back(GetColumnTitle(anIndex));
}
-
-vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetRowIndices(const int theRow)
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetRowIndices(const int theRow)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, aShift = myNbColumns*(theRow-1);
for(i = 1; i <= myNbColumns; i++) {
return aSeq;
}
-vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetColumnIndices(const int theColumn)
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetColumnIndices(const int theColumn)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, anIndex;
for(i = 1; i <= myNbRows; i++) {
return aSeq;
}
-
-
-string SALOMEDSImpl_AttributeTableOfString::Save()
+std::string SALOMEDSImpl_AttributeTableOfString::Save()
{
- ostrstream theStream;
+ std::string aString;
+ char* buffer = new char[1024];
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
- theStream << myNbRows << "\n";
+ sprintf(buffer, "%d\n", myNbRows);
+ aString+=buffer;
- //Rows titles
+ //Row titles
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
- theStream << myNbColumns << "\n";
+ sprintf(buffer, "%d\n", myNbColumns);
+ aString+=buffer;
//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();
- 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
- theStream << p->first << "\n";
+ sprintf(buffer, "%d\n", p->first);
+ aString += buffer;
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
- 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)
+void SALOMEDSImpl_AttributeTableOfString::Load(const std::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);
+ std::vector<std::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
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
- theStream >> 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<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++) {
- theStream >> 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<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++) {
- theStream >> 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);
+ std::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;
+ strtol(v[pos++].c_str(), NULL, 10);
+ aValue = v[pos++];
}
myTable[aKey] = aValue;
}
- delete(aValueString);
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ if ( theRow > 0 && theRow <= myNbRows ) {
+ std::vector<int> indices( myNbColumns );
+ int cnt = 0;
+ for ( int i = 0; i < myNbColumns; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(theRow, i+1) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfString> sorter( this, sortOrder, sortPolicy, theRow, true );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbColumns );
+ cnt = 0;
+ for( int i = 0; i < myNbColumns; i++ )
+ other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+ result = indices;
+
+ for ( int col = 0; col < indices.size(); col++ ) {
+ int idx = indices[col];
+ if ( col+1 == idx ) continue;
+ SwapCells(theRow, col+1, theRow, idx);
+ int idx1 = 0;
+ for ( int i = col+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == col+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ if ( theColumn > 0 && theColumn <= myNbColumns ) {
+ std::vector<int> indices( myNbRows );
+ int cnt = 0;
+ for ( int i = 0; i < myNbRows; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(i+1, theColumn) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfString> sorter( this, sortOrder, sortPolicy, theColumn, false );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbRows );
+ cnt = 0;
+ for( int i = 0; i < myNbRows; i++ )
+ other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+ result = indices;
+
+ for ( int row = 0; row < indices.size(); row++ ) {
+ int idx = indices[row];
+ if ( row+1 == idx ) continue;
+ SwapCells(row+1, theColumn, idx, theColumn);
+ int idx1 = 0;
+ for ( int i = row+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == row+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ if ( theRow > 0 && theRow <= myNbRows ) {
+ std::vector<int> indices( myNbColumns );
+ int cnt = 0;
+ for ( int i = 0; i < myNbColumns; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(theRow, i+1) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfString> sorter( this, sortOrder, sortPolicy, theRow, true );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbColumns );
+ cnt = 0;
+ for( int i = 0; i < myNbColumns; i++ )
+ other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+ result = indices;
+
+ for ( int col = 0; col < indices.size(); col++ ) {
+ int idx = indices[col];
+ if ( col+1 == idx ) continue;
+ SwapColumns(col+1, idx);
+ int idx1 = 0;
+ for ( int i = col+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == col+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapColumns()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ if ( theColumn > 0 && theColumn <= myNbColumns ) {
+ std::vector<int> indices( myNbRows );
+ int cnt = 0;
+ for ( int i = 0; i < myNbRows; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(i+1, theColumn) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfString> sorter( this, sortOrder, sortPolicy, theColumn, false );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbRows );
+ cnt = 0;
+ for( int i = 0; i < myNbRows; i++ )
+ other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+ result = indices;
+
+ for ( int row = 0; row < indices.size(); row++ ) {
+ int idx = indices[row];
+ if ( row+1 == idx ) continue;
+ SwapRows(row+1, idx);
+ int idx1 = 0;
+ for ( int i = row+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == row+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapRows()
+ }
+ return result;
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SwapCells(const int theRow1, const int theColumn1,
+ const int theRow2, const int theColumn2)
+{
+ CheckLocked();
+ if (theRow1 > myNbRows || theRow1 < 1) throw DFexception("Invalid cell index");
+ if (theRow2 > myNbRows || theRow2 < 1) throw DFexception("Invalid cell index");
+ if (theColumn1 > myNbColumns || theColumn1 < 1) throw DFexception("Invalid cell index");
+ if (theColumn2 > myNbColumns || theColumn2 < 1) throw DFexception("Invalid cell index");
+
+ int anIndex1 = (theRow1-1)*myNbColumns + theColumn1;
+ int anIndex2 = (theRow2-1)*myNbColumns + theColumn2;
+
+ bool hasValue1 = myTable.find(anIndex1) != myTable.end();
+ bool hasValue2 = myTable.find(anIndex2) != myTable.end();
+
+ if (!hasValue1 && !hasValue2) return; // nothing changed
+
+ std::string value1 = hasValue1 ? myTable[anIndex1] : 0;
+ std::string value2 = hasValue2 ? myTable[anIndex2] : 0;
+
+ if (hasValue1 && hasValue2 && value1 == value2) return; // nothing changed
+
+ if (hasValue1) myTable[anIndex2] = value1;
+ else myTable.erase(anIndex2);
+ if (hasValue2) myTable[anIndex1] = value2;
+ else myTable.erase(anIndex1);
+
+ SetModifyFlag(); // table is modified
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SwapRows(const int theRow1, const int theRow2)
+{
+ CheckLocked();
+ for (int i = 1; i <= myNbColumns; i++)
+ SwapCells(theRow1, i, theRow2, i);
+ // swap row titles
+ std::string tmp = myRows[theRow1-1];
+ myRows[theRow1-1] = myRows[theRow2-1];
+ myRows[theRow2-1] = tmp;
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SwapColumns(const int theColumn1, const int theColumn2)
+{
+ CheckLocked();
+ for (int i = 1; i <= myNbRows; i++)
+ SwapCells(i, theColumn1, i, theColumn2);
+ // swap column titles
+ std::string tmp = myCols[theColumn1-1];
+ myCols[theColumn1-1] = myCols[theColumn2-1];
+ myCols[theColumn2-1] = tmp;
+ // no need for SetModifyFlag(), since it is done by SwapCells()
}