#include <TDataStd_ReferenceList.hxx>
#include <TDF_ListIteratorOfLabelList.hxx>
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
+
+#include <algorithm>
+#include <vector>
+
#define MAXLENGTH 10
//#define DEB_DDataStd
TCollection_ExtendedString aKey(itr.Key());
TCollection_AsciiString aStr(aKey,'?');
Standard_Integer aValue = itr.Value();
- std::cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<std::endl;
+ di << "Key = " << aStr.ToCString() << " Value = " << aValue << "\n";
}
return 0;
TCollection_ExtendedString aKey(itr.Key());
TCollection_AsciiString aStr(aKey,'?');
Standard_Real aValue = itr.Value();
- std::cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<std::endl;
+ di << "Key = " << aStr.ToCString() << " Value = " << aValue << "\n";
}
return 0;
}
//=======================================================================
//function : GetNDStrings(DF, entry )
//=======================================================================
+namespace
+{
+ typedef std::pair<TCollection_ExtendedString, TCollection_ExtendedString>
+ DDataStd_GetNDStrings_Property;
+
+ bool isLess(
+ const DDataStd_GetNDStrings_Property& theProperty1,
+ const DDataStd_GetNDStrings_Property& theProperty2)
+ {
+ return theProperty1.first.IsLess(theProperty2.first);
+ }
+}
+
static Standard_Integer DDataStd_GetNDStrings (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
anAtt->LoadDeferredData();
const TDataStd_DataMapOfStringString& aMap = anAtt->GetStringsContainer();
- TDataStd_DataMapIteratorOfDataMapOfStringString itr(aMap);
- for (; itr.More(); itr.Next()){
- TCollection_ExtendedString aKey(itr.Key());
- TCollection_AsciiString aStr(aKey,'?');
- TCollection_ExtendedString aVal(itr.Value());
- TCollection_AsciiString aStrValue(aVal,'?');
- std::cout << "Key = " << aStr.ToCString() << " Value = " <<aStrValue.ToCString()<< std::endl;
- }
- return 0;
+
+ std::vector<DDataStd_GetNDStrings_Property> aProperties;
+ for (TDataStd_DataMapIteratorOfDataMapOfStringString aIt (aMap); aIt.More(); aIt.Next())
+ {
+ aProperties.push_back(DDataStd_GetNDStrings_Property (aIt.Key(), aIt.Value()));
+ }
+ std::sort (aProperties.begin(), aProperties.end(), isLess);
+
+ for (std::vector<DDataStd_GetNDStrings_Property>::size_type aI = 0; aI < aProperties.size(); ++aI)
+ {
+ di << "Key = " << aProperties[aI].first << " Value = " << aProperties[aI].second << "\n";
+ }
+
+ return 0;
}
di << "DDataStd_GetNDStrings : Error\n";
return 1;
} else {
puts "Error: center of gravity ($comp_x, $comp_y, $comp_z) is not equal to expected ($x, $y, $z)"
}
-}
\ No newline at end of file
+}
+
+help checkMultilineStrings {
+ Compares two strings.
+ Logically splits the strings to lines by the new line characters.
+ Outputs the first different lines.
+
+ Use: checkMultilineStrings <string_1> <string_2>
+}
+proc checkMultilineStrings {tS1 tS2} {
+ set aL1 [split $tS1 \n]
+ set aL2 [split $tS2 \n]
+
+ set aC1 [llength $aL1]
+ set aC2 [llength $aL2]
+ set aC [expr {min($aC1, $aC2)}]
+
+ for {set aI 0} {$aI < $aC} {incr aI} {
+ if {[lindex $aL1 $aI] != [lindex $aL2 $aI]} {
+ puts "Error. $aI-th lines are different:"
+ puts "[lindex $aL1 $aI]"
+ puts "[lindex $aL2 $aI]"
+ }
+ }
+
+ if {$aC1 != $aC2} {
+ puts "Error. Line counts are different: $aC1 != $aC2."
+ }
+}