Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::StringProperty Class Reference

Property for storing string values. More...

#include <mitkStringProperty.h>

Inheritance diagram for mitk::StringProperty:
Collaboration diagram for mitk::StringProperty:

Public Types

typedef std::string ValueType
 The type of the value stored by this property. More...
 

Public Member Functions

 mitkClassMacro (StringProperty, BaseProperty)
 
Pointer Clone () const
 
 mitkNewMacro1Param (StringProperty, const char *)
 
 mitkNewMacro1Param (StringProperty, const std::string &)
 
virtual const char * GetValue () const
 Get the string value. More...
 
virtual void SetValue (const char *_arg)
 Set the string value. More...
 
std::string GetValueAsString () const override
 Return the property value as a string. More...
 
bool ToJSON (nlohmann::json &j) const override
 Serialize the string value to JSON. More...
 
bool FromJSON (const nlohmann::json &j) override
 Deserialize the string value from JSON. More...
 
BaseProperty & operator= (const BaseProperty &property)
 Assign a property value to this instance. More...
 
- Public Member Functions inherited from mitk::BaseProperty
 mitkClassMacroItkParent (BaseProperty, itk::Object)
 
Pointer Clone () const
 
bool operator== (const BaseProperty &property) const
 Compare two properties for equality. More...
 
BaseProperty & operator= (const BaseProperty &property)
 Assign a property value to this instance. More...
 
bool AssignProperty (const BaseProperty &property)
 Assign a property value to this instance and report success. More...
 

Static Public Member Functions

static Pointer New ()
 

Static Public Attributes

static const char * PATH
 Constant used as a convention for properties representing file paths. More...
 
- Static Public Attributes inherited from mitk::BaseProperty
static const std::string VALUE_CANNOT_BE_CONVERTED_TO_STRING
 Default return value for properties that cannot be converted to a string. More...
 

Protected Member Functions

 StringProperty (const char *string=nullptr)
 
 StringProperty (const std::string &s)
 
 StringProperty (const StringProperty &)
 
 mitkCloneMacro (StringProperty)
 
- Protected Member Functions inherited from mitk::BaseProperty
 BaseProperty ()
 
 BaseProperty (const BaseProperty &other)
 
 ~BaseProperty () override
 

Protected Attributes

std::string m_Value
 

Detailed Description

Property for storing string values.

This property holds a std::string value. It is one of the most commonly used property types in MITK, for example to store names, labels, or other textual metadata associated with data objects.

See also
BaseProperty
GenericProperty
TemporoSpatialStringProperty

Definition at line 36 of file mitkStringProperty.h.

Member Typedef Documentation

◆ ValueType

typedef std::string mitk::StringProperty::ValueType

The type of the value stored by this property.

Definition at line 52 of file mitkStringProperty.h.

Constructor & Destructor Documentation

◆ StringProperty() [1/3]

mitk::StringProperty::StringProperty ( const char *  string = nullptr)
protected

◆ StringProperty() [2/3]

mitk::StringProperty::StringProperty ( const std::string &  s)
protected

◆ StringProperty() [3/3]

mitk::StringProperty::StringProperty ( const StringProperty &  )
protected

Member Function Documentation

◆ Clone()

Pointer mitk::StringProperty::Clone ( ) const

◆ FromJSON()

bool mitk::StringProperty::FromJSON ( const nlohmann::json &  j)
overridevirtual

Deserialize the string value from JSON.

Parameters
[in]jThe JSON value containing the string.
Returns
Always true.

Implements mitk::BaseProperty.

◆ GetValue()

virtual const char* mitk::StringProperty::GetValue ( ) const
virtual

Get the string value.

Returns
The current string value.

Referenced by mitk::DataNode::GetName().

◆ GetValueAsString()

std::string mitk::StringProperty::GetValueAsString ( ) const
overridevirtual

Return the property value as a string.

Returns
The stored string value.

Reimplemented from mitk::BaseProperty.

◆ mitkClassMacro()

mitk::StringProperty::mitkClassMacro ( StringProperty  ,
BaseProperty   
)

◆ mitkCloneMacro()

mitk::StringProperty::mitkCloneMacro ( StringProperty  )
protected

◆ mitkNewMacro1Param() [1/2]

mitk::StringProperty::mitkNewMacro1Param ( StringProperty  ,
const char *   
)

◆ mitkNewMacro1Param() [2/2]

mitk::StringProperty::mitkNewMacro1Param ( StringProperty  ,
const std::string &   
)

◆ New()

static Pointer mitk::StringProperty::New ( )
static

◆ operator=()

BaseProperty& mitk::BaseProperty::operator=

Assign a property value to this instance.

Performs a polymorphic assignment from the given property. The assignment succeeds only if the source and target properties are of the same type. The subclass-specific Assign() method is called to perform the actual value copy.

Subclasses must implement Assign(const BaseProperty&) and call the superclass Assign method for proper handling. The copy assignment operator of the subclass should be disabled and the base class operator should be made visible using "using" statements.

Parameters
[in]propertyThe property whose value should be assigned to this instance.
Returns
A reference to this property.
See also
AssignProperty
Assign

◆ SetValue()

virtual void mitk::StringProperty::SetValue ( const char *  _arg)
virtual

Set the string value.

Parameters
[in]_argThe new string value.

Referenced by mitk::DataNode::SetName().

◆ ToJSON()

bool mitk::StringProperty::ToJSON ( nlohmann::json &  j) const
overridevirtual

Serialize the string value to JSON.

Parameters
[out]jThe JSON object to write the value into.
Returns
Always true.

Implements mitk::BaseProperty.

Member Data Documentation

◆ m_Value

std::string mitk::StringProperty::m_Value
protected

Definition at line 39 of file mitkStringProperty.h.

◆ PATH

const char* mitk::StringProperty::PATH
static

Constant used as a convention for properties representing file paths.

Definition at line 94 of file mitkStringProperty.h.


The documentation for this class was generated from the following file: