mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0023912: TDataStd_ExtStringArray::Value() returns a copy of TCollection_ExtendedString, but it might return a reference.
Since now TDataStd_ExtStringArray::Value() returns a constant reference to the string value. Also, a draw-command GetExtStringArray is modified to manipulate with the string by a constant reference. Added test case bugs/caf/bug23912
This commit is contained in:
@@ -952,12 +952,9 @@ static Standard_Integer DDataStd_GetExtStringArray (Draw_Interpretor& di,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TCollection_ExtendedString anExtendedString;
|
|
||||||
TCollection_AsciiString anAsciiString;
|
|
||||||
for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
|
for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
|
||||||
anExtendedString = A->Value(i);
|
const TCollection_ExtendedString& anExtendedString = A->Value(i);
|
||||||
anAsciiString = TCollection_AsciiString (A->Value(i),'?');
|
TCollection_AsciiString anAsciiString(A->Value(i),'?');
|
||||||
//cout << anAsciiString.ToCString() << endl;
|
|
||||||
di << anAsciiString.ToCString();
|
di << anAsciiString.ToCString();
|
||||||
if(i<A->Upper())
|
if(i<A->Upper())
|
||||||
di<<" ";
|
di<<" ";
|
||||||
|
@@ -64,6 +64,7 @@ is
|
|||||||
Value (me; Index : Integer from Standard)
|
Value (me; Index : Integer from Standard)
|
||||||
---Purpose: Returns the value of the <Index>th element of the array
|
---Purpose: Returns the value of the <Index>th element of the array
|
||||||
--
|
--
|
||||||
|
---C++: return const &
|
||||||
---C++: alias operator ()
|
---C++: alias operator ()
|
||||||
returns ExtendedString from TCollection;
|
returns ExtendedString from TCollection;
|
||||||
|
|
||||||
|
@@ -99,18 +99,20 @@ void TDataStd_ExtStringArray::SetValue(const Standard_Integer index, const TColl
|
|||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetValue
|
//function : Value
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
TCollection_ExtendedString TDataStd_ExtStringArray::Value (const Standard_Integer index) const
|
const TCollection_ExtendedString& TDataStd_ExtStringArray::Value (const Standard_Integer index) const
|
||||||
{
|
{
|
||||||
if(myValue.IsNull()) return TCollection_ExtendedString();
|
if (myValue.IsNull())
|
||||||
return myValue->Value(index);
|
{
|
||||||
|
static TCollection_ExtendedString staticEmptyValue;
|
||||||
|
return staticEmptyValue;
|
||||||
|
}
|
||||||
|
return myValue->Value(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Lower
|
//function : Lower
|
||||||
//purpose :
|
//purpose :
|
||||||
|
24
tests/bugs/caf/bug23912
Normal file
24
tests/bugs/caf/bug23912
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "OCC23912"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
###################################################################################################################
|
||||||
|
# TDataStd_ExtStringArray::Value() returns a copy of TCollection_ExtededString, but it might return a reference
|
||||||
|
###################################################################################################################
|
||||||
|
|
||||||
|
NewDocument D
|
||||||
|
SetExtStringArray D 0:1 0 1 5 "A" "B" "C" "D" "E"
|
||||||
|
set info [GetExtStringArray D 0:1]
|
||||||
|
|
||||||
|
if { [regexp "A B C D E" $info] != 1 } {
|
||||||
|
puts "Error : function returns wrong value"
|
||||||
|
} else {
|
||||||
|
puts "OK : function works properly"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user