    

 ## On this page

  

 

 # ValueType Class Reference

 Last update: 16.07.2025 

Represents a type of value and a set of properties. [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") is intended to be associated with a set of floating point data values. It stores information (the value type and named value attributes) about data values. It provides conversion routines between its associated floating point data values and value type. [More...](class_value_type.xhtml#details)

## <a name="pub-types"></a>Public Types

<a id="a12f8ec8f0e7a4584b9fe481bb53fa60e"></a>enum [eType](class_value_type.xhtml#a12f8ec8f0e7a4584b9fe481bb53fa60e) { **DOUBLE** = 1, **INT** = 2, **BOOL** = 3, **ENUM** = 4 } Enumeration of all available value types. Returned by [type()](class_value_type.xhtml#a04b0a9497332985d1c7386b487924e85 "Get the Type of this ValueType. ") method. Used to identify from which derived class the shared base class [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") object has been created.   
 ## <a name="pub-methods"></a>Public Member Functions

string [\_\_str\_\_](class_value_type.xhtml#a44139caf93a3463ea4f2a6671cdce842) () Function to allow printing instances of this class in python. [More...](#a44139caf93a3463ea4f2a6671cdce842)  
 number [attribute](class_value_type.xhtml#a4fe78fe23647b841774a467f7115e242) (string attribute) Returns the value of the given attribute. An attribute is a named value, to specify the behavior of the [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). For instance min/max. See [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") derived classes for documentation of available attributes. [More...](#a4fe78fe23647b841774a467f7115e242)  
 number [attribute](class_value_type.xhtml#a945190dbb867b410997fa2d77a1a629f) (string attribute, number default\_value) Returns the value of the given attribute. Default value is returned if the attribute is undefined. An attribute is a named value, to specify the behavior of the [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). For instance min/max. See [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") derived classes for documentation of available attributes. [More...](#a945190dbb867b410997fa2d77a1a629f)  
 <a id="abc6417bd7b50620ce73098bd5859540d"></a>bool [attributeExists](class_value_type.xhtml#abc6417bd7b50620ce73098bd5859540d) (string [attribute](class_value_type.xhtml#a4fe78fe23647b841774a467f7115e242)) Check whether an attribute is defined.   
 <a id="a166e44f3030115668a91a35ffb81ff11"></a>string [description](class_value_type.xhtml#a166e44f3030115668a91a35ffb81ff11) () Get the description of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...").   
 bool [eraseAttribute](class_value_type.xhtml#a39693bcee84d3daf689384219bd7e89c) (string [attribute](class_value_type.xhtml#a4fe78fe23647b841774a467f7115e242)) Removes an attribute. [More...](#a39693bcee84d3daf689384219bd7e89c)  
 <a id="aa62b508d2c0e7d9cec12924965276eb5"></a>string [name](class_value_type.xhtml#aa62b508d2c0e7d9cec12924965276eb5) () Get the unique name of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...").   
 <a id="a7fe700521405d7e9ecb39f9c20eb2589"></a>bool [operator!=](class_value_type.xhtml#a7fe700521405d7e9ecb39f9c20eb2589) ([ValueType](class_value_type.xhtml) b) Returns false if both types have equal name, value type, attributes and description.   
 <a id="a99b4ecb5a908b5fb78fddad314091737"></a>bool [operator==](class_value_type.xhtml#a99b4ecb5a908b5fb78fddad314091737) ([ValueType](class_value_type.xhtml) b) Returns true if both types have equal name, value type, attributes and description.   
 <a id="a3355fe903707accf684bf8ca5dd30f34"></a>bool [operator&gt;](class_value_type.xhtml#a3355fe903707accf684bf8ca5dd30f34) ([ValueType](class_value_type.xhtml) b) Sort by name.   
  [setAttribute](class_value_type.xhtml#a8bdd98028a4fcad8345fb72becb3c0d4) (string [attribute](class_value_type.xhtml#a4fe78fe23647b841774a467f7115e242), number value) Define an attribute. Existing attributes are overwritten. [More...](#a8bdd98028a4fcad8345fb72becb3c0d4)  
 virtual number [toDouble](class_value_type.xhtml#a0f53106b13e55a9126710549e5d91fd0) (string str)=0 Convert a string to number precision floating point value. [More...](#a0f53106b13e55a9126710549e5d91fd0)  
 virtual string [toString](class_value_type.xhtml#ac64491e7d149ef1fdb6bc14df52a27d1) (number value)=0 Convert a string to number precision floating point value. [More...](#ac64491e7d149ef1fdb6bc14df52a27d1)  
 <a id="a04b0a9497332985d1c7386b487924e85"></a>[eType](class_value_type.xhtml#a12f8ec8f0e7a4584b9fe481bb53fa60e) [type](class_value_type.xhtml#a04b0a9497332985d1c7386b487924e85) () Get the Type of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...").   
 <a id="details" name="details"></a>## Detailed Description

Represents a type of value and a set of properties. [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") is intended to be associated with a set of floating point data values. It stores information (the value type and named value attributes) about data values. It provides conversion routines between its associated floating point data values and value type.

See also[ValueTypeManager](class_value_type_manager.xhtml "Keeps track of all unique ValueTypes. Required to create new ValueType shared resource instances...") for [Script](group__script.xhtml "Define custom scripts ("macros"). Build macro-based custom solvers and export (FMU/SDB). ") example usage. NoteConstructor is private. Use create() method of derived classes ([ValueTypeDouble](class_value_type_double.xhtml "Identifies a set of values as number precision floating points values and an associated set of option..."), [ValueTypeDouble](class_value_type_double.xhtml "Identifies a set of values as number precision floating points values and an associated set of option..."), [ValueTypeBool](class_value_type_bool.xhtml "Identifies a set of values as boolean and an associated set of optional attributes. It provides conversion routines between floating point and string representation. "), [ValueTypeEnum](class_value_type_enum.xhtml "Identifies a set of values as an enumration of strings type and an associated set of optional attribu...")). 

## Member Function Documentation

<a id="a44139caf93a3463ea4f2a6671cdce842"></a>## [◆ ](#a44139caf93a3463ea4f2a6671cdce842)\_\_str\_\_()

 string \_\_str\_\_  ( ) 

Function to allow printing instances of this class in python.

ReturnsThe unique name of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") 



<a id="a4fe78fe23647b841774a467f7115e242"></a>## [◆ ](#a4fe78fe23647b841774a467f7115e242)attribute() \[1/2\]

 number attribute  ( string  *attribute*) 

Returns the value of the given attribute. An attribute is a named value, to specify the behavior of the [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). For instance min/max. See [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") derived classes for documentation of available attributes.

Parameters attributeAttribute to search for Exceptions Ifattribute is undefined 



<a id="a945190dbb867b410997fa2d77a1a629f"></a>## [◆ ](#a945190dbb867b410997fa2d77a1a629f)attribute() \[2/2\]

 number attribute  ( string  *attribute*,    number  *default\_value*   ) 

Returns the value of the given attribute. Default value is returned if the attribute is undefined. An attribute is a named value, to specify the behavior of the [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). For instance min/max. See [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") derived classes for documentation of available attributes.

Parameters attributeAttribute to search for. default\_valueValue returned if attribute is undefined. 



<a id="a39693bcee84d3daf689384219bd7e89c"></a>## [◆ ](#a39693bcee84d3daf689384219bd7e89c)eraseAttribute()

 bool eraseAttribute  ( string  *attribute*) 

Removes an attribute.

Parameters attributeThe attribute to remove ReturnsTrue if the attribute was removed. False if the attribute was undefined. 



<a id="a8bdd98028a4fcad8345fb72becb3c0d4"></a>## [◆ ](#a8bdd98028a4fcad8345fb72becb3c0d4)setAttribute()

 setAttribute  ( string  *attribute*,    number  *value*   ) 

Define an attribute. Existing attributes are overwritten.

Parameters attributeName of the attribute. valueValue of the attribute. 



<a id="a0f53106b13e55a9126710549e5d91fd0"></a>## [◆ ](#a0f53106b13e55a9126710549e5d91fd0)toDouble()

 virtual number toDouble  ( string  *str*)   pure virtual 

Convert a string to number precision floating point value.

See alsoDerived classes for [type](class_value_type.xhtml#a04b0a9497332985d1c7386b487924e85 "Get the Type of this ValueType. ") specific implementation Parameters strThe string to convert ReturnsThe converted value Implemented in [ValueTypeEnum](class_value_type_enum.xhtml#a3feb53908f4c019f35111daf04a190b8), [ValueTypeBool](class_value_type_bool.xhtml#a3feb53908f4c019f35111daf04a190b8), [ValueTypeDouble](class_value_type_double.xhtml#a3feb53908f4c019f35111daf04a190b8), and [ValueTypeInt](class_value_type_int.xhtml#a3feb53908f4c019f35111daf04a190b8).





<a id="ac64491e7d149ef1fdb6bc14df52a27d1"></a>## [◆ ](#ac64491e7d149ef1fdb6bc14df52a27d1)toString()

 virtual string toString  ( number  *value*)   pure virtual 

Convert a string to number precision floating point value.

See alsoDerived classes for [type](class_value_type.xhtml#a04b0a9497332985d1c7386b487924e85 "Get the Type of this ValueType. ") specific implementation Parameters strThe string to convert ReturnsThe converted value Implemented in [ValueTypeEnum](class_value_type_enum.xhtml#afe98eed581fb1712f5b265fcce59dfda), [ValueTypeBool](class_value_type_bool.xhtml#afe98eed581fb1712f5b265fcce59dfda), [ValueTypeInt](class_value_type_int.xhtml#afe98eed581fb1712f5b265fcce59dfda), and [ValueTypeDouble](class_value_type_double.xhtml#afe98eed581fb1712f5b265fcce59dfda).