mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0025394: Make it possible to store/retrieve the list-based attributes containing no items
Attention! It is not a complete patch. First patch for Binary schema. Fix for Xml schema. Patch for the standard schema. Added new Draw commands to test ExtStringList & ReferenceList attributes. Fix of a small bug in ReferenceListDriver & improvement of Draw Get commands. Replace tabs with spaces in newly added lines. Test cases for issue CR25394
This commit is contained in:
@@ -77,8 +77,9 @@ Standard_Boolean XmlMDataStd_BooleanListDriver::Paste(const XmlObjMgt_Persistent
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(TDataStd_BooleanList) aBooleanList = Handle(TDataStd_BooleanList)::DownCast(theTarget);
|
||||
if (aFirstInd == aLastInd)
|
||||
const Handle(TDataStd_BooleanList) aBooleanList = Handle(TDataStd_BooleanList)::DownCast(theTarget);
|
||||
if(aLastInd == 0) aFirstInd = 0;
|
||||
if (aFirstInd == aLastInd && aLastInd > 0)
|
||||
{
|
||||
Standard_Integer anInteger;
|
||||
if (!XmlObjMgt::GetStringValue(anElement).GetInteger(anInteger))
|
||||
@@ -91,7 +92,7 @@ Standard_Boolean XmlMDataStd_BooleanListDriver::Paste(const XmlObjMgt_Persistent
|
||||
}
|
||||
aBooleanList->Append(anInteger ? Standard_True : Standard_False);
|
||||
}
|
||||
else
|
||||
else if(aLastInd >= 1)
|
||||
{
|
||||
Standard_CString aValueStr = Standard_CString(XmlObjMgt::GetStringValue(anElement).GetString());
|
||||
for (ind = aFirstInd; ind <= aLastInd; ind++)
|
||||
@@ -120,21 +121,22 @@ void XmlMDataStd_BooleanListDriver::Paste(const Handle(TDF_Attribute)& theSource
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_BooleanList) aBooleanList = Handle(TDataStd_BooleanList)::DownCast(theSource);
|
||||
const Handle(TDataStd_BooleanList) aBooleanList = Handle(TDataStd_BooleanList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = aBooleanList->Extent();
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
if (anU >= 1)
|
||||
// Allocation of 1 char for each boolean value + a space.
|
||||
NCollection_LocalArray<Standard_Character> str(2 * anU + 1);
|
||||
if(anU == 0) str[0] = 0;
|
||||
else 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);
|
||||
Standard_Integer iChar(0);
|
||||
TDataStd_ListIteratorOfListOfByte itr(aBooleanList->List());
|
||||
for (; itr.More(); itr.Next())
|
||||
{
|
||||
const Standard_Byte& byte = itr.Value();
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", byte);
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
|
@@ -79,7 +79,8 @@ Standard_Boolean XmlMDataStd_ExtStringListDriver::Paste(const XmlObjMgt_Persiste
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(TDataStd_ExtStringList) anExtStringList = Handle(TDataStd_ExtStringList)::DownCast(theTarget);
|
||||
if(aLastInd == 0) return Standard_True;
|
||||
const Handle(TDataStd_ExtStringList) anExtStringList = Handle(TDataStd_ExtStringList)::DownCast(theTarget);
|
||||
|
||||
if (!anElement.hasChildNodes())
|
||||
{
|
||||
@@ -114,7 +115,7 @@ void XmlMDataStd_ExtStringListDriver::Paste(const Handle(TDF_Attribute)& theSour
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_ExtStringList) anExtStringList = Handle(TDataStd_ExtStringList)::DownCast(theSource);
|
||||
const Handle(TDataStd_ExtStringList) anExtStringList = Handle(TDataStd_ExtStringList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = anExtStringList->Extent();
|
||||
XmlObjMgt_Element& anElement = theTarget;
|
||||
|
@@ -77,8 +77,9 @@ Standard_Boolean XmlMDataStd_IntegerListDriver::Paste(const XmlObjMgt_Persistent
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(TDataStd_IntegerList) anIntList = Handle(TDataStd_IntegerList)::DownCast(theTarget);
|
||||
if (aFirstInd == aLastInd)
|
||||
const Handle(TDataStd_IntegerList) anIntList = Handle(TDataStd_IntegerList)::DownCast(theTarget);
|
||||
if(aLastInd == 0) aFirstInd = 0;
|
||||
if (aFirstInd == aLastInd && aLastInd > 0)
|
||||
{
|
||||
Standard_Integer anInteger;
|
||||
if (!XmlObjMgt::GetStringValue(anElement).GetInteger(anInteger))
|
||||
@@ -91,7 +92,7 @@ Standard_Boolean XmlMDataStd_IntegerListDriver::Paste(const XmlObjMgt_Persistent
|
||||
}
|
||||
anIntList->Append(anInteger);
|
||||
}
|
||||
else
|
||||
else if(aLastInd >= 1)
|
||||
{
|
||||
Standard_CString aValueStr = Standard_CString(XmlObjMgt::GetStringValue(anElement).GetString());
|
||||
for (ind = aFirstInd; ind <= aLastInd; ind++)
|
||||
@@ -120,24 +121,25 @@ void XmlMDataStd_IntegerListDriver::Paste(const Handle(TDF_Attribute)& theSource
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_IntegerList) anIntList = Handle(TDataStd_IntegerList)::DownCast(theSource);
|
||||
const Handle(TDataStd_IntegerList) anIntList = Handle(TDataStd_IntegerList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = anIntList->Extent();
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
if (anU >= 1)
|
||||
NCollection_LocalArray<Standard_Character> str(12 * anU + 1);
|
||||
if(anU == 0)
|
||||
str[0] = 0;
|
||||
else 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())
|
||||
{
|
||||
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, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
|
@@ -78,13 +78,13 @@ Standard_Boolean XmlMDataStd_RealListDriver::Paste(const XmlObjMgt_Persistent&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(TDataStd_RealList) aRealList = Handle(TDataStd_RealList)::DownCast(theTarget);
|
||||
|
||||
const Handle(TDataStd_RealList) aRealList = Handle(TDataStd_RealList)::DownCast(theTarget);
|
||||
// Check the type of LDOMString
|
||||
const XmlObjMgt_DOMString& aString = XmlObjMgt::GetStringValue(anElement);
|
||||
if(aLastInd == 0) aFirstInd = 0;
|
||||
if (aString.Type() == LDOMBasicString::LDOM_Integer)
|
||||
{
|
||||
if (aFirstInd == aLastInd)
|
||||
if (aFirstInd == aLastInd && aLastInd > 0)
|
||||
{
|
||||
Standard_Integer anIntValue;
|
||||
if (aString.GetInteger(anIntValue))
|
||||
@@ -100,7 +100,7 @@ Standard_Boolean XmlMDataStd_RealListDriver::Paste(const XmlObjMgt_Persistent&
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(aLastInd >= 1)
|
||||
{
|
||||
Standard_CString aValueStr = Standard_CString(aString.GetString());
|
||||
for (ind = aFirstInd; ind <= aLastInd; ind++)
|
||||
@@ -128,22 +128,23 @@ void XmlMDataStd_RealListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_RealList) aRealList = Handle(TDataStd_RealList)::DownCast(theSource);
|
||||
const Handle(TDataStd_RealList) aRealList = Handle(TDataStd_RealList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = aRealList->Extent();
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
if (anU >= 1)
|
||||
{
|
||||
// Allocation of 25 chars for each double value including the space:
|
||||
// An example: -3.1512678732195273e+020
|
||||
// Allocation of 25 chars for each double value including the space:
|
||||
// An example: -3.1512678732195273e+020
|
||||
NCollection_LocalArray<Standard_Character> str(25 * anU + 1);
|
||||
if(anU == 0) str[0] = 0;
|
||||
else if (anU >= 1)
|
||||
{
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str(25 * anU + 1);
|
||||
TColStd_ListIteratorOfListOfReal itr(aRealList->List());
|
||||
for (; itr.More(); itr.Next())
|
||||
{
|
||||
const Standard_Real& realValue = itr.Value();
|
||||
iChar += Sprintf(&(str[iChar]), "%.17g ", realValue);
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
|
@@ -82,7 +82,8 @@ Standard_Boolean XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persiste
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(TDataStd_ReferenceList) aReferenceList = Handle(TDataStd_ReferenceList)::DownCast(theTarget);
|
||||
if(aLastInd == 0) return Standard_True;
|
||||
const Handle(TDataStd_ReferenceList) aReferenceList = Handle(TDataStd_ReferenceList)::DownCast(theTarget);
|
||||
|
||||
if (!anElement.hasChildNodes())
|
||||
{
|
||||
@@ -107,8 +108,8 @@ Standard_Boolean XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persiste
|
||||
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;
|
||||
}
|
||||
@@ -134,8 +135,8 @@ Standard_Boolean XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persiste
|
||||
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;
|
||||
}
|
||||
@@ -158,7 +159,7 @@ void XmlMDataStd_ReferenceListDriver::Paste(const Handle(TDF_Attribute)& theSour
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_ReferenceList) aReferenceList = Handle(TDataStd_ReferenceList)::DownCast(theSource);
|
||||
const Handle(TDataStd_ReferenceList) aReferenceList = Handle(TDataStd_ReferenceList)::DownCast(theSource);
|
||||
TDF_Label L = aReferenceList->Label();
|
||||
if (L.IsNull())
|
||||
{
|
||||
@@ -169,7 +170,7 @@ void XmlMDataStd_ReferenceListDriver::Paste(const Handle(TDF_Attribute)& theSour
|
||||
Standard_Integer anU = aReferenceList->Extent();
|
||||
XmlObjMgt_Element& anElement = theTarget;
|
||||
anElement.setAttribute(::LastIndexString(), anU);
|
||||
|
||||
if(anU == 0) return;
|
||||
XmlObjMgt_Document aDoc = anElement.getOwnerDocument().Doc();
|
||||
|
||||
TDF_ListIteratorOfLabelList itr(aReferenceList->List());
|
||||
|
Reference in New Issue
Block a user