Introduce TCollection_AsciiString::EmptyString() and TCollection_ExtendedString::EmptyString()
and update headers.
Replace many local/static empty string instances and default-constructed
temporaries with the shared EmptyString() reference across ApplicationFramework, DataExchange,
Visualization and other modules.
Remove several unused local empty-key/static variables and
adjust default parameters and return paths to use the centralized empty-string accessors.
Add missing #include <TCollection_AsciiString.hxx> to several headers that use/forward TCollection_AsciiString.
return **aResult;
}
- static const TCollection_AsciiString anEmpty;
- return anEmpty;
+ return TCollection_AsciiString::EmptyString();
}
//=================================================================================================
{
if (myValue.IsNull())
{
- static TCollection_ExtendedString staticEmptyValue;
- return staticEmptyValue;
+ return TCollection_ExtendedString::EmptyString();
}
return myValue->Value(index);
}
const TCollection_ExtendedString& operator()(const Handle(StdObjMgt_Persistent)& theValue) const
{
- static TCollection_ExtendedString anEmptyString;
if (theValue.IsNull())
- return anEmptyString;
+ return TCollection_ExtendedString::EmptyString();
Handle(TCollection_HExtendedString) aString = theValue->ExtString();
- return aString ? aString->String() : anEmptyString;
+ return aString ? aString->String() : TCollection_ExtendedString::EmptyString();
}
};
if (theValue)
return theValue->ExtString()->String();
- static TCollection_ExtendedString anEmptyString;
- return anEmptyString;
+ return TCollection_ExtendedString::EmptyString();
}
template <class HArray>
IMPLEMENT_STANDARD_RTTIEXT(RWHeaderSection_ReadWriteModule, StepData_ReadWriteModule)
// -- General Declarations (Recognize, StepType) ---
-static TCollection_AsciiString PasReco(""); // neutralise StartEntity de SW
+// neutralise StartEntity de SW
static TCollection_AsciiString Reco_FileName("FILE_NAME");
static TCollection_AsciiString Reco_FileDescription("FILE_DESCRIPTION");
static TCollection_AsciiString Reco_FileSchema("FILE_SCHEMA");
case 3:
return Reco_FileSchema;
default:
- return PasReco;
+ return TCollection_AsciiString::EmptyString();
}
}
#include <StepData_EnumTool.hxx>
#include <TCollection_AsciiString.hxx>
-static TCollection_AsciiString nulstr("");
-
StepData_EnumTool::StepData_EnumTool(const Standard_CString e0,
const Standard_CString e1,
const Standard_CString e2,
const TCollection_AsciiString& StepData_EnumTool::Text(const Standard_Integer num) const
{
if (num < 0 || num >= thetexts.Length())
- return nulstr;
+ return TCollection_AsciiString::EmptyString();
return thetexts.Value(num + 1);
}
theTools.ShapeTool->GetReferredShape(aNewLabel, aNewRefLabel);
// put attributes to the Product (shared across Instances)
- static const TCollection_AsciiString anEmptyString;
- setShapeName(aNewRefLabel, aShapeType, aShapeAttribs.Name, TDF_Label(), anEmptyString);
+ setShapeName(aNewRefLabel,
+ aShapeType,
+ aShapeAttribs.Name,
+ TDF_Label(),
+ TCollection_AsciiString::EmptyString());
setShapeStyle(theTools, aNewRefLabel, aShapeAttribs.Style);
setShapeNamedData(theTools, aNewRefLabel, aShapeAttribs.NamedData);
myCurrent.Location = myCurrent.LocalTrsf;
myCurrent.Style =
mergedStyle(myColorTool, myVisMatTool, myDefStyle, myCurrent.Label, myCurrent.RefLabel);
- myCurrent.Id = DefineChildId(myCurrent.Label, TCollection_AsciiString());
+ myCurrent.Id = DefineChildId(myCurrent.Label, TCollection_AsciiString::EmptyString());
}
else
{
aNodeInStack.Location = aNodeInStack.LocalTrsf;
aNodeInStack.Style =
mergedStyle(myColorTool, myVisMatTool, myDefStyle, aNodeInStack.Label, aNodeInStack.RefLabel);
- aNodeInStack.Id = DefineChildId(aNodeInStack.Label, TCollection_AsciiString());
+ aNodeInStack.Id = DefineChildId(aNodeInStack.Label, TCollection_AsciiString::EmptyString());
myNodeStack.SetValue(0, aNodeInStack);
if ((myFlags & XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes) == 0)
{
#define MAXWORDS 200
#define MAXCARS 1000
-static int THE_IFSelect_SessionPilot_initactor = 0;
-static TCollection_AsciiString nulword;
+static int THE_IFSelect_SessionPilot_initactor = 0;
// #define DEBUG_TRACE
{
if (num < thenbwords)
return thewords(num);
- return nulword;
+ return TCollection_AsciiString::EmptyString();
}
Standard_CString IFSelect_SessionPilot::Arg(const Standard_Integer num) const
return thekind(nd);
}
-static const TCollection_AsciiString& nulname()
-{
- static TCollection_AsciiString nuln;
- return nuln;
-}
-
const TCollection_AsciiString& MoniTool_CaseData::Name(const Standard_Integer nd) const
{
if (nd < 1 || nd > thednam.Length())
- return nulname();
+ return TCollection_AsciiString::EmptyString();
return thednam(nd);
}
// assert( d.IsDifferent( a ));
// assert( d.IsDifferent( h ));
// assert( !d.IsDifferent( d ));
- QCOMPARE(d.IsDifferent(TCollection_AsciiString()), Standard_True);
+ QCOMPARE(d.IsDifferent(TCollection_AsciiString::EmptyString()), Standard_True);
QCOMPARE(d.IsDifferent(a), Standard_True);
QCOMPARE(d.IsDifferent(h), Standard_True);
QCOMPARE(!d.IsDifferent(d), Standard_True);
public:
//! Empty constructor
Standard_EXPORT Message_Attribute(
- const TCollection_AsciiString& theName = TCollection_AsciiString());
+ const TCollection_AsciiString& theName = TCollection_AsciiString::EmptyString());
//! Return a C string to be used as a key for generating text user messages describing this alert.
//! The messages are generated with help of Message_Msg class, in Message_Report::Dump().
#include <Message_Attribute.hxx>
#include <Message_MetricType.hxx>
+#include <TCollection_AsciiString.hxx>
#include <NCollection_IndexedDataMap.hxx>
public:
//! Constructor with string argument
Standard_EXPORT Message_AttributeMeter(
- const TCollection_AsciiString& theName = TCollection_AsciiString());
+ const TCollection_AsciiString& theName = TCollection_AsciiString::EmptyString());
//! Checks whether the attribute has values for the metric
//! @param[in] theMetric metric type
#define _Message_AttributeObject_HeaderFile
#include <Message_Attribute.hxx>
+#include <TCollection_AsciiString.hxx>
#include <NCollection_DefineAlloc.hxx>
//! Alert object storing a transient object
//! Constructor with string argument
Standard_EXPORT Message_AttributeObject(
const Handle(Standard_Transient)& theObject,
- const TCollection_AsciiString& theName = TCollection_AsciiString());
+ const TCollection_AsciiString& theName = TCollection_AsciiString::EmptyString());
//! Returns object
//! @return the object instance
#define _Message_AttributeStream_HeaderFile
#include <Message_Attribute.hxx>
+#include <TCollection_AsciiString.hxx>
#include <Standard_SStream.hxx>
//! Constructor with string argument
Standard_EXPORT Message_AttributeStream(
const Standard_SStream& theStream,
- const TCollection_AsciiString& theName = TCollection_AsciiString());
+ const TCollection_AsciiString& theName = TCollection_AsciiString::EmptyString());
//! Returns stream value
const Standard_SStream& Stream() const { return myStream; }
#include <Message_AlertExtended.hxx>
#include <Message_Gravity.hxx>
#include <Message_Messenger.hxx>
+#include <TCollection_AsciiString.hxx>
#include <Standard.hxx>
//! Constructor.
//! One string key is used for all alert meters.
//! The perf meter is not started automatically, it will be done in AddAlert() method
- Standard_EXPORT Message_Level(const TCollection_AsciiString& theName = TCollection_AsciiString());
+ Standard_EXPORT Message_Level(
+ const TCollection_AsciiString& theName = TCollection_AsciiString::EmptyString());
//! Assures stopping upon destruction
Standard_EXPORT ~Message_Level();
//=================================================================================================
-TCollection_AsciiString::TCollection_AsciiString()
+TCollection_AsciiString::TCollection_AsciiString() noexcept
{
allocate(0);
}
return Standard_True;
}
}
+
+//=================================================================================================
+
+const TCollection_AsciiString& TCollection_AsciiString::EmptyString() noexcept
+{
+ static const TCollection_AsciiString THE_EMPTY_STRING;
+ return THE_EMPTY_STRING;
+}
DEFINE_STANDARD_ALLOC
//! Initializes a AsciiString to an empty AsciiString.
- Standard_EXPORT TCollection_AsciiString();
+ Standard_EXPORT TCollection_AsciiString() noexcept;
#if Standard_CPP17_OR_HIGHER
//! Initializes a AsciiString with a string_view.
//! @return a computed hash code
inline size_t HashCode() const;
+ //! Returns a const reference to a single shared empty string instance.
+ //! This method provides access to a static empty string to avoid creating temporary empty
+ //! strings. Use this method instead of constructing empty strings when you need a const
+ //! reference.
+ //!
+ //! Example:
+ //! ```cpp
+ //! const TCollection_AsciiString& anEmptyStr = TCollection_AsciiString::EmptyString();
+ //! // Use anEmptyStr instead of TCollection_AsciiString()
+ //! ```
+ //! @return const reference to static empty string
+ Standard_EXPORT static const TCollection_AsciiString& EmptyString() noexcept;
+
//! Returns True when the two strings are the same.
//! (Just for HashCode for AsciiString)
//! @param[in] string1 first string to compare
//=================================================================================================
-TCollection_ExtendedString::TCollection_ExtendedString()
+TCollection_ExtendedString::TCollection_ExtendedString() noexcept
{
allocate(0);
}
mylength = 0;
mystring = THE_DEFAULT_EXT_CHAR_STRING;
}
+
+//=================================================================================================
+
+const TCollection_ExtendedString& TCollection_ExtendedString::EmptyString() noexcept
+{
+ static const TCollection_ExtendedString THE_EMPTY_STRING;
+ return THE_EMPTY_STRING;
+}
DEFINE_STANDARD_ALLOC
//! Initializes a ExtendedString to an empty ExtendedString.
- Standard_EXPORT TCollection_ExtendedString();
+ Standard_EXPORT TCollection_ExtendedString() noexcept;
//! Creation by converting a CString to an extended
//! string. If <isMultiByte> is true then the string is
return opencascade::hashBytes(mystring, aSize);
}
+ //! Returns a const reference to a single shared empty string instance.
+ //! This method provides access to a static empty string to avoid creating temporary empty
+ //! strings. Use this method instead of constructing empty strings when you need a const
+ //! reference.
+ //!
+ //! Example:
+ //! ```cpp
+ //! const TCollection_ExtendedString& anEmptyStr = TCollection_ExtendedString::EmptyString();
+ //! // Use anEmptyStr instead of TCollection_ExtendedString()
+ //! ```
+ //! @return const reference to static empty string
+ Standard_EXPORT static const TCollection_ExtendedString& EmptyString() noexcept;
+
//! Returns true if the characters in this extended
//! string are identical to the characters in the other extended string.
//! Note that this method is an alias of operator ==.
#include <Message_AttributeStream.hxx>
#include <Message_Messenger.hxx>
#include <Message_Report.hxx>
+#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
//! Constructor with shape argument
Standard_EXPORT TopoDS_AlertAttribute(
const TopoDS_Shape& theShape,
- const TCollection_AsciiString& theName = TCollection_AsciiString());
+ const TCollection_AsciiString& theName = TCollection_AsciiString::EmptyString());
//! Returns contained shape
const TopoDS_Shape& GetShape() const { return myShape; }
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
-namespace
-{
-static const TCollection_AsciiString THE_EMPTY_KEY;
-}
-
//=================================================================================================
void OpenGl_AspectsProgram::Release(OpenGl_Context* theCtx)
void OpenGl_AspectsProgram::UpdateRediness(const Handle(Graphic3d_Aspects)& theAspect)
{
- const TCollection_AsciiString& aShaderKey =
- theAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : theAspect->ShaderProgram()->GetId();
+ const TCollection_AsciiString& aShaderKey = theAspect->ShaderProgram().IsNull()
+ ? TCollection_AsciiString::EmptyString()
+ : theAspect->ShaderProgram()->GetId();
if (aShaderKey.IsEmpty() || myShaderProgramId != aShaderKey)
{
myIsShaderReady = Standard_False;
#include <Graphic3d_MarkerImage.hxx>
#include <TColStd_HArray1OfByte.hxx>
-namespace
-{
-static const TCollection_AsciiString THE_EMPTY_KEY;
-}
-
//=================================================================================================
void OpenGl_AspectsSprite::Release(OpenGl_Context* theCtx)
aSpriteKeyNew,
aSpriteAKeyNew);
const TCollection_AsciiString& aSpriteKeyOld =
- !mySprite.IsNull() ? mySprite->ResourceId() : THE_EMPTY_KEY;
+ !mySprite.IsNull() ? mySprite->ResourceId() : TCollection_AsciiString::EmptyString();
const TCollection_AsciiString& aSpriteAKeyOld =
- !mySpriteA.IsNull() ? mySpriteA->ResourceId() : THE_EMPTY_KEY;
+ !mySpriteA.IsNull() ? mySpriteA->ResourceId() : TCollection_AsciiString::EmptyString();
if (aSpriteKeyNew.IsEmpty() || aSpriteKeyOld != aSpriteKeyNew || aSpriteAKeyNew.IsEmpty()
|| aSpriteAKeyOld != aSpriteAKeyNew)
{
spriteKeys(theMarkerImage, theType, theScale, theColor, aNewKey, aNewKeyA);
const TCollection_AsciiString& aSpriteKeyOld =
- !mySprite.IsNull() ? mySprite->ResourceId() : THE_EMPTY_KEY;
+ !mySprite.IsNull() ? mySprite->ResourceId() : TCollection_AsciiString::EmptyString();
const TCollection_AsciiString& aSpriteAKeyOld =
- !mySpriteA.IsNull() ? mySpriteA->ResourceId() : THE_EMPTY_KEY;
+ !mySpriteA.IsNull() ? mySpriteA->ResourceId() : TCollection_AsciiString::EmptyString();
// release old shared resources
const Standard_Boolean aNewResource = aNewKey.IsEmpty() || aSpriteKeyOld != aNewKey;
#include <Graphic3d_TextureParams.hxx>
-namespace
-{
-static const TCollection_AsciiString THE_EMPTY_KEY;
-}
-
//=================================================================================================
void OpenGl_AspectsTextureSet::Release(OpenGl_Context* theCtx)
#define OpenGl_FrameBuffer_HeaderFile
#include <OpenGl_NamedResource.hxx>
-
+#include <TCollection_AsciiString.hxx>
#include <Graphic3d_BufferType.hxx>
#include <Graphic3d_Vec2.hxx>
#include <NCollection_Vector.hxx>
public:
//! Empty constructor
Standard_EXPORT OpenGl_FrameBuffer(
- const TCollection_AsciiString& theResourceId = TCollection_AsciiString());
+ const TCollection_AsciiString& theResourceId = TCollection_AsciiString::EmptyString());
//! Destructor
Standard_EXPORT virtual ~OpenGl_FrameBuffer();
#include <OpenGl_Sampler.hxx>
#include <Graphic3d_TextureUnit.hxx>
#include <Graphic3d_TypeOfTexture.hxx>
+#include <TCollection_AsciiString.hxx>
//! Texture resource.
class OpenGl_Texture : public OpenGl_NamedResource
public:
//! Create uninitialized texture.
Standard_EXPORT OpenGl_Texture(
- const TCollection_AsciiString& theResourceId = TCollection_AsciiString(),
+ const TCollection_AsciiString& theResourceId = TCollection_AsciiString::EmptyString(),
const Handle(Graphic3d_TextureParams)& theParams = Handle(Graphic3d_TextureParams)());
//! Destroy object.
#include <OpenGl_SceneGeometry.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_TileSampler.hxx>
+#include <TCollection_AsciiString.hxx>
#include <map>
#include <set>
class ShaderSource
{
public:
- //! Default shader prefix - empty string.
- static const TCollection_AsciiString EMPTY_PREFIX;
-
//! Creates new uninitialized shader source.
ShaderSource()
{
const GLenum theType) const;
//! Loads shader source from specified files.
- Standard_Boolean LoadFromFiles(const TCollection_AsciiString* theFileNames,
- const TCollection_AsciiString& thePrefix = EMPTY_PREFIX);
+ Standard_Boolean LoadFromFiles(
+ const TCollection_AsciiString* theFileNames,
+ const TCollection_AsciiString& thePrefix = TCollection_AsciiString::EmptyString());
//! Loads shader source from specified strings.
- Standard_Boolean LoadFromStrings(const TCollection_AsciiString* theStrings,
- const TCollection_AsciiString& thePrefix = EMPTY_PREFIX);
+ Standard_Boolean LoadFromStrings(
+ const TCollection_AsciiString* theStrings,
+ const TCollection_AsciiString& thePrefix = TCollection_AsciiString::EmptyString());
private:
TCollection_AsciiString mySource; //!< Source string of the shader object
return Standard_True;
}
-const TCollection_AsciiString OpenGl_View::ShaderSource::EMPTY_PREFIX;
-
// =======================================================================
// function : Source
// purpose : Returns shader source combined with prefix
if (aFont.IsNull() && theStrictLevel == Font_StrictLevel_Any)
{
// try finding ANY font in case if even default fallback alias myFallbackAlias cannot be found
- aFont = myFontMap.Find(TCollection_AsciiString());
+ aFont = myFontMap.Find(TCollection_AsciiString::EmptyString());
}
if (aFont.IsNull())
{
{
if (myTextFont.IsNull())
{
- static const TCollection_AsciiString anEmpty;
- return anEmpty;
+ return TCollection_AsciiString::EmptyString();
}
return myTextFont->String();
}
#include <Graphic3d_TypeOfShaderObject.hxx>
#include <NCollection_Sequence.hxx>
#include <OSD_Path.hxx>
+#include <TCollection_AsciiString.hxx>
//! Forward declaration
Graphic3d_TypeOfShaderObject theType,
const ShaderVariableList& theUniforms,
const ShaderVariableList& theStageInOuts,
- const TCollection_AsciiString& theInName = TCollection_AsciiString(),
- const TCollection_AsciiString& theOutName = TCollection_AsciiString(),
+ const TCollection_AsciiString& theInName = TCollection_AsciiString::EmptyString(),
+ const TCollection_AsciiString& theOutName = TCollection_AsciiString::EmptyString(),
Standard_Integer theNbGeomInputVerts = 0);
private:
const Standard_Integer theWindowExtra = 0,
const Aspect_Handle theCursor = NULL,
const Aspect_Handle theIcon = NULL,
- const TCollection_AsciiString& theMenuName = TCollection_AsciiString());
+ const TCollection_AsciiString& theMenuName = TCollection_AsciiString::EmptyString());
//! Destroys all resources attached to the class
Standard_EXPORT ~WNT_WClass();
namespace
{
-static const TCollection_ExtendedString THE_EMPTY_LABEL_STRING;
-static const Standard_Real THE_EMPTY_LABEL_WIDTH = 0.0;
-static const Standard_ExtCharacter THE_DEGREE_SYMBOL(0x00B0);
-static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
+static const Standard_Real THE_EMPTY_LABEL_WIDTH = 0.0;
+static const Standard_ExtCharacter THE_DEGREE_SYMBOL(0x00B0);
+static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
//! Returns true if the given points lie on a same line.
static Standard_Boolean isSameLine(const gp_Pnt& theFirstPoint,
aDimensionAspect->ArrowTailSize(),
aFirstArrowEnd,
aFirstExtensionDir,
- THE_EMPTY_LABEL_STRING,
+ TCollection_ExtendedString::EmptyString(),
THE_EMPTY_LABEL_WIDTH,
theMode,
LabelPosition_None);
aDimensionAspect->ArrowTailSize(),
aSecondArrowEnd,
aSecondExtensionDir,
- THE_EMPTY_LABEL_STRING,
+ TCollection_ExtendedString::EmptyString(),
THE_EMPTY_LABEL_WIDTH,
theMode,
LabelPosition_None);
namespace
{
-// default text strings
-static const TCollection_ExtendedString THE_EMPTY_LABEL;
-static const TCollection_AsciiString THE_UNDEFINED_UNITS;
-
// default text margin and resolution
static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
const TCollection_AsciiString& PrsDim_Dimension::GetDisplayUnits() const
{
- return THE_UNDEFINED_UNITS;
+ return TCollection_AsciiString::EmptyString();
}
//=================================================================================================
const TCollection_AsciiString& PrsDim_Dimension::GetModelUnits() const
{
- return THE_UNDEFINED_UNITS;
+ return TCollection_AsciiString::EmptyString();
}
//=================================================================================================
aDimensionAspect->ArrowTailSize(),
aFirstArrowEnd,
aFirstExtensionDir,
- THE_EMPTY_LABEL,
+ TCollection_ExtendedString::EmptyString(),
0.0,
theMode,
LabelPosition_None);
aDimensionAspect->ArrowTailSize(),
aSecondArrowEnd,
aSecondExtensionDir,
- THE_EMPTY_LABEL,
+ TCollection_ExtendedString::EmptyString(),
0.0,
theMode,
LabelPosition_None);
aDimensionAspect->ArrowTailSize(),
aSecondArrowEnd,
aSecondExtensionDir,
- THE_EMPTY_LABEL,
+ TCollection_ExtendedString::EmptyString(),
0.0,
theMode,
LabelPosition_None);
aDimensionAspect->ArrowTailSize(),
aFirstArrowEnd,
aFirstExtensionDir,
- THE_EMPTY_LABEL,
+ TCollection_ExtendedString::EmptyString(),
0.0,
theMode,
LabelPosition_None);