mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0027970: Improvement of standard attributes usability - containers.
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_BooleanArrayDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "boolarrattguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_BooleanArrayDriver
|
||||
//purpose : Constructor
|
||||
@@ -52,8 +52,8 @@ Handle(TDF_Attribute) XmlMDataStd_BooleanArrayDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd, aValue;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
@@ -105,16 +105,24 @@ Standard_Boolean XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persisten
|
||||
if (!XmlObjMgt::GetInteger(aValueStr, aValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for BooleanArray attribute as \"")
|
||||
+ aValueStr + "\"";
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for BooleanArray attribute as \"")
|
||||
+ aValueStr + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
arr.SetValue(i, (Standard_Byte) aValue);
|
||||
}
|
||||
aBooleanArray->SetInternalArray(hArr);
|
||||
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_BooleanArray::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
aBooleanArray->SetID(aGUID);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -123,8 +131,8 @@ Standard_Boolean XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persisten
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMDataStd_BooleanArrayDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_BooleanArray) aBooleanArray = Handle(TDataStd_BooleanArray)::DownCast(theSource);
|
||||
|
||||
@@ -153,4 +161,11 @@ void XmlMDataStd_BooleanArrayDriver::Paste(const Handle(TDF_Attribute)& theSourc
|
||||
|
||||
if (arr.Length())
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
if(aBooleanArray->ID() != TDataStd_BooleanArray::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aBooleanArray->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_BooleanListDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "boollistattguid")
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_BooleanListDriver
|
||||
@@ -52,8 +53,8 @@ Handle(TDF_Attribute) XmlMDataStd_BooleanListDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_BooleanListDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd, aValue, ind;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
@@ -115,7 +116,17 @@ Standard_Boolean XmlMDataStd_BooleanListDriver::Paste(const XmlObjMgt_Persistent
|
||||
aBooleanList->Append(aValue ? Standard_True : Standard_False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_BooleanList::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
aBooleanList->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -124,8 +135,8 @@ Standard_Boolean XmlMDataStd_BooleanListDriver::Paste(const XmlObjMgt_Persistent
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMDataStd_BooleanListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
const Handle(TDataStd_BooleanList) aBooleanList = Handle(TDataStd_BooleanList)::DownCast(theSource);
|
||||
|
||||
@@ -145,4 +156,12 @@ void XmlMDataStd_BooleanListDriver::Paste(const Handle(TDF_Attribute)& theSource
|
||||
}
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
|
||||
if(aBooleanList->ID() != TDataStd_BooleanList::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aBooleanList->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <XmlMDataStd_ByteArrayDriver.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
#include <XmlObjMgt_Persistent.hxx>
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "bytearrattguid")
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ByteArrayDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -53,8 +54,8 @@ Handle(TDF_Attribute) XmlMDataStd_ByteArrayDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd, aValue;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
@@ -105,9 +106,9 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
|
||||
if (!XmlObjMgt::GetInteger(aValueStr, aValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for ByteArray attribute as \"")
|
||||
+ aValueStr + "\"";
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for ByteArray attribute as \"")
|
||||
+ aValueStr + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -120,14 +121,14 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
|
||||
if(XmlMDataStd::DocumentVersion() > 2) {
|
||||
Standard_Integer aDeltaValue;
|
||||
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the isDelta value"
|
||||
" for ByteArray attribute as \"")
|
||||
+ aDeltaValue + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the isDelta value"
|
||||
" for ByteArray attribute as \"")
|
||||
+ aDeltaValue + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
else
|
||||
aDelta = aDeltaValue != 0;
|
||||
}
|
||||
@@ -137,6 +138,16 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
|
||||
#endif
|
||||
aByteArray->SetDelta(aDelta);
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_ByteArray::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
aByteArray->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -145,8 +156,8 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMDataStd_ByteArrayDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_ByteArray) aByteArray = Handle(TDataStd_ByteArray)::DownCast(theSource);
|
||||
|
||||
@@ -180,4 +191,11 @@ void XmlMDataStd_ByteArrayDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
// Transfer the string (array of chars) to XML.
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
if(aByteArray->ID() != TDataStd_ByteArray::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aByteArray->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@
|
||||
#include <XmlObjMgt.hxx>
|
||||
#include <XmlObjMgt_Document.hxx>
|
||||
#include <XmlObjMgt_Persistent.hxx>
|
||||
#include <XmlLDrivers.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ExtStringArrayDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -32,6 +31,7 @@ IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
IMPLEMENT_DOMSTRING (ExtString, "string")
|
||||
IMPLEMENT_DOMSTRING (IsDeltaOn, "delta")
|
||||
IMPLEMENT_DOMSTRING (Separator, "separator")
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "extstrarrattguid")
|
||||
|
||||
// Searches for a symbol within an array of strings.
|
||||
// Returns TRUE if the symbol is found.
|
||||
@@ -73,9 +73,9 @@ Handle(TDF_Attribute) XmlMDataStd_ExtStringArrayDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_ExtStringArrayDriver::Paste
|
||||
( const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd, ind;
|
||||
TCollection_ExtendedString aValue;
|
||||
@@ -188,12 +188,12 @@ Standard_Boolean XmlMDataStd_ExtStringArrayDriver::Paste
|
||||
Standard_Integer aDeltaValue;
|
||||
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the isDelta value"
|
||||
" for IntegerArray attribute as \"")
|
||||
+ aDeltaValue + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the isDelta value"
|
||||
" for IntegerArray attribute as \"")
|
||||
+ aDeltaValue + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
else
|
||||
aDelta = aDeltaValue != 0;
|
||||
@@ -204,6 +204,16 @@ Standard_Boolean XmlMDataStd_ExtStringArrayDriver::Paste
|
||||
#endif
|
||||
aExtStringArray->SetDelta(aDelta);
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_ExtStringArray::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
aExtStringArray->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -228,44 +238,39 @@ void XmlMDataStd_ExtStringArrayDriver::Paste (const Handle(TDF_Attribute)& theSo
|
||||
|
||||
// Find a separator.
|
||||
Standard_Boolean found(Standard_True);
|
||||
// Optimization of storage of string array elements.
|
||||
// It is applied since the storage version 8 and newer.
|
||||
// Preferrable symbols for the separator: - _ . : ^ ~
|
||||
// Don't use a space as a separator: XML low-level parser sometimes "eats" it.
|
||||
Standard_Character c = '-';
|
||||
if (XmlLDrivers::StorageVersion() > 7)
|
||||
static Standard_Character aPreferable[] = "-_.:^~";
|
||||
for (i = 0; found && aPreferable[i]; i++)
|
||||
{
|
||||
// Preferrable symbols for the separator: - _ . : ^ ~
|
||||
// Don't use a space as a separator: XML low-level parser sometimes "eats" it.
|
||||
static Standard_Character aPreferable[] = "-_.:^~";
|
||||
for (i = 0; found && aPreferable[i]; i++)
|
||||
c = aPreferable[i];
|
||||
found = Contains(aExtStringArray, TCollection_ExtendedString(c));
|
||||
}
|
||||
// If all prefferable symbols exist in the array,
|
||||
// try to use any other simple symbols.
|
||||
if (found)
|
||||
{
|
||||
c = '!';
|
||||
while (found && c < '~')
|
||||
{
|
||||
c = aPreferable[i];
|
||||
found = Contains(aExtStringArray, TCollection_ExtendedString(c));
|
||||
}
|
||||
// If all prefferable symbols exist in the array,
|
||||
// try to use any other simple symbols.
|
||||
if (found)
|
||||
{
|
||||
c = '!';
|
||||
while (found && c < '~')
|
||||
{
|
||||
found = Standard_False;
|
||||
found = Standard_False;
|
||||
#ifdef _DEBUG
|
||||
TCollection_AsciiString cseparator(c); // deb
|
||||
TCollection_AsciiString cseparator(c); // deb
|
||||
#endif
|
||||
TCollection_ExtendedString separator(c);
|
||||
found = Contains(aExtStringArray, separator);
|
||||
if (found)
|
||||
TCollection_ExtendedString separator(c);
|
||||
found = Contains(aExtStringArray, separator);
|
||||
if (found)
|
||||
{
|
||||
c++;
|
||||
// Skip forbidden symbols for XML.
|
||||
while (c < '~' && (c == '&' || c == '<'))
|
||||
{
|
||||
c++;
|
||||
// Skip forbidden symbols for XML.
|
||||
while (c < '~' && (c == '&' || c == '<'))
|
||||
{
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}// check doc version
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
@@ -320,4 +325,11 @@ void XmlMDataStd_ExtStringArrayDriver::Paste (const Handle(TDF_Attribute)& theSo
|
||||
// Set UNICODE value.
|
||||
XmlObjMgt::SetExtendedString(theTarget, xstr);
|
||||
}
|
||||
if(aExtStringArray->ID() != TDataStd_ExtStringArray::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aExtStringArray->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ExtStringListDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
IMPLEMENT_DOMSTRING (ExtString, "string")
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "extstrlistattguid")
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_ExtStringListDriver
|
||||
@@ -54,8 +55,8 @@ Handle(TDF_Attribute) XmlMDataStd_ExtStringListDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_ExtStringListDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
@@ -85,30 +86,39 @@ Standard_Boolean XmlMDataStd_ExtStringListDriver::Paste(const XmlObjMgt_Persiste
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if(aLastInd == 0) return Standard_True;
|
||||
const Handle(TDataStd_ExtStringList) anExtStringList = Handle(TDataStd_ExtStringList)::DownCast(theTarget);
|
||||
|
||||
if (!anElement.hasChildNodes())
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve a list of extended strings");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
if(aLastInd > 0) {
|
||||
if (!anElement.hasChildNodes())
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve a list of extended strings");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
LDOM_Node aCurNode = anElement.getFirstChild();
|
||||
LDOM_Element* aCurElement = (LDOM_Element*)&aCurNode;
|
||||
TCollection_ExtendedString aValueStr;
|
||||
while (*aCurElement != anElement.getLastChild())
|
||||
{
|
||||
XmlObjMgt::GetExtendedString( *aCurElement, aValueStr );
|
||||
anExtStringList->Append(aValueStr);
|
||||
aCurNode = aCurElement->getNextSibling();
|
||||
aCurElement = (LDOM_Element*)&aCurNode;
|
||||
}
|
||||
|
||||
LDOM_Node aCurNode = anElement.getFirstChild();
|
||||
LDOM_Element* aCurElement = (LDOM_Element*)&aCurNode;
|
||||
TCollection_ExtendedString aValueStr;
|
||||
while (*aCurElement != anElement.getLastChild())
|
||||
{
|
||||
XmlObjMgt::GetExtendedString( *aCurElement, aValueStr );
|
||||
anExtStringList->Append(aValueStr);
|
||||
aCurNode = aCurElement->getNextSibling();
|
||||
aCurElement = (LDOM_Element*)&aCurNode;
|
||||
}
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_ExtStringList::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
XmlObjMgt::GetExtendedString( *aCurElement, aValueStr );
|
||||
anExtStringList->Append(aValueStr);
|
||||
anExtStringList->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -118,8 +128,8 @@ Standard_Boolean XmlMDataStd_ExtStringListDriver::Paste(const XmlObjMgt_Persiste
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMDataStd_ExtStringListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
const Handle(TDataStd_ExtStringList) anExtStringList = Handle(TDataStd_ExtStringList)::DownCast(theSource);
|
||||
|
||||
@@ -137,4 +147,12 @@ void XmlMDataStd_ExtStringListDriver::Paste(const Handle(TDF_Attribute)& theSour
|
||||
XmlObjMgt::SetExtendedString( aCurTarget, aValueStr );
|
||||
anElement.appendChild( aCurTarget );
|
||||
}
|
||||
|
||||
if(anExtStringList->ID() != TDataStd_ExtStringList::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
anExtStringList->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,8 @@ IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_IntegerArrayDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
IMPLEMENT_DOMSTRING (IsDeltaOn, "delta")
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "intarrattguid")
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_IntegerArrayDriver
|
||||
//purpose : Constructor
|
||||
@@ -123,12 +125,12 @@ Standard_Boolean XmlMDataStd_IntegerArrayDriver::Paste
|
||||
Standard_Integer aDeltaValue;
|
||||
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the isDelta value"
|
||||
" for IntegerArray attribute as \"")
|
||||
+ aDeltaValue + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the isDelta value"
|
||||
" for IntegerArray attribute as \"")
|
||||
+ aDeltaValue + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
else
|
||||
aDelta = aDeltaValue != 0;
|
||||
@@ -138,7 +140,17 @@ Standard_Boolean XmlMDataStd_IntegerArrayDriver::Paste
|
||||
cout << "Current DocVersion field is not initialized. " <<endl;
|
||||
#endif
|
||||
anIntArray->SetDelta(aDelta);
|
||||
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_IntegerArray::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
anIntArray->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -184,4 +196,11 @@ void XmlMDataStd_IntegerArrayDriver::Paste
|
||||
str[iChar - 1] = '\0';
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
if(anIntArray->ID() != TDataStd_IntegerArray::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
anIntArray->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -27,13 +27,14 @@
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_IntegerListDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "intlistattguid")
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_IntegerListDriver
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
XmlMDataStd_IntegerListDriver::XmlMDataStd_IntegerListDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
|
||||
: XmlMDF_ADriver (theMsgDriver, NULL)
|
||||
: XmlMDF_ADriver (theMsgDriver, NULL)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -52,8 +53,8 @@ Handle(TDF_Attribute) XmlMDataStd_IntegerListDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_IntegerListDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd, aValue, ind;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
@@ -115,7 +116,17 @@ Standard_Boolean XmlMDataStd_IntegerListDriver::Paste(const XmlObjMgt_Persistent
|
||||
anIntList->Append(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_IntegerList::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
anIntList->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -124,8 +135,8 @@ Standard_Boolean XmlMDataStd_IntegerListDriver::Paste(const XmlObjMgt_Persistent
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMDataStd_IntegerListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
const Handle(TDataStd_IntegerList) anIntList = Handle(TDataStd_IntegerList)::DownCast(theSource);
|
||||
|
||||
@@ -148,4 +159,12 @@ void XmlMDataStd_IntegerListDriver::Paste(const Handle(TDF_Attribute)& theSource
|
||||
}
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
|
||||
if(anIntList->ID() != TDataStd_IntegerList::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
anIntList->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_RealArrayDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
IMPLEMENT_DOMSTRING (IsDeltaOn, "delta")
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "realarrattguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_RealArrayDriver
|
||||
//purpose : Constructor
|
||||
@@ -129,12 +129,12 @@ Standard_Boolean XmlMDataStd_RealArrayDriver::Paste
|
||||
Standard_Integer aDeltaValue;
|
||||
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the isDelta value"
|
||||
" for RealArray attribute as \"")
|
||||
+ aDeltaValue + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the isDelta value"
|
||||
" for RealArray attribute as \"")
|
||||
+ aDeltaValue + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
else
|
||||
aDelta = aDeltaValue != 0;
|
||||
@@ -145,6 +145,15 @@ Standard_Boolean XmlMDataStd_RealArrayDriver::Paste
|
||||
#endif
|
||||
aRealArray->SetDelta(aDelta);
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_RealArray::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
aRealArray->SetID(aGUID);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -209,4 +218,11 @@ void XmlMDataStd_RealArrayDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
str[iChar - 1] = '\0';
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
if(aRealArray->ID() != TDataStd_RealArray::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aRealArray->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_RealListDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "reallistattguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_RealListDriver
|
||||
//purpose : Constructor
|
||||
@@ -52,8 +52,8 @@ Handle(TDF_Attribute) XmlMDataStd_RealListDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_RealListDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Real aValue;
|
||||
Standard_Integer aFirstInd, aLastInd, ind;
|
||||
@@ -123,6 +123,16 @@ Standard_Boolean XmlMDataStd_RealListDriver::Paste(const XmlObjMgt_Persistent&
|
||||
}
|
||||
}
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_RealList::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
aRealList->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -131,8 +141,8 @@ Standard_Boolean XmlMDataStd_RealListDriver::Paste(const XmlObjMgt_Persistent&
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMDataStd_RealListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
const Handle(TDataStd_RealList) aRealList = Handle(TDataStd_RealList)::DownCast(theSource);
|
||||
|
||||
@@ -153,4 +163,12 @@ void XmlMDataStd_RealListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
}
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
|
||||
if(aRealList->ID() != TDataStd_RealList::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aRealList->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ReferenceArrayDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
IMPLEMENT_DOMSTRING (ExtString, "string")
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "refarrattguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_ReferenceArrayDriver
|
||||
//purpose : Constructor
|
||||
@@ -55,8 +55,8 @@ Handle(TDF_Attribute) XmlMDataStd_ReferenceArrayDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_ReferenceArrayDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
@@ -113,8 +113,8 @@ Standard_Boolean XmlMDataStd_ReferenceArrayDriver::Paste(const XmlObjMgt_Persist
|
||||
if (XmlObjMgt::GetTagEntryString (aValueStr, anEntry) == Standard_False)
|
||||
{
|
||||
TCollection_ExtendedString aMessage =
|
||||
TCollection_ExtendedString ("Cannot retrieve reference from \"")
|
||||
+ aValueStr + '\"';
|
||||
TCollection_ExtendedString ("Cannot retrieve reference from \"")
|
||||
+ aValueStr + '\"';
|
||||
WriteMessage (aMessage);
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ Standard_Boolean XmlMDataStd_ReferenceArrayDriver::Paste(const XmlObjMgt_Persist
|
||||
{
|
||||
TCollection_ExtendedString aMessage =
|
||||
TCollection_ExtendedString ("Cannot retrieve reference from \"")
|
||||
+ aValueStr + '\"';
|
||||
+ aValueStr + '\"';
|
||||
WriteMessage (aMessage);
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -153,6 +153,16 @@ Standard_Boolean XmlMDataStd_ReferenceArrayDriver::Paste(const XmlObjMgt_Persist
|
||||
}
|
||||
aReferenceArray->SetValue(i, tLab);
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_ReferenceArray::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
aReferenceArray->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -161,8 +171,8 @@ Standard_Boolean XmlMDataStd_ReferenceArrayDriver::Paste(const XmlObjMgt_Persist
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMDataStd_ReferenceArrayDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_ReferenceArray) aReferenceArray = Handle(TDataStd_ReferenceArray)::DownCast(theSource);
|
||||
TDF_Label L = aReferenceArray->Label();
|
||||
@@ -195,4 +205,11 @@ void XmlMDataStd_ReferenceArrayDriver::Paste(const Handle(TDF_Attribute)& theSou
|
||||
anElement.appendChild( aCurTarget );
|
||||
}
|
||||
}
|
||||
if(aReferenceArray->ID() != TDataStd_ReferenceArray::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aReferenceArray->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ReferenceListDriver,XmlMDF_ADriver)
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
IMPLEMENT_DOMSTRING (LastIndexString, "last")
|
||||
IMPLEMENT_DOMSTRING (ExtString, "string")
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "reflistattguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_ReferenceListDriver
|
||||
//purpose : Constructor
|
||||
@@ -56,8 +56,8 @@ Handle(TDF_Attribute) XmlMDataStd_ReferenceListDriver::NewEmpty() const
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
@@ -87,47 +87,45 @@ Standard_Boolean XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persiste
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if(aLastInd == 0) return Standard_True;
|
||||
const Handle(TDataStd_ReferenceList) aReferenceList = Handle(TDataStd_ReferenceList)::DownCast(theTarget);
|
||||
|
||||
if (!anElement.hasChildNodes())
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve a list of reference");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
if(aLastInd > 0) {
|
||||
if (!anElement.hasChildNodes())
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve a list of reference");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
LDOM_Node aCurNode = anElement.getFirstChild();
|
||||
LDOM_Element* aCurElement = (LDOM_Element*)&aCurNode;
|
||||
XmlObjMgt_DOMString aValueStr;
|
||||
while (*aCurElement != anElement.getLastChild())
|
||||
{
|
||||
aValueStr = XmlObjMgt::GetStringValue( *aCurElement );
|
||||
if (aValueStr == NULL)
|
||||
LDOM_Node aCurNode = anElement.getFirstChild();
|
||||
LDOM_Element* aCurElement = (LDOM_Element*)&aCurNode;
|
||||
XmlObjMgt_DOMString aValueStr;
|
||||
while (*aCurElement != anElement.getLastChild())
|
||||
{
|
||||
WriteMessage ("Cannot retrieve reference string from element");
|
||||
return Standard_False;
|
||||
aValueStr = XmlObjMgt::GetStringValue( *aCurElement );
|
||||
if (aValueStr == NULL)
|
||||
{
|
||||
WriteMessage ("Cannot retrieve reference string from element");
|
||||
return Standard_False;
|
||||
}
|
||||
TCollection_AsciiString anEntry;
|
||||
if (XmlObjMgt::GetTagEntryString (aValueStr, anEntry) == Standard_False)
|
||||
{
|
||||
TCollection_ExtendedString aMessage =
|
||||
TCollection_ExtendedString ("Cannot retrieve reference from \"")
|
||||
+ aValueStr + '\"';
|
||||
WriteMessage (aMessage);
|
||||
return Standard_False;
|
||||
}
|
||||
// Find label by entry
|
||||
TDF_Label tLab; // Null label.
|
||||
if (anEntry.Length() > 0)
|
||||
TDF_Tool::Label(aReferenceList->Label().Data(), anEntry, tLab, Standard_True);
|
||||
|
||||
aReferenceList->Append(tLab);
|
||||
aCurNode = aCurElement->getNextSibling();
|
||||
aCurElement = (LDOM_Element*)&aCurNode;
|
||||
}
|
||||
TCollection_AsciiString anEntry;
|
||||
if (XmlObjMgt::GetTagEntryString (aValueStr, anEntry) == Standard_False)
|
||||
{
|
||||
TCollection_ExtendedString aMessage =
|
||||
TCollection_ExtendedString ("Cannot retrieve reference from \"")
|
||||
+ aValueStr + '\"';
|
||||
WriteMessage (aMessage);
|
||||
return Standard_False;
|
||||
}
|
||||
// Find label by entry
|
||||
TDF_Label tLab; // Null label.
|
||||
if (anEntry.Length() > 0)
|
||||
{
|
||||
TDF_Tool::Label(aReferenceList->Label().Data(), anEntry, tLab, Standard_True);
|
||||
}
|
||||
aReferenceList->Append(tLab);
|
||||
aCurNode = aCurElement->getNextSibling();
|
||||
aCurElement = (LDOM_Element*)&aCurNode;
|
||||
}
|
||||
|
||||
// Last reference
|
||||
aValueStr = XmlObjMgt::GetStringValue( *aCurElement );
|
||||
@@ -152,6 +150,16 @@ Standard_Boolean XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persiste
|
||||
TDF_Tool::Label(aReferenceList->Label().Data(), anEntry, tLab, Standard_True);
|
||||
}
|
||||
aReferenceList->Append(tLab);
|
||||
}
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_ReferenceList::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
aReferenceList->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -161,8 +169,8 @@ Standard_Boolean XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persiste
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMDataStd_ReferenceListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
const Handle(TDataStd_ReferenceList) aReferenceList = Handle(TDataStd_ReferenceList)::DownCast(theSource);
|
||||
TDF_Label L = aReferenceList->Label();
|
||||
@@ -194,4 +202,12 @@ void XmlMDataStd_ReferenceListDriver::Paste(const Handle(TDF_Attribute)& theSour
|
||||
anElement.appendChild( aCurTarget );
|
||||
}
|
||||
}
|
||||
|
||||
if(aReferenceList->ID() != TDataStd_ReferenceList::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aReferenceList->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user