return 1;
}
+//=======================================================================
+//function : DDataStd_InsertBeforeExtStringList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertBeforeExtStringList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_ExtStringList) A;
+ if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+ TCollection_ExtendedString value = arg[4];
+
+ if (A->InsertBefore(index, value))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertBeforeExtStringList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertAfterExtStringList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertAfterExtStringList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_ExtStringList) A;
+ if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+ TCollection_ExtendedString value = arg[4];
+
+ if (A->InsertAfter(index, value))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertAfterExtStringList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_RemoveExtStringList (DF, entry, index )
+//=======================================================================
+static Standard_Integer DDataStd_RemoveExtStringList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 4)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_ExtStringList) A;
+ if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+
+ if (A->Remove(index))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_RemoveExtStringList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertBeforeBooleanList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertBeforeBooleanList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_BooleanList) A;
+ if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+ Standard_Boolean value = (Standard_Boolean) Draw::Atoi(arg[4]);
+
+ if (A->InsertBefore(index, value))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertBeforeBooleanList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertAfterBooleanList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertAfterBooleanList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_BooleanList) A;
+ if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+ Standard_Boolean value = (Standard_Boolean) Draw::Atoi(arg[4]);
+
+ if (A->InsertAfter(index, value))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertAfterBooleanList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_RemoveBooleanList (DF, entry, index )
+//=======================================================================
+static Standard_Integer DDataStd_RemoveBooleanList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 4)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_BooleanList) A;
+ if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+
+ if (A->Remove(index))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_RemoveBooleanList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertBeforeIntegerList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertBeforeIntegerList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_IntegerList) A;
+ if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+ Standard_Integer value = (Standard_Integer) Draw::Atoi(arg[4]);
+
+ if (A->InsertBeforeByIndex(index, value))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertBeforeIntegerList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertAfterIntegerList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertAfterIntegerList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_IntegerList) A;
+ if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+ Standard_Integer value = (Standard_Integer) Draw::Atoi(arg[4]);
+
+ if (A->InsertAfterByIndex(index, value))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertAfterIntegerList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_RemoveIntegerList (DF, entry, index )
+//=======================================================================
+static Standard_Integer DDataStd_RemoveIntegerList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 4)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_IntegerList) A;
+ if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+
+ if (A->RemoveByIndex(index))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_RemoveIntegerList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertBeforeRealList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertBeforeRealList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_RealList) A;
+ if (!label.FindAttribute(TDataStd_RealList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+ Standard_Real value = (Standard_Real) Draw::Atof(arg[4]);
+
+ if (A->InsertBeforeByIndex(index, value))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertBeforeRealList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertAfterRealList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertAfterRealList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_RealList) A;
+ if (!label.FindAttribute(TDataStd_RealList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+ Standard_Real value = (Standard_Real) Draw::Atof(arg[4]);
+
+ if (A->InsertAfterByIndex(index, value))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertAfterRealList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_RemoveRealList (DF, entry, index )
+//=======================================================================
+static Standard_Integer DDataStd_RemoveRealList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 4)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_RealList) A;
+ if (!label.FindAttribute(TDataStd_RealList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+
+ if (A->RemoveByIndex(index))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_RemoveRealList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertBeforeReferenceList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertBeforeReferenceList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_ReferenceList) A;
+ if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+
+ TDF_Label refLabel;
+ if (!DDF::AddLabel(DF, arg[4], refLabel))
+ return 1;
+
+ if (A->InsertBefore(index, refLabel))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertBeforeReferenceList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_InsertAfterReferenceList (DF, entry, index, value )
+//=======================================================================
+static Standard_Integer DDataStd_InsertAfterReferenceList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 5)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_ReferenceList) A;
+ if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+
+ TDF_Label refLabel;
+ if (!DDF::AddLabel(DF, arg[4], refLabel))
+ return 1;
+
+ if (A->InsertAfter(index, refLabel))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_InsertAfterReferenceList: Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_RemoveReferenceList (DF, entry, index )
+//=======================================================================
+static Standard_Integer DDataStd_RemoveReferenceList (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 4)
+ {
+ Handle(TDF_Data) DF;
+ if (!DDF::GetDF(arg[1],DF))
+ return 1;
+
+ TDF_Label label;
+ DDF::AddLabel(DF, arg[2], label);
+
+ Handle(TDataStd_ReferenceList) A;
+ if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A))
+ return 1;
+
+ Standard_Integer index = Draw::Atoi(arg[3]);
+
+ if (A->Remove(index))
+ return 0;
+ else
+ return 1;
+ }
+ di << "DDataStd_RemoveReferenceList: Error\n";
+ return 1;
+}
+
//=======================================================================
//function : GetByteArray (DF, entry )
//=======================================================================
"SetReferenceList (DF, entry, elmt1, elmt2, ... )",
__FILE__, DDataStd_SetReferenceList, g);
+ theCommands.Add ("InsertBeforeExtStringList",
+ "InsertBeforeExtStringList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertBeforeExtStringList, g);
+
+ theCommands.Add ("InsertAfterExtStringList",
+ "InsertAfterExtStringList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertAfterExtStringList, g);
+
+ theCommands.Add ("RemoveExtStringList",
+ "RemoveExtStringList (DF, entry, index )",
+ __FILE__, DDataStd_RemoveExtStringList, g);
+
+ theCommands.Add ("InsertBeforeBooleanList",
+ "InsertBeforeBooleanList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertBeforeBooleanList, g);
+
+ theCommands.Add ("InsertAfterBooleanList",
+ "InsertAfterBooleanList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertAfterBooleanList, g);
+
+ theCommands.Add ("RemoveBooleanList",
+ "RemoveBooleanList (DF, entry, index )",
+ __FILE__, DDataStd_RemoveBooleanList, g);
+
+ theCommands.Add ("InsertBeforeIntegerList",
+ "InsertBeforeIntegerList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertBeforeIntegerList, g);
+
+ theCommands.Add ("InsertAfterIntegerList",
+ "InsertAfterIntegerList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertAfterIntegerList, g);
+
+ theCommands.Add ("RemoveIntegerList",
+ "RemoveIntegerList (DF, entry, index )",
+ __FILE__, DDataStd_RemoveIntegerList, g);
+
+ theCommands.Add ("InsertBeforeRealList",
+ "InsertBeforeRealList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertBeforeRealList, g);
+
+ theCommands.Add ("InsertAfterRealList",
+ "InsertAfterRealList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertAfterRealList, g);
+
+ theCommands.Add ("RemoveRealList",
+ "RemoveRealList (DF, entry, index )",
+ __FILE__, DDataStd_RemoveRealList, g);
+
+ theCommands.Add ("InsertBeforeReferenceList",
+ "InsertBeforeReferenceList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertBeforeReferenceList, g);
+
+ theCommands.Add ("InsertAfterReferenceList",
+ "InsertAfterReferenceList (DF, entry, index, value )",
+ __FILE__, DDataStd_InsertAfterReferenceList, g);
+
+ theCommands.Add ("RemoveReferenceList",
+ "RemoveReferenceList (DF, entry, index )",
+ __FILE__, DDataStd_RemoveReferenceList, g);
+
// GET
theCommands.Add ("GetAsciiString",
--- /dev/null
+# =================== OCAF ======================
+# Standard attributes of List containers (xml format)
+#
+# Testing purpose: test of InsertBefore / InsertAfter / Remove
+# of TDataStd_BooleanList, TDataStd_IntegerList
+# TDataStd_RealList, TDataStd_ExtStringList,
+# TDataStd_ReferenceList attributes
+#
+# ===============================================
+# Test case:
+# 1. create BooleanList attribute with empty list
+# 2. create IntegerList attribute with empty list
+# 3. create RealList attribute with empty list
+# 4. create ExtStringList attribute with empty list
+# 5. create ReferenceList attribute with empty list
+# 6. insert before a value
+# 7. insert after a value
+# 8. remove a value
+# 9. check the values
+# ===============================================
+
+NewDocument D XmlOcaf
+# 1. create BooleanList attribute
+set Lab1 [Label D 0:1:1]
+SetBooleanList D $Lab1 0 0 1 0
+set info1 [GetBooleanList D $Lab1]
+# output => "0 0 1 0"
+
+# 2. create IntegerList attribute
+set Lab2 [Label D 0:1:2]
+SetIntegerList D $Lab2 0 0 1 0
+set info2 [GetIntegerList D $Lab2]
+# output => "0 0 1 0"
+
+# 3. create RealList attribute
+set Lab3 [Label D 0:1:3]
+SetRealList D $Lab3 0 0 1 0
+set info3 [GetRealList D $Lab3]
+# output => "0 0 1 0"
+
+# 4. create ExtStringList attribute
+set Lab4 [Label D 0:1:4]
+SetExtStringList D $Lab4 0 0 1 0
+set info4 [GetExtStringList D $Lab4]
+# output => "0 0 1 0"
+
+# 5. create ReferenceList attribute
+set Lab5 [Label D 0:1:5]
+SetReferenceList D $Lab5 $Lab1 $Lab2 $Lab4
+set info5 [GetReferenceList D $Lab5]
+# output => "0:1:1 0:1:2 0:1:4"
+
+# 6. insert before a value
+InsertBeforeBooleanList D $Lab1 3 1
+InsertBeforeIntegerList D $Lab2 3 1
+InsertBeforeRealList D $Lab3 3 1
+InsertBeforeExtStringList D $Lab4 3 1
+InsertBeforeReferenceList D $Lab5 3 0:1:3
+# output => "0 0 1 1 0"
+# output => "0:1:1 0:1:2 0:1:3 0:1:4"
+
+# 7. insert after a value
+InsertAfterBooleanList D $Lab1 4 1
+InsertAfterIntegerList D $Lab2 4 1
+InsertAfterRealList D $Lab3 4 1
+InsertAfterExtStringList D $Lab4 4 1
+InsertAfterReferenceList D $Lab5 4 0:1:5
+# output => "0 0 1 1 1 0"
+# output => "0:1:1 0:1:2 0:1:3 0:1:4 0:1:5"
+
+# 8. remove a value
+RemoveBooleanList D $Lab1 6
+RemoveIntegerList D $Lab2 6
+RemoveRealList D $Lab3 6
+RemoveExtStringList D $Lab4 6
+RemoveReferenceList D $Lab5 1
+# output => "0 0 1 1 1"
+# output => "0:1:2 0:1:3 0:1:4 0:1:5"
+
+# 8. Check the values
+set info6 [GetBooleanList D $Lab1]
+set info7 [GetIntegerList D $Lab2]
+set info8 [GetRealList D $Lab3]
+set info9 [GetExtStringList D $Lab4]
+set info10 [GetReferenceList D $Lab5]
+# output => "0 0 1 1 1"
+# output => "0:1:2 0:1:3 0:1:4 0:1:5"
+
+Close D
+
+if { [regexp {0 0 1 1 1} ${info6}] } {
+ puts "OK: inserted and removed values for BooleanList attribute are good"
+} else {
+ puts "Error: inserted and removed values for BooleanList attribute are bad"
+}
+
+if { [regexp {0 0 1 1 1} ${info7}] } {
+ puts "OK: inserted and removed values for IntegerList attribute are good"
+} else {
+ puts "Error: inserted and removed values for IntegerList attribute are bad"
+}
+
+if { [regexp {0 0 1 1 1} ${info8}] } {
+ puts "OK: inserted and removed values for RealList attribute are good"
+} else {
+ puts "Error: inserted and removed values for RealList attribute are bad"
+}
+
+if { [regexp {0 0 1 1 1} ${info9}] } {
+ puts "OK: inserted and removed values for ExtStringList attribute are good"
+} else {
+ puts "Error: inserted and removed values for ExtStringList attribute are bad"
+}
+
+if { [regexp {0:1:2 0:1:3 0:1:4 0:1:5} ${info10}] } {
+ puts "OK: inserted and removed values for ReferenceList attribute are good"
+} else {
+ puts "Error: inserted and removed values for ReferenceList attribute are bad"
+}