mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0023850: TDataStd_ByteArray is too slow on storage on disk
Optimization of a byte-array for XML persistence (binary persistence is ok). A possible bug is corrected (size of an array is extended a little). Same improvement for storage of a TDataStd_TreeNode. Improvement of speed of storage of several Ocaf attributes in XML file format. Also, format of storage of a double value is extended to keep 17 digits after a decimal point (it was used only 15 digits before). Several draw-commands are added to manipulate the basic Ocaf attributes: BooleanArray BooleanList IntegerList RealList A test-script for OCAF document successfully saved and opened from disk in XML file format. + 1 is added to keep '\0' Removed several spaces in source files. PLib_LocalArray is renamed to NCollection_LocalArray and became a template. It is used as a local array for Standard_Character in XML OCAF drivers, and as a local array of Standard_Real in PLib package. Small correction of test case for this fix
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <XmlMDataStd_BooleanArrayDriver.ixx>
|
||||
#include <TDataStd_BooleanArray.hxx>
|
||||
#include <TColStd_HArray1OfByte.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -93,9 +94,10 @@ Standard_Boolean XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persisten
|
||||
Handle(TDataStd_BooleanArray) aBooleanArray = Handle(TDataStd_BooleanArray)::DownCast(theTarget);
|
||||
aBooleanArray->Init(aFirstInd, aLastInd);
|
||||
Standard_Integer length = aLastInd - aFirstInd + 1;
|
||||
Handle(TColStd_HArray1OfByte) array = new TColStd_HArray1OfByte(0, length >> 3);
|
||||
Handle(TColStd_HArray1OfByte) hArr = new TColStd_HArray1OfByte(0, length >> 3);
|
||||
TColStd_Array1OfByte& arr = hArr->ChangeArray1();
|
||||
|
||||
Standard_Integer i = 0, upper = array->Upper();
|
||||
Standard_Integer i = 0, upper = arr.Upper();
|
||||
Standard_CString aValueStr = Standard_CString(XmlObjMgt::GetStringValue(anElement).GetString());
|
||||
for (; i <= upper; i++)
|
||||
{
|
||||
@@ -108,9 +110,9 @@ Standard_Boolean XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persisten
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
array->SetValue(i, (Standard_Byte) aValue);
|
||||
arr.SetValue(i, (Standard_Byte) aValue);
|
||||
}
|
||||
aBooleanArray->SetInternalArray(array);
|
||||
aBooleanArray->SetInternalArray(hArr);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -127,17 +129,27 @@ void XmlMDataStd_BooleanArrayDriver::Paste(const Handle(TDF_Attribute)& theSourc
|
||||
|
||||
Standard_Integer aL = aBooleanArray->Lower();
|
||||
Standard_Integer anU = aBooleanArray->Upper();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
theTarget.Element().setAttribute(::FirstIndexString(), aL);
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
|
||||
const Handle(TColStd_HArray1OfByte)& array = aBooleanArray->InternalArray();
|
||||
Standard_Integer lower = array->Lower(), i = lower, upper = array->Upper();
|
||||
const Handle(TColStd_HArray1OfByte)& hArr = aBooleanArray->InternalArray();
|
||||
const TColStd_Array1OfByte& arr = hArr->Array1();
|
||||
|
||||
// Allocation of 4 chars for each byte.
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str;
|
||||
if (arr.Length())
|
||||
str.Allocate(4 * arr.Length() + 1);
|
||||
|
||||
// Convert integers - compressed boolean values, to a string.
|
||||
Standard_Integer lower = arr.Lower(), i = lower, upper = arr.Upper();
|
||||
for (; i <= upper; i++)
|
||||
{
|
||||
aValueStr += TCollection_AsciiString((Standard_Integer) array->Value(i));
|
||||
aValueStr += ' ';
|
||||
const Standard_Byte& byte = arr.Value(i);
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", byte);
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
|
||||
if (arr.Length())
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <XmlMDataStd_BooleanListDriver.ixx>
|
||||
#include <TDataStd_BooleanList.hxx>
|
||||
#include <TDataStd_ListIteratorOfListOfByte.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -127,18 +128,18 @@ void XmlMDataStd_BooleanListDriver::Paste(const Handle(TDF_Attribute)& theSource
|
||||
Handle(TDataStd_BooleanList) aBooleanList = Handle(TDataStd_BooleanList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = aBooleanList->Extent();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
if (anU >= 1)
|
||||
{
|
||||
// Allocation of 1 char for each boolean value + a space.
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str(2 * anU + 1);
|
||||
TDataStd_ListIteratorOfListOfByte itr(aBooleanList->List());
|
||||
for (; itr.More(); itr.Next())
|
||||
{
|
||||
aValueStr += TCollection_AsciiString(itr.Value());
|
||||
aValueStr += ' ';
|
||||
const Standard_Byte& byte = itr.Value();
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", byte);
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <XmlMDataStd_ByteArrayDriver.ixx>
|
||||
#include <TDataStd_ByteArray.hxx>
|
||||
#include <TColStd_HArray1OfByte.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
#include <XmlMDataStd.hxx>
|
||||
|
||||
@@ -93,10 +94,11 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
|
||||
|
||||
|
||||
Handle(TDataStd_ByteArray) aByteArray = Handle(TDataStd_ByteArray)::DownCast(theTarget);
|
||||
Handle(TColStd_HArray1OfByte) array = new TColStd_HArray1OfByte(aFirstInd, aLastInd);
|
||||
Handle(TColStd_HArray1OfByte) hArr = new TColStd_HArray1OfByte(aFirstInd, aLastInd);
|
||||
TColStd_Array1OfByte& arr = hArr->ChangeArray1();
|
||||
|
||||
Standard_CString aValueStr = Standard_CString(XmlObjMgt::GetStringValue(anElement).GetString());
|
||||
Standard_Integer i = array->Lower(), upper = array->Upper();
|
||||
Standard_Integer i = arr.Lower(), upper = arr.Upper();
|
||||
for (; i <= upper; i++)
|
||||
{
|
||||
if (!XmlObjMgt::GetInteger(aValueStr, aValue))
|
||||
@@ -108,9 +110,9 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
array->SetValue(i, (Standard_Byte) aValue);
|
||||
arr.SetValue(i, (Standard_Byte) aValue);
|
||||
}
|
||||
aByteArray->ChangeArray(array);
|
||||
aByteArray->ChangeArray(hArr);
|
||||
|
||||
#ifdef DEB
|
||||
//cout << "CurDocVersion = " << XmlMDataStd::DocumentVersion() <<endl;
|
||||
@@ -152,19 +154,32 @@ void XmlMDataStd_ByteArrayDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
|
||||
Standard_Integer aL = aByteArray->Lower();
|
||||
Standard_Integer anU = aByteArray->Upper();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
theTarget.Element().setAttribute(::FirstIndexString(), aL);
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
theTarget.Element().setAttribute(::IsDeltaOn(),aByteArray->GetDelta());
|
||||
|
||||
const Handle(TColStd_HArray1OfByte)& array = aByteArray->InternalArray();
|
||||
Standard_Integer lower = array->Lower(), i = lower, upper = array->Upper();
|
||||
for (; i <= upper; i++)
|
||||
const Handle(TColStd_HArray1OfByte)& hArr = aByteArray->InternalArray();
|
||||
if (!hArr.IsNull() && hArr->Length())
|
||||
{
|
||||
aValueStr += TCollection_AsciiString((Standard_Integer) array->Value(i));
|
||||
aValueStr += ' ';
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
// Access to data through an internal reprsentation of the array is faster.
|
||||
const TColStd_Array1OfByte& arr = hArr->Array1();
|
||||
|
||||
// Allocate 4 characters (including a space ' ') for each byte (unsigned char) from the array.
|
||||
NCollection_LocalArray<Standard_Character> str(4 * arr.Length() + 1);
|
||||
|
||||
// Char counter in the array of chars.
|
||||
Standard_Integer iChar = 0;
|
||||
|
||||
// Iterate on the array of bytes and fill-in the array of chars inserting spacing between the chars.
|
||||
Standard_Integer iByte = arr.Lower(); // position inside the byte array
|
||||
for (; iByte <= arr.Upper(); ++iByte)
|
||||
{
|
||||
const Standard_Byte& byte = arr.Value(iByte);
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", byte);
|
||||
}
|
||||
|
||||
// Transfer the string (array of chars) to XML.
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include <XmlMDF_ADriver.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TDataStd_IntPackedMap.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlMDataStd.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (IntPackedMapSize, "mapsize")
|
||||
@@ -154,14 +155,21 @@ void XmlMDataStd_IntPackedMapDriver::Paste (const Handle(TDF_Attribute)& theSour
|
||||
theTarget.Element().setAttribute(::IntPackedMapSize(), aSize);
|
||||
theTarget.Element().setAttribute(::IsDeltaOn(),aS->GetDelta());
|
||||
|
||||
TCollection_AsciiString aValueString;
|
||||
if(aSize) {
|
||||
if(aSize)
|
||||
{
|
||||
// Allocation of 12 chars for each integer including the space.
|
||||
// An example: -2 147 483 648
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str(12 * aSize + 1);
|
||||
|
||||
TColStd_MapIteratorOfPackedMapOfInteger anIt(aS->GetMap());
|
||||
for(;anIt.More();anIt.Next()) {
|
||||
aValueString += TCollection_AsciiString(anIt.Key());
|
||||
aValueString += ' ';
|
||||
for(;anIt.More();anIt.Next())
|
||||
{
|
||||
const Standard_Integer intValue = anIt.Key();
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", intValue);
|
||||
}
|
||||
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueString.ToCString(), Standard_True);
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <XmlMDataStd_IntegerArrayDriver.ixx>
|
||||
#include <TDataStd_IntegerArray.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
#include <XmlMDataStd.hxx>
|
||||
|
||||
@@ -154,21 +155,36 @@ void XmlMDataStd_IntegerArrayDriver::Paste
|
||||
{
|
||||
Handle(TDataStd_IntegerArray) anIntArray =
|
||||
Handle(TDataStd_IntegerArray)::DownCast(theSource);
|
||||
const Handle(TColStd_HArray1OfInteger)& hIntArray = anIntArray->Array();
|
||||
const TColStd_Array1OfInteger& intArray = hIntArray->Array1();
|
||||
Standard_Integer aL = intArray.Lower(), anU = intArray.Upper();
|
||||
|
||||
Standard_Integer aL = anIntArray->Lower(), anU = anIntArray->Upper();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
if (aL != 1) theTarget.Element().setAttribute (::FirstIndexString(), aL);
|
||||
if (aL != 1)
|
||||
theTarget.Element().setAttribute(::FirstIndexString(), aL);
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
theTarget.Element().setAttribute(::IsDeltaOn(), anIntArray->GetDelta());
|
||||
|
||||
// Allocation of 12 chars for each integer including the space.
|
||||
// An example: -2 147 483 648
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str;
|
||||
if (intArray.Length())
|
||||
str.Allocate(12 * intArray.Length() + 1);
|
||||
|
||||
Standard_Integer i = aL;
|
||||
while (1) {
|
||||
aValueStr += TCollection_AsciiString(anIntArray->Value(i));
|
||||
if (i >= anU) break;
|
||||
aValueStr += ' ';
|
||||
while (1)
|
||||
{
|
||||
const Standard_Integer& intValue = intArray.Value(i);
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", intValue);
|
||||
if (i >= anU)
|
||||
break;
|
||||
++i;
|
||||
}
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
|
||||
if (intArray.Length())
|
||||
{
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
str[iChar - 1] = '\0';
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <XmlMDataStd_IntegerListDriver.ixx>
|
||||
#include <TDataStd_IntegerList.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -127,18 +128,21 @@ void XmlMDataStd_IntegerListDriver::Paste(const Handle(TDF_Attribute)& theSource
|
||||
Handle(TDataStd_IntegerList) anIntList = Handle(TDataStd_IntegerList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = anIntList->Extent();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
if (anU >= 1)
|
||||
{
|
||||
// Allocation of 12 chars for each integer including the space.
|
||||
// An example: -2 147 483 648
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str(12 * anU + 1);
|
||||
TColStd_ListIteratorOfListOfInteger itr(anIntList->List());
|
||||
for (; itr.More(); itr.Next())
|
||||
{
|
||||
aValueStr += TCollection_AsciiString(itr.Value());
|
||||
aValueStr += ' ';
|
||||
const Standard_Integer& intValue = itr.Value();
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", intValue);
|
||||
}
|
||||
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
}
|
||||
|
@@ -19,13 +19,13 @@
|
||||
|
||||
//AGV 150202: Changed prototype XmlObjMgt::SetStringValue()
|
||||
|
||||
#define OCC6010 // vro 01.06.2004
|
||||
|
||||
# include <stdio.h>
|
||||
#include <XmlMDataStd_RealArrayDriver.ixx>
|
||||
#include <TDataStd_RealArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
#include <XmlMDataStd.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
@@ -158,27 +158,35 @@ void XmlMDataStd_RealArrayDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
{
|
||||
Handle(TDataStd_RealArray) aRealArray =
|
||||
Handle(TDataStd_RealArray)::DownCast(theSource);
|
||||
|
||||
Standard_Integer aL = aRealArray->Lower(), anU = aRealArray->Upper();
|
||||
TCollection_AsciiString aValueStr;
|
||||
const Handle(TColStd_HArray1OfReal)& hRealArray = aRealArray->Array();
|
||||
const TColStd_Array1OfReal& realArray = hRealArray->Array1();
|
||||
Standard_Integer aL = realArray.Lower(), anU = realArray.Upper();
|
||||
|
||||
if (aL != 1) theTarget.Element().setAttribute(::FirstIndexString(), aL);
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
theTarget.Element().setAttribute(::IsDeltaOn(), aRealArray->GetDelta());
|
||||
|
||||
// Allocation of 25 chars for each double value including the space:
|
||||
// An example: -3.1512678732195273e+020
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str;
|
||||
if (realArray.Length())
|
||||
str.Allocate(25 * realArray.Length() + 1);
|
||||
|
||||
Standard_Integer i = aL;
|
||||
while (1) {
|
||||
#ifndef OCC6010
|
||||
aValueStr += TCollection_AsciiString(aRealArray->Value(i));
|
||||
#else
|
||||
char aValueChar[32];
|
||||
Sprintf(aValueChar, "%.15g", aRealArray->Value(i));
|
||||
aValueStr += aValueChar;
|
||||
#endif
|
||||
if (i >= anU) break;
|
||||
aValueStr += ' ';
|
||||
while (1)
|
||||
{
|
||||
const Standard_Real& dblValue = realArray.Value(i);
|
||||
iChar += Sprintf(&(str[iChar]), "%.17g ", dblValue);
|
||||
if (i >= anU)
|
||||
break;
|
||||
++i;
|
||||
}
|
||||
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
if (realArray.Length())
|
||||
{
|
||||
str[iChar - 1] = '\0';
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
}
|
||||
|
@@ -84,7 +84,7 @@ void XmlMDataStd_RealDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
TCollection_AsciiString aValueStr (anInt->Get());
|
||||
#else
|
||||
char aValueChar[32];
|
||||
Sprintf(aValueChar, "%.15g", anInt->Get());
|
||||
Sprintf(aValueChar, "%.17g", anInt->Get());
|
||||
TCollection_AsciiString aValueStr(aValueChar);
|
||||
#endif
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <XmlMDataStd_RealListDriver.ixx>
|
||||
#include <TDataStd_RealList.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfReal.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -135,18 +136,19 @@ void XmlMDataStd_RealListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
Handle(TDataStd_RealList) aRealList = Handle(TDataStd_RealList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = aRealList->Extent();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
if (anU >= 1)
|
||||
{
|
||||
// Allocation of 25 chars for each double value including the space:
|
||||
// An example: -3.1512678732195273e+020
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str(25 * anU + 1);
|
||||
TColStd_ListIteratorOfListOfReal itr(aRealList->List());
|
||||
for (; itr.More(); itr.Next())
|
||||
{
|
||||
aValueStr += TCollection_AsciiString(itr.Value());
|
||||
aValueStr += ' ';
|
||||
const Standard_Real& realValue = itr.Value();
|
||||
iChar += Sprintf(&(str[iChar]), "%.17g ", realValue);
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include <XmlMDataStd_TreeNodeDriver.ixx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
@@ -108,20 +109,24 @@ void XmlMDataStd_TreeNodeDriver::Paste
|
||||
{
|
||||
Handle(TDataStd_TreeNode) aS = Handle(TDataStd_TreeNode)::DownCast(theSource);
|
||||
|
||||
Standard_Integer aNb;
|
||||
|
||||
TCollection_AsciiString aChildrenStr;
|
||||
|
||||
// tree id
|
||||
Standard_Integer aNb;
|
||||
Standard_Character aGuidStr [40];
|
||||
Standard_PCharacter pGuidStr=aGuidStr;
|
||||
aS->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute(::TreeIdString(), aGuidStr);
|
||||
|
||||
// first child
|
||||
Handle(TDataStd_TreeNode) aF = aS->First();
|
||||
// Find number of children.
|
||||
int nbChildren = aS->NbChildren();
|
||||
|
||||
// Allocate 11 digits for each ID (an integer) of the child + a space.
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str;
|
||||
if (nbChildren)
|
||||
str.Allocate(11 * nbChildren + 1);
|
||||
|
||||
// form the string of numbers for the list of children
|
||||
Handle(TDataStd_TreeNode) aF = aS->First();
|
||||
while (!aF.IsNull())
|
||||
{
|
||||
aNb = theRelocTable.FindIndex(aF);
|
||||
@@ -129,14 +134,16 @@ void XmlMDataStd_TreeNodeDriver::Paste
|
||||
{
|
||||
aNb = theRelocTable.Add(aF);
|
||||
}
|
||||
TCollection_AsciiString aNbStr (aNb);
|
||||
aChildrenStr += aNbStr + " ";
|
||||
|
||||
// Add number to the long string.
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", aNb);
|
||||
|
||||
// next child
|
||||
aF = aF->Next();
|
||||
}
|
||||
|
||||
if (aChildrenStr.Length() > 0)
|
||||
theTarget.Element().setAttribute(::ChildrenString(),
|
||||
aChildrenStr.ToCString());
|
||||
if (nbChildren)
|
||||
{
|
||||
theTarget.Element().setAttribute(::ChildrenString(), (Standard_Character*)str);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user