]> OCCT Git - occt.git/commitdiff
0033470: Application Framework - TDataStd_NamedData HasSmth() methods return true...
authorika <ika@opencascade.com>
Thu, 7 Sep 2023 14:02:05 +0000 (15:02 +0100)
committerjokwajeb <jokwajeb@opencascade.com>
Fri, 22 Sep 2023 13:35:53 +0000 (14:35 +0100)
Add checks for empty containers.

src/TDataStd/TDataStd_NamedData.cxx
src/TDataStd/TDataStd_NamedData.hxx

index 92340a44ad17cf3562231158e2dfe4805ef19dfa..1e38c0670703f8401e0f13efd0ce8268583e66a0 100644 (file)
@@ -86,6 +86,15 @@ void TDataStd_NamedData::clear()
 
 //Category: Integers
 
+//=======================================================================
+//function : HasIntegers
+//purpose  : Returns true if at least one named integer value is kept in the attribute.
+//=======================================================================
+Standard_Boolean TDataStd_NamedData::HasIntegers() const
+{
+  return !myIntegers.IsNull() && !myIntegers->Map().IsEmpty();
+}
+
 //=======================================================================
 //function : HasInteger
 //purpose  : Returns true if the attribute contains this named integer.
@@ -186,6 +195,15 @@ void TDataStd_NamedData::ChangeIntegers(const TColStd_DataMapOfStringInteger& th
 //Category: Reals
 //          =====    
 
+//=======================================================================
+//function : HasReals
+//purpose  : Returns true if at least one named real value is kept in the attribute.
+//=======================================================================
+Standard_Boolean TDataStd_NamedData::HasReals() const
+{
+  return !myReals.IsNull() && !myReals->Map().IsEmpty();
+}
+
 //=======================================================================
 //function : HasReal
 //purpose  : Returns true if the attribute contains this named real.
@@ -283,6 +301,16 @@ void TDataStd_NamedData::ChangeReals(const TDataStd_DataMapOfStringReal& theReal
 
 //Category: Strings
 //          =======
+
+//=======================================================================
+//function : HasStrings
+//purpose  : Returns true if there are some named strings in the attribute.
+//=======================================================================
+Standard_Boolean TDataStd_NamedData::HasStrings() const
+{ 
+  return !myStrings.IsNull() && !myStrings->Map().IsEmpty();
+}
+
 //=======================================================================
 //function : HasString
 //purpose  : Returns true if the attribute contains this named string.
@@ -383,6 +411,16 @@ void TDataStd_NamedData::ChangeStrings(const TDataStd_DataMapOfStringString& the
 
 //Category: Bytes
 //          =====    
+
+//=======================================================================
+//function : HasBytes
+//purpose  : Returns true if there are some named bytes in the attribute.
+//=======================================================================
+Standard_Boolean TDataStd_NamedData::HasBytes() const
+{
+  return !myBytes.IsNull() && !myBytes->Map().IsEmpty();
+}
+
 //=======================================================================
 //function : HasByte
 //purpose  : Returns true if the attribute contains this named byte.
@@ -482,6 +520,16 @@ void TDataStd_NamedData::ChangeBytes(const TDataStd_DataMapOfStringByte& theByte
 
 //Category: Arrays of integers
 //          ==================
+
+//=======================================================================
+//function : HasArrayOfIntegers
+//purpose  : Returns true if there are some named arrays of integer values in the attribute.
+//=======================================================================
+Standard_Boolean TDataStd_NamedData::HasArraysOfIntegers() const
+{
+  return !myArraysOfIntegers.IsNull() && !myArraysOfIntegers->Map().IsEmpty();
+}
+
 //=======================================================================
 //function : HasArrayOfIntegers
 //purpose  : Returns true if the attribute contains this named array 
@@ -569,6 +617,16 @@ void TDataStd_NamedData::ChangeArraysOfIntegers
 
 //Category: Arrays of reals
 //          ===============
+
+//=======================================================================
+//function : HasArrayOfReals
+//purpose  : Returns true if there are some named arrays of real values in the attribute.
+//=======================================================================
+Standard_Boolean TDataStd_NamedData::HasArraysOfReals() const
+{
+  return !myArraysOfReals.IsNull() && !myArraysOfReals->Map().IsEmpty();
+}
+
 //=======================================================================
 //function : HasArrayOfReals
 //purpose  : Returns true if the attribute contains this named array of 
index e147aea23f3fb1ac14e9d1b5c709a93904c7ade7..f374893dd920151b742ed00b2e6968cebafc2c87 100644 (file)
@@ -52,7 +52,7 @@ public:
   Standard_EXPORT TDataStd_NamedData();
 
   //! Returns true if at least one named integer value is kept in the attribute.
-  Standard_Boolean HasIntegers() const { return !myIntegers.IsNull(); }
+  Standard_EXPORT Standard_Boolean HasIntegers() const;
 
   //! Returns true if the attribute contains specified by Name
   //! integer value.
@@ -74,7 +74,7 @@ public:
   Standard_EXPORT void ChangeIntegers (const TColStd_DataMapOfStringInteger& theIntegers);
 
   //! Returns true if at least one named real value is kept in the attribute.
-  Standard_Boolean HasReals() const { return !myReals.IsNull(); }
+  Standard_EXPORT Standard_Boolean HasReals() const;
 
   //! Returns true if the attribute contains a real specified by Name.
   Standard_EXPORT Standard_Boolean HasReal (const TCollection_ExtendedString& theName) const;
@@ -95,7 +95,7 @@ public:
   Standard_EXPORT void ChangeReals (const TDataStd_DataMapOfStringReal& theReals);
 
   //! Returns true if there are some named strings in the attribute.
-  Standard_Boolean HasStrings() const { return !myStrings.IsNull(); }
+  Standard_EXPORT Standard_Boolean HasStrings() const;
 
   //! Returns true if the attribute contains this named string.
   Standard_EXPORT Standard_Boolean HasString (const TCollection_ExtendedString& theName) const;
@@ -116,7 +116,7 @@ public:
   Standard_EXPORT void ChangeStrings (const TDataStd_DataMapOfStringString& theStrings);
 
   //! Returns true if there are some named bytes in the attribute.
-  Standard_Boolean HasBytes() const { return !myBytes.IsNull(); }
+  Standard_EXPORT Standard_Boolean HasBytes() const;
 
   //! Returns true if the attribute contains this named byte.
   Standard_EXPORT Standard_Boolean HasByte (const TCollection_ExtendedString& theName) const;
@@ -137,7 +137,7 @@ public:
   Standard_EXPORT void ChangeBytes (const TDataStd_DataMapOfStringByte& theBytes);
 
   //! Returns true if there are some named arrays of integer values in the attribute.
-  Standard_Boolean HasArraysOfIntegers() const { return !myArraysOfIntegers.IsNull(); }
+  Standard_EXPORT Standard_Boolean HasArraysOfIntegers() const;
 
   //! Returns true if the attribute contains this named array of integer values.
   Standard_EXPORT Standard_Boolean HasArrayOfIntegers (const TCollection_ExtendedString& theName) const;
@@ -164,7 +164,7 @@ public:
   Standard_EXPORT void ChangeArraysOfIntegers (const TDataStd_DataMapOfStringHArray1OfInteger& theArraysOfIntegers);
 
   //! Returns true if there are some named arrays of real values in the attribute.
-  Standard_Boolean HasArraysOfReals() const { return !myArraysOfReals.IsNull(); }
+  Standard_EXPORT Standard_Boolean HasArraysOfReals() const;
 
   //! Returns true if the attribute contains this named array of real values.
   Standard_EXPORT Standard_Boolean HasArrayOfReals (const TCollection_ExtendedString& theName) const;