// commercial license or contractual agreement.
-#include <CDM_MessageDriver.hxx>
+#include <Message_Messenger.hxx>
#include <LDOM_MemManager.hxx>
#include <Standard_Type.hxx>
#include <TDataStd_ExtStringArray.hxx>
#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")
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.
//=======================================================================
XmlMDataStd_ExtStringArrayDriver::XmlMDataStd_ExtStringArrayDriver
- ( const Handle(CDM_MessageDriver)& theMsgDriver )
+ ( const Handle(Message_Messenger)& theMsgDriver )
: XmlMDF_ADriver( theMsgDriver, NULL )
{}
//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;
TCollection_ExtendedString("Cannot retrieve the first index"
" for ExtStringArray attribute as \"")
+ aFirstIndex + "\"";
- WriteMessage (aMessageString);
+ myMessageDriver->Send (aMessageString, Message_Fail);
return Standard_False;
}
TCollection_ExtendedString("Cannot retrieve the last index"
" for ExtStringArray attribute as \"")
+ aFirstIndex + "\"";
- WriteMessage (aMessageString);
+ myMessageDriver->Send (aMessageString, Message_Fail);
return Standard_False;
}
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 + "\"";
+ myMessageDriver->Send (aMessageString, Message_Fail);
+ return Standard_False;
}
else
- aDelta = (Standard_Boolean)aDeltaValue;
+ aDelta = aDeltaValue != 0;
}
#ifdef OCCT_DEBUG
else if(XmlMDataStd::DocumentVersion() == -1)
#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;
}
if (aL != 1) anElement.setAttribute(::FirstIndexString(), aL);
anElement.setAttribute(::LastIndexString(), anU);
- anElement.setAttribute(::IsDeltaOn(), aExtStringArray->GetDelta());
+ anElement.setAttribute(::IsDeltaOn(), aExtStringArray->GetDelta() ? 1 : 0);
// Find a separator.
Standard_Boolean found(Standard_True);
- // Preferrable symbols for the separator: - _ . : ^ ~
- // Don't use a space as a separator: XML low-level parser sometimes "eats" it.
+ // This improvement was defined in the version 8.
+ // So, if the user wants to save the document under the 7th or earlier versions,
+ // don't apply this improvement.
Standard_Character c = '-';
- 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)
+ if (XmlLDrivers::StorageVersion() > 7)
{
- c = '!';
- while (found && c < '~')
+ // 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++)
{
- found = Standard_False;
+ 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;
#ifdef _DEBUG
- TCollection_AsciiString cseparator(c); // deb
+ TCollection_AsciiString cseparator(c); // deb
#endif
- TCollection_ExtendedString separator(c);
- found = Contains(aExtStringArray, separator);
- if (found)
- {
- c++;
- // Skip forbidden symbols for XML.
- while (c < '~' && (c == '&' || c == '<'))
+ TCollection_ExtendedString separator(c);
+ found = Contains(aExtStringArray, separator);
+ if (found)
{
c++;
+ // Skip forbidden symbols for XML.
+ while (c < '~' && (c == '&' || c == '<'))
+ {
+ c++;
+ }
}
}
}
- }
+ }// check doc version
if (found)
{
// 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);
+ }
}