Salome HOME
BugID: IPAL19426 Fixed methods Save/Load
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTableOfReal.cxx
index a5767647226a8496e23c99f68e19d8b0b2ecacac..2c3aba89e3ef811ed4d59cd737efaad6c69d0e8f 100644 (file)
+// 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.
+//
+// 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_AttributeTableOfReal.cxx
 //  Author : Michael Ponikarov
 //  Module : SALOME
 
-#include <SALOMEDSImpl_AttributeTableOfReal.hxx>
-#include <Standard_Failure.hxx>
-#include <TColStd_DataMapIteratorOfDataMapOfIntegerReal.hxx>
-#include <Standard_GUID.hxx>
+#include "SALOMEDSImpl_AttributeTableOfReal.hxx"
 #include <stdio.h>
-#include <TColStd_HSequenceOfExtendedString.hxx>  
+#include <strstream>
 
 using namespace std;
 
-IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfReal, SALOMEDSImpl_GenericAttribute )
-IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTableOfReal, SALOMEDSImpl_GenericAttribute )
-
 #define SEPARATOR '\1'
 
-static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString)
+typedef map<int, double>::const_iterator MI;
+
+static std::string getUnit(std::string theString)
 {
-  TCollection_ExtendedString aString(theString);
-  int aPos = aString.Search(SEPARATOR);
-  if(aPos <= 0 || aPos == aString.Length() ) return TCollection_ExtendedString();
-  return aString.Split(aPos);
+  std::string aString(theString);
+  int aPos = aString.find(SEPARATOR);
+  if(aPos <= 0 || aPos == aString.size() ) return std::string();
+  return aString.substr(aPos+1, aString.size());
 }
 
-static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString)
+static std::string getTitle(std::string theString)
 {
-  TCollection_ExtendedString aString(theString);
-  int aPos = aString.Search(SEPARATOR);
-  if(aPos < 1) return aString;
-  if(aPos == 1) return TCollection_ExtendedString();
-  aString.Split(aPos-1);
-  return aString;
+  std::string aString(theString);
+  int aPos = aString.find(SEPARATOR);
+  if(aPos < 0) return aString;
+  if(aPos == 0) return std::string();
+  return aString.substr(0, aPos);
 }
 
-const Standard_GUID& SALOMEDSImpl_AttributeTableOfReal::GetID() 
+const std::string& SALOMEDSImpl_AttributeTableOfReal::GetID() 
 {
-  static Standard_GUID SALOMEDSImpl_AttributeTableOfRealID ("128371A1-8F52-11d6-A8A3-0001021E8C7F");
+  static std::string SALOMEDSImpl_AttributeTableOfRealID ("128371A1-8F52-11d6-A8A3-0001021E8C7F");
   return SALOMEDSImpl_AttributeTableOfRealID;
 }
 
-Handle(SALOMEDSImpl_AttributeTableOfReal) SALOMEDSImpl_AttributeTableOfReal::Set(const TDF_Label& label) 
+SALOMEDSImpl_AttributeTableOfReal* SALOMEDSImpl_AttributeTableOfReal::Set(const DF_Label& label) 
 {
-  Handle(SALOMEDSImpl_AttributeTableOfReal) anAttr;
-  if (!label.FindAttribute(SALOMEDSImpl_AttributeTableOfReal::GetID(),anAttr)) {
-    anAttr = new SALOMEDSImpl_AttributeTableOfReal();
-    label.AddAttribute(anAttr);
+  SALOMEDSImpl_AttributeTableOfReal* A = NULL;
+  if (!(A=(SALOMEDSImpl_AttributeTableOfReal*)label.FindAttribute(SALOMEDSImpl_AttributeTableOfReal::GetID()))) {
+    A = new SALOMEDSImpl_AttributeTableOfReal();
+    label.AddAttribute(A);
   }
-  return anAttr;
+  return A;
 }
 
 SALOMEDSImpl_AttributeTableOfReal::SALOMEDSImpl_AttributeTableOfReal() 
 :SALOMEDSImpl_GenericAttribute("AttributeTableOfReal")
 {
-  myRows = new TColStd_HSequenceOfExtendedString();
-  myCols = new TColStd_HSequenceOfExtendedString();
   myNbRows = 0;
   myNbColumns = 0;
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetNbColumns(const Standard_Integer theNbColumns)
+void SALOMEDSImpl_AttributeTableOfReal::SetNbColumns(const int theNbColumns)
 {
   CheckLocked();  
   Backup();
   
-  TColStd_DataMapOfIntegerReal aMap;
+  map<int, double> aMap;
   aMap = myTable;
-  myTable.Clear();
+  myTable.clear();
 
-  TColStd_DataMapIteratorOfDataMapOfIntegerReal anIterator(aMap);
-  for(; anIterator.More(); anIterator.Next()) {
-    int aRow = (int)(anIterator.Key()/myNbColumns) + 1;
-    int aCol = (int)(anIterator.Key() - myNbColumns*(aRow-1));
+  for(MI p = aMap.begin(); p != aMap.end(); p++) {
+    int aRow = (int)(p->first/myNbColumns) + 1;
+    int aCol = (int)(p->first - myNbColumns*(aRow-1));
     if(aCol == 0) { aCol = myNbColumns; aRow--; }
     if(aCol > theNbColumns) continue;
     int aKey = (aRow-1)*theNbColumns+aCol;
-    myTable.Bind(aKey, anIterator.Value());
+    myTable[aKey] = p->second;
   }
 
   myNbColumns = theNbColumns;
 
-  while (myCols->Length() < myNbColumns) { // append empty columns titles
-    myCols->Append(TCollection_ExtendedString(""));
+  while (myCols.size() < myNbColumns) { // append empty columns titles
+    myCols.push_back(string(""));
   }
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetTitle(const TCollection_ExtendedString& theTitle) 
+void SALOMEDSImpl_AttributeTableOfReal::SetTitle(const std::string& theTitle) 
 {
   CheckLocked();  
   Backup();
@@ -96,26 +107,26 @@ void SALOMEDSImpl_AttributeTableOfReal::SetTitle(const TCollection_ExtendedStrin
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfReal::GetTitle() const 
+std::string SALOMEDSImpl_AttributeTableOfReal::GetTitle() const 
 {
   return myTitle;
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetRowData(const Standard_Integer theRow,
-                                                  const Handle(TColStd_HSequenceOfReal)& theData) 
+void SALOMEDSImpl_AttributeTableOfReal::SetRowData(const int theRow,
+                                                  const vector<double>& theData) 
 {
   CheckLocked();  
-  if(theData->Length() > myNbColumns) SetNbColumns(theData->Length());
+  if(theData.size() > myNbColumns) SetNbColumns(theData.size());
 
   Backup();
 
-  while (myRows->Length() < theRow) { // append new row titles
-    myRows->Append(TCollection_ExtendedString(""));
+  while (myRows.size() < theRow) { // append new row titles
+    myRows.push_back(std::string(""));
   }
 
-  Standard_Integer i, aShift = (theRow-1)*myNbColumns, aLength = theData->Length();
+  int i, aShift = (theRow-1)*myNbColumns, aLength = theData.size();
   for(i = 1; i <= aLength; i++) {
-    myTable.Bind(aShift + i, theData->Value(i));
+    myTable[aShift + i] = theData[i-1];
   }
 
   if(theRow > myNbRows) myNbRows = theRow;
@@ -123,113 +134,113 @@ void SALOMEDSImpl_AttributeTableOfReal::SetRowData(const Standard_Integer theRow
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-Handle(TColStd_HSequenceOfReal) SALOMEDSImpl_AttributeTableOfReal::GetRowData(const Standard_Integer theRow)
+vector<double> SALOMEDSImpl_AttributeTableOfReal::GetRowData(const int theRow)
 {
-  Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal();
-  Standard_Integer i, aShift = (theRow-1)*myNbColumns;
+  vector<double> aSeq;
+  int i, aShift = (theRow-1)*myNbColumns;
   for(i = 1; i <= myNbColumns; i++) {
-     if(myTable.IsBound(aShift+i)) 
-       aSeq->Append(myTable.Find(aShift+i));
+     if(myTable.find(aShift+i) != myTable.end()) 
+       aSeq.push_back(myTable[aShift+i]);
      else
-       aSeq->Append(0.);
+       aSeq.push_back(0.);
   }
   
   return aSeq;
 }
 
 
-void SALOMEDSImpl_AttributeTableOfReal::SetRowTitle(const Standard_Integer theRow,
-                                                      const TCollection_ExtendedString& theTitle) 
+void SALOMEDSImpl_AttributeTableOfReal::SetRowTitle(const int theRow,
+                                                   const std::string& theTitle) 
 {
   CheckLocked();  
   Backup();
-  TCollection_ExtendedString aTitle(theTitle), aUnit = GetRowUnit(theRow);
-  if(aUnit.Length()>0) {
+  std::string aTitle(theTitle), aUnit = GetRowUnit(theRow);
+  if(aUnit.size()>0) {
     aTitle += SEPARATOR;
     aTitle += aUnit;
   }
-  myRows->SetValue(theRow, aTitle);
+  myRows[theRow-1] = aTitle;
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetRowUnit(const Standard_Integer theRow,
-                                                     const TCollection_ExtendedString& theUnit) 
+void SALOMEDSImpl_AttributeTableOfReal::SetRowUnit(const int theRow,
+                                                  const std::string& theUnit) 
 {
   CheckLocked();  
   Backup();
-  TCollection_ExtendedString aTitle = GetRowTitle(theRow);
+  std::string aTitle = GetRowTitle(theRow);
   aTitle += SEPARATOR;
   aTitle += theUnit;
-
-  myRows->SetValue(theRow, aTitle);
+  
+  myRows[theRow-1] = aTitle;
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetRowUnits(const Handle(TColStd_HSequenceOfExtendedString)& theUnits)
+void SALOMEDSImpl_AttributeTableOfReal::SetRowUnits(const vector<string>& theUnits)
 {
-  if (theUnits->Length() != GetNbRows()) Standard_Failure::Raise("Invalid number of rows");
-  int aLength = theUnits->Length(), i;
-  for(i = 1; i <= aLength; i++) SetRowUnit(i, theUnits->Value(i));
+  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]);
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-Handle(TColStd_HSequenceOfExtendedString) SALOMEDSImpl_AttributeTableOfReal::GetRowUnits()
+vector<string> SALOMEDSImpl_AttributeTableOfReal::GetRowUnits()
 {
-  Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
-  int aLength = myRows->Length(), i;
-  for(i=1; i<=aLength; i++) aSeq->Append(getUnit(myRows->Value(i)));
+  vector<string> aSeq;
+  int aLength = myRows.size(), i;
+  for(i=0; i<aLength; i++) aSeq.push_back(getUnit(myRows[i]));
   return aSeq;
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetRowTitles(const Handle(TColStd_HSequenceOfExtendedString)& theTitles)
+void SALOMEDSImpl_AttributeTableOfReal::SetRowTitles(const vector<string>& theTitles)
 {
-  if (theTitles->Length() != GetNbRows()) Standard_Failure::Raise("Invalid number of rows");
-  int aLength = theTitles->Length(), i;
-  for(i = 1; i <= aLength; i++) SetRowTitle(i, theTitles->Value(i));
+  if (theTitles.size() != GetNbRows()) throw DFexception("Invalid number of rows");
+  int aLength = theTitles.size(), i;
+  for(i = 1; i <= aLength; i++) SetRowTitle(i, theTitles[i-1]);
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-Handle(TColStd_HSequenceOfExtendedString) SALOMEDSImpl_AttributeTableOfReal::GetRowTitles()
+vector<string> SALOMEDSImpl_AttributeTableOfReal::GetRowTitles()
 {
-  Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
-  int aLength = myRows->Length(), i;
-  for(i=1; i<=aLength; i++) aSeq->Append(getTitle(myRows->Value(i)));
+  vector<string> aSeq;
+  int aLength = myRows.size(), i;
+  for(i=0; i<aLength; i++) aSeq.push_back(getTitle(myRows[i]));
   return aSeq;
 }
 
 
-TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfReal::GetRowTitle(const Standard_Integer theRow) const 
+std::string SALOMEDSImpl_AttributeTableOfReal::GetRowTitle(const int theRow) const 
 {
-  return getTitle(myRows->Value(theRow));
+  return getTitle(myRows[theRow-1]);
 }
 
 
-TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfReal::GetRowUnit(const Standard_Integer theRow) const 
+std::string SALOMEDSImpl_AttributeTableOfReal::GetRowUnit(const int theRow) const 
 {
-  return getUnit(myRows->Value(theRow));
+  return getUnit(myRows[theRow-1]);
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetColumnData(const Standard_Integer theColumn,
-                                                     const Handle(TColStd_HSequenceOfReal)& theData) 
+void SALOMEDSImpl_AttributeTableOfReal::SetColumnData(const int theColumn,
+                                                     const vector<double>& theData) 
 {
   CheckLocked();  
   if(theColumn > myNbColumns) SetNbColumns(theColumn);
 
   Backup();
 
-  Standard_Integer i, aLength = theData->Length();
+  int i, aLength = theData.size();
   for(i = 1; i <= aLength; i++) {
-    myTable.Bind(myNbColumns*(i-1)+theColumn, theData->Value(i));
+    myTable[myNbColumns*(i-1)+theColumn] = theData[i-1];
   }
 
   if(aLength > myNbRows) {
     myNbRows = aLength;
-    while (myRows->Length() < myNbRows) { // append empty row titles
-      myRows->Append(TCollection_ExtendedString(""));
+    while (myRows.size() < myNbRows) { // append empty row titles
+      myRows.push_back(string(""));
     }
   }
   
@@ -237,80 +248,80 @@ void SALOMEDSImpl_AttributeTableOfReal::SetColumnData(const Standard_Integer the
 }
 
 
-Handle(TColStd_HSequenceOfReal) SALOMEDSImpl_AttributeTableOfReal::GetColumnData(const Standard_Integer theColumn)
+vector<double> SALOMEDSImpl_AttributeTableOfReal::GetColumnData(const int theColumn)
 {
-  Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal;
+  vector<double> aSeq;
   
-  Standard_Integer i, anIndex;
+  int i, anIndex;
   for(i = 1; i <= myNbRows; i++) {
     anIndex = myNbColumns*(i-1) + theColumn;
-    if(myTable.IsBound(anIndex)) 
-      aSeq->Append(myTable.Find(anIndex));
+    if(myTable.find(anIndex) != myTable.end()) 
+      aSeq.push_back(myTable[anIndex]);
     else
-      aSeq->Append(0.);
+      aSeq.push_back(0.);
   }
   
   return aSeq;
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetColumnTitle(const Standard_Integer theColumn,
-                                                      const TCollection_ExtendedString& theTitle) 
+void SALOMEDSImpl_AttributeTableOfReal::SetColumnTitle(const int theColumn,
+                                                      const std::string& theTitle) 
 {
   CheckLocked();  
   Backup();
-  while(myCols->Length() < theColumn) myCols->Append(TCollection_ExtendedString(""));
-  myCols->SetValue(theColumn,theTitle);
-  
+  while(myCols.size() < theColumn) myCols.push_back(std::string(""));
+  myCols[theColumn-1] = theTitle;
+
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfReal::GetColumnTitle(const Standard_Integer theColumn) const 
+std::string SALOMEDSImpl_AttributeTableOfReal::GetColumnTitle(const int theColumn) const 
 {
-  if(myCols.IsNull()) return "";
-  if(myCols->Length() < theColumn) return "";
-  return myCols->Value(theColumn);
+  if(myCols.empty()) return "";
+  if(myCols.size() < theColumn) return "";
+  return myCols[theColumn-1];
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::SetColumnTitles(const Handle(TColStd_HSequenceOfExtendedString)& theTitles)
+void SALOMEDSImpl_AttributeTableOfReal::SetColumnTitles(const vector<string>& theTitles)
 {
-  if (theTitles->Length() != myNbColumns) Standard_Failure::Raise("Invalid number of columns");
-  int aLength = theTitles->Length(), i;
-  for(i = 1; i <= aLength; i++)  myCols->SetValue(i, theTitles->Value(i));
+  if (theTitles.size() != myNbColumns) throw DFexception("Invalid number of columns");
+  int aLength = theTitles.size(), i;
+  for(i = 0; i < aLength; i++)  myCols[i] = theTitles[i];
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-Handle(TColStd_HSequenceOfExtendedString) SALOMEDSImpl_AttributeTableOfReal::GetColumnTitles()
+vector<string> SALOMEDSImpl_AttributeTableOfReal::GetColumnTitles()
 {
-  Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
-  int aLength = myCols->Length(), i;
-  for(i=1; i<=aLength; i++) aSeq->Append(myCols->Value(i));
+  vector<string> aSeq;
+  int aLength = myCols.size(), i;
+  for(i=0; i<aLength; i++) aSeq.push_back(myCols[i]);
   return aSeq;
 }
 
-Standard_Integer SALOMEDSImpl_AttributeTableOfReal::GetNbRows() const
+int SALOMEDSImpl_AttributeTableOfReal::GetNbRows() const
 {
   return myNbRows;
 }
 
-Standard_Integer SALOMEDSImpl_AttributeTableOfReal::GetNbColumns() const
+int SALOMEDSImpl_AttributeTableOfReal::GetNbColumns() const
 {
   return myNbColumns;
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::PutValue(const Standard_Real theValue,
-                                            const Standard_Integer theRow,
-                                            const Standard_Integer theColumn) 
+void SALOMEDSImpl_AttributeTableOfReal::PutValue(const double& theValue,
+                                                const int theRow,
+                                                const int theColumn) 
 {
   CheckLocked();      
   if(theColumn > myNbColumns) SetNbColumns(theColumn);
 
-  Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn;
-  myTable.Bind(anIndex, theValue);
+  int anIndex = (theRow-1)*myNbColumns + theColumn;
+  myTable[anIndex] =  theValue;
 
   if(theRow > myNbRows) {
-    while (myRows->Length() < theRow) { // append empty row titles
-      myRows->Append(TCollection_ExtendedString(""));
+    while (myRows.size() < theRow) { // append empty row titles
+      myRows.push_back(std::string(""));
     }
     myNbRows = theRow;
   }
@@ -318,41 +329,42 @@ void SALOMEDSImpl_AttributeTableOfReal::PutValue(const Standard_Real theValue,
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
 
-Standard_Boolean SALOMEDSImpl_AttributeTableOfReal::HasValue(const Standard_Integer theRow,
-                                                        const Standard_Integer theColumn) 
+bool SALOMEDSImpl_AttributeTableOfReal::HasValue(const int theRow,
+                                                const int theColumn) 
 {
-  if(theRow > myNbRows || theRow < 1) return Standard_False;
-  if(theColumn > myNbColumns || theColumn < 1) return Standard_False;
-  Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn;
-  return myTable.IsBound(anIndex); 
+  if(theRow > myNbRows || theRow < 1) return false;
+  if(theColumn > myNbColumns || theColumn < 1) return false;
+  int anIndex = (theRow-1)*myNbColumns + theColumn;
+  return (myTable.find(anIndex) != myTable.end()); 
 }
 
-Standard_Real SALOMEDSImpl_AttributeTableOfReal::GetValue(const Standard_Integer theRow,
-                                                     const Standard_Integer theColumn) 
+double SALOMEDSImpl_AttributeTableOfReal::GetValue(const int theRow,
+                                                  const int theColumn) 
 {
-  if(theRow > myNbRows || theRow < 1) Standard_Failure::Raise("Invalid cell index");
-  if(theColumn > myNbColumns || theColumn < 1) Standard_Failure::Raise("Invalid cell index");
+  if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
+  if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
 
-  Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn;
-  if(myTable.IsBound(anIndex)) return myTable.Find(anIndex);
+  int anIndex = (theRow-1)*myNbColumns + theColumn;
+  if(myTable.find(anIndex) != myTable.end()) return myTable[anIndex];
   
-  Standard_Failure::Raise("Invalid cell index");
+  throw DFexception("Invalid cell index");
   return 0.;
 }
 
-const Standard_GUID& SALOMEDSImpl_AttributeTableOfReal::ID() const
+const std::string& SALOMEDSImpl_AttributeTableOfReal::ID() const
 {
   return GetID();
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::Restore(const Handle(TDF_Attribute)& with) 
+void SALOMEDSImpl_AttributeTableOfReal::Restore(DF_Attribute* with) 
 {
-  Standard_Integer anIndex;
-  Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(with);
+  int anIndex;
+  SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(with);
+  if(!aTable) throw DFexception("Can't Restore from a null attribute");
 
-  myTable.Clear();
-  myCols->Clear();
-  myRows->Clear();
+  myTable.clear();
+  myCols.clear();
+  myRows.clear();
 
   myTable = aTable->myTable;
   myNbRows = aTable->myNbRows;
@@ -360,26 +372,26 @@ void SALOMEDSImpl_AttributeTableOfReal::Restore(const Handle(TDF_Attribute)& wit
   myTitle = aTable->myTitle;
   
   for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++)
-    myRows->Append(aTable->GetRowTitle(anIndex));
+    myRows.push_back(aTable->GetRowTitle(anIndex));
 
   for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) 
-    myCols->Append(aTable->GetColumnTitle(anIndex));
+    myCols.push_back(aTable->GetColumnTitle(anIndex));
 }
 
-Handle(TDF_Attribute) SALOMEDSImpl_AttributeTableOfReal::NewEmpty() const
+DF_Attribute* SALOMEDSImpl_AttributeTableOfReal::NewEmpty() const
 {
   return new SALOMEDSImpl_AttributeTableOfReal();
 }
 
-void SALOMEDSImpl_AttributeTableOfReal::Paste(const Handle(TDF_Attribute)& into,
-                                            const Handle(TDF_RelocationTable)&) const
+void SALOMEDSImpl_AttributeTableOfReal::Paste(DF_Attribute* into)
 {
-  Standard_Integer anIndex;
-  Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(into);
+  int anIndex;
+  SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(into);
+  if(!aTable) throw DFexception("Can't Paste into a null attribute"); 
 
-  aTable->myTable.Clear();
-  aTable->myCols->Clear();
-  aTable->myRows->Clear();
+  aTable->myTable.clear();
+  aTable->myCols.clear();
+  aTable->myRows.clear();
 
   aTable->myTable = myTable;
   aTable->myTitle = myTitle;
@@ -387,160 +399,154 @@ void SALOMEDSImpl_AttributeTableOfReal::Paste(const Handle(TDF_Attribute)& into,
   aTable->myNbColumns = myNbColumns;
 
   for(anIndex = 1; anIndex <= GetNbRows();anIndex++)
-    aTable->myRows->Append(GetRowTitle(anIndex));
+    aTable->myRows.push_back(GetRowTitle(anIndex));
   for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) 
-    aTable->myCols->Append(GetColumnTitle(anIndex));
+    aTable->myCols.push_back(GetColumnTitle(anIndex));
 }
 
 
-Handle_TColStd_HSequenceOfInteger SALOMEDSImpl_AttributeTableOfReal::GetSetRowIndices(const Standard_Integer theRow)
+vector<int> SALOMEDSImpl_AttributeTableOfReal::GetSetRowIndices(const int theRow)
 {
-  Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+  vector<int> aSeq;
 
-  Standard_Integer i, aShift = myNbColumns*(theRow-1);
+  int i, aShift = myNbColumns*(theRow-1);
   for(i = 1; i <= myNbColumns; i++) {
-    if(myTable.IsBound(aShift + i)) aSeq->Append(i);
+    if(myTable.find(aShift + i) != myTable.end()) aSeq.push_back(i);
   }
   
   return aSeq;
 }
 
-Handle_TColStd_HSequenceOfInteger SALOMEDSImpl_AttributeTableOfReal::GetSetColumnIndices(const Standard_Integer theColumn)
+vector<int> SALOMEDSImpl_AttributeTableOfReal::GetSetColumnIndices(const int theColumn)
 {
-  Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+  vector<int> aSeq;
 
-  Standard_Integer i, anIndex;
+  int i, anIndex;
   for(i = 1; i <= myNbRows; i++) {
     anIndex = myNbColumns*(i-1)+theColumn;
-    if(myTable.IsBound(anIndex)) aSeq->Append(i);
+    if(myTable.find(anIndex) != myTable.end()) aSeq.push_back(i);
   }
   
   return aSeq;
 }
 
-
-
-void SALOMEDSImpl_AttributeTableOfReal::ConvertToString(ostrstream& theStream)
+string SALOMEDSImpl_AttributeTableOfReal::Save() 
 {
+  string aString;
+  char* buffer = new char[1024];
   int i, j, l;
 
-  
   //Title
-  l = myTitle.Length();
-  theStream << l << "\n";
-  for(i=1; i<=l; i++)
-    theStream << myTitle.Value(i) << "\n";
-
-  //Nb rows
-  theStream << myNbRows << "\n";
-
-  //Rows titles
-  for(i=1; i<=myNbRows; i++) {
-    l = myRows->Value(i).Length();
-    theStream << l << "\n";
-    for(j=1; j<=l; j++)
-      theStream << myRows->Value(i).Value(j) << "\n";
+  l = myTitle.size();
+  sprintf(buffer, "%d\n", l);
+  aString+=buffer;
+  for(i=0; i<l; i++) {
+    aString += myTitle[i];
+    aString +='\n';
   }
+  
+  //Nb rows
+  sprintf(buffer, "%d\n", myNbRows);
+  aString+=buffer;
+
+  //Row titles
+  for(i=0; i<myNbRows; i++) {
+    l = myRows[i].size();
+    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=1; i<=myNbColumns; i++) {
-    l = myCols->Value(i).Length();
-    theStream << l << "\n";
-    for(j=1; j<=l; j++)
-      theStream << myCols->Value(i).Value(j) << "\n";
+  for(i=0; i<myNbColumns; i++) {
+    l = myCols[i].size();
+    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.Extent();
-  theStream << l << "\n";
-  char *aBuffer = new char[128];
-  TColStd_DataMapIteratorOfDataMapOfIntegerReal anIterator(myTable);
-  for(; anIterator.More(); anIterator.Next()) {
-    theStream << anIterator.Key() << "\n";
-    sprintf(aBuffer, "%.64e", anIterator.Value());
-    theStream << aBuffer << "\n";
+  l = myTable.size();
+  sprintf(buffer, "%d\n", l);
+  aString+=buffer;
+  for(MI p = myTable.begin(); p != myTable.end(); p++) {
+    sprintf(buffer, "%d\n%.64e\n", p->first, p->second);
+    aString += buffer;
   }
-  
-  delete []aBuffer;
 
-  return;
+  delete []buffer;
+  return aString;
 }
 
-bool SALOMEDSImpl_AttributeTableOfReal::RestoreFromString(istrstream& theStream)
+void SALOMEDSImpl_AttributeTableOfReal::Load(const string& value) 
 {
-  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();
 
-  Standard_ExtCharacter anExtChar;
-  TCollection_ExtendedString aStr;
+  pos = 0;
+  std::string aStr;
 
   //Title
-  theStream >> l;
+  l = strtol(v[pos++].c_str(), NULL, 10);
 
-  myTitle = TCollection_ExtendedString(l, 0);
-  for(i=1; i<=l; i++) {
-    theStream >> anExtChar;
-    myTitle.SetValue(i, anExtChar);
+  myTitle = std::string(l, 0);
+  for(i=0; i<l; i++) {
+    myTitle[i] = v[pos++][0];
   }
 
   //Nb rows
-  theStream >> myNbRows;
+  myNbRows = strtol(v[pos++].c_str(), NULL, 10);
 
   //Rows titles
-  myRows->Clear();  
+  myRows.clear();  
   for(i=1; i<=myNbRows; i++) { 
-    theStream >> l;
-    aStr = TCollection_ExtendedString(l,0);
-    for(j=1; j<=l; j++) {
-      theStream >> anExtChar;
-      aStr.SetValue(j, anExtChar);
+    l = strtol(v[pos++].c_str(), NULL, 10);
+    aStr = std::string(l,0);
+    for(j=0; j<l; j++) {
+      aStr[j] = v[pos++][0];
     }
-    myRows->Append(aStr);
+    myRows.push_back(aStr);
   }
 
   //Nb columns
-  theStream >> myNbColumns;
+  myNbColumns = strtol(v[pos++].c_str(), NULL, 10);
 
   //Columns titles
-  myCols->Clear();
+  myCols.clear();
   for(i=1; i<=myNbColumns; i++) {
-    theStream >> l;
-    aStr = TCollection_ExtendedString(l,0);
-    for(j=1; j<=l; j++) {
-      theStream >> anExtChar;
-      aStr.SetValue(j, anExtChar);
+    l = strtol(v[pos++].c_str(), NULL, 10);
+    aStr = std::string(l,0);
+    for(j=0; j<l; j++) {
+      aStr[j] = v[pos++][0];
     }
-    myCols->Append(aStr);
+    myCols.push_back(aStr);
   }
 
   //Restore the table values
-  theStream >> l;
-  myTable.Clear();
+  l = strtol(v[pos++].c_str(), NULL, 10);
+  myTable.clear();
   for(i=1; i<=l; i++) {
-    Standard_Integer aKey;
-    Standard_Real aValue;
-    theStream >> aKey;
-    theStream >> aValue;
-    myTable.Bind(aKey, aValue);
+    int aKey = strtol(v[pos++].c_str(), NULL, 10);
+    double aValue = strtod(v[pos++].c_str(), NULL);
+    myTable[aKey] = aValue;
   }
 
-  return true;
-}
-
-TCollection_AsciiString SALOMEDSImpl_AttributeTableOfReal::Save() 
-{
-  ostrstream ostr;
-  ConvertToString(ostr);
-  TCollection_AsciiString aString((char*)ostr.rdbuf()->str());
-  return aString;
-}
-
-void SALOMEDSImpl_AttributeTableOfReal::Load(const TCollection_AsciiString& value) 
-{
-  istrstream aStream(value.ToCString(), strlen(value.ToCString()));
-  RestoreFromString(aStream);
 }