Manual for OpenFLUID 2.1.11

Public Member Functions | List of all members
openfluid::core::StringValue Class Reference

Detailed Description

StringValue is a container for a std::string value, with methods for conversion to other containers derived from Value.

See also
Value

Example : declaration

// declaration of a StringValue, initialized to an empty string by default
// declaration of a StringValue, initialized to "hello world"
openfluid::core::StringValue Val2("hello world");

Example : getting the contained value

std::string Tmp1;
// using the get method
Tmp1 = Val1.get();
// or using the cast operator
Tmp1 = Val1;

Example : setting the contained value

// using the set method
Val1.set("Have a nice day");

#include <core/StringValue.hpp>

Public Member Functions

 StringValue ()
 
 StringValue (const StringValue &Val)
 
 StringValue (const char *Val)
 
 StringValue (const std::string &Val)
 
 StringValue (bool Val)
 
 StringValue (int Val)
 
 StringValue (double Val)
 
StringValue & operator= (const Value &Other) override
 
StringValue & operator= (Value &&Other) override
 
StringValue & operator= (const StringValue &Other)=default
 
StringValue & operator= (StringValue &&Other)=default
 
virtual ~StringValue ()=default
 
 operator std::string () const
 
Type getType () const override
 
Value * clone () const override
 
bool convert (Value &Val) const override
 
std::string get () const
 
std::string & data ()
 
const std::string & data () const
 
void set (const std::string &Val)
 
void clear ()
 
void writeToStream (std::ostream &OutStm) const override
 
void writeQuotedToStream (std::ostream &OutStm) const override
 
unsigned long getSize () const
 
unsigned long size () const
 
unsigned int replaceAll (const std::string &FindStr, const std::string &ReplaceStr)
 
Value::Type guessTypeConversion () const
 
bool toDouble (double &Val) const
 
bool toDoubleValue (DoubleValue &Val) const
 
bool toBoolean (bool &Val) const
 
bool toBooleanValue (BooleanValue &Val) const
 
bool toInteger (int &Val) const
 
bool toInteger (long &Val) const
 
bool toIntegerValue (IntegerValue &Val) const
 
bool toNullValue (NullValue &Val) const
 
bool toVectorValue (VectorValue &Val) const
 
bool toMatrixValue (MatrixValue &Val) const
 
bool toMatrixValue (const unsigned int &RowLength, MatrixValue &Val) const
 
bool toMapValue (MapValue &Val) const
 
bool toTreeValue (TreeValue &Val) const
 
- Public Member Functions inherited from openfluid::core::SimpleValue
bool isSimple () const override
 
bool isCompound () const override
 
- Public Member Functions inherited from openfluid::core::Value
 Value ()=default
 
 Value (const Value &)=default
 
 Value (Value &&)=default
 
virtual ~Value ()=default
 
bool isDoubleValue () const
 
const DoubleValue & asDoubleValue () const
 
DoubleValue & asDoubleValue ()
 
bool isIntegerValue () const
 
const IntegerValue & asIntegerValue () const
 
IntegerValue & asIntegerValue ()
 
bool isBooleanValue () const
 
const BooleanValue & asBooleanValue () const
 
BooleanValue & asBooleanValue ()
 
bool isStringValue () const
 
const StringValue & asStringValue () const
 
StringValue & asStringValue ()
 
bool isNullValue () const
 
const NullValue & asNullValue () const
 
NullValue & asNullValue ()
 
bool isVectorValue () const
 
const VectorValue & asVectorValue () const
 
VectorValue & asVectorValue ()
 
bool isMatrixValue () const
 
const MatrixValue & asMatrixValue () const
 
MatrixValue & asMatrixValue ()
 
bool isMapValue () const
 
const MapValue & asMapValue () const
 
MapValue & asMapValue ()
 
bool isTreeValue () const
 
const TreeValue & asTreeValue () const
 
TreeValue & asTreeValue ()
 
std::string toString () const
 

Additional Inherited Members

- Public Types inherited from openfluid::core::Value
enum  Type {
  NONE, BOOLEAN, INTEGER, DOUBLE,
  STRING, VECTOR, MATRIX, MAP,
  TREE, NULLL
}
 
- Static Public Member Functions inherited from openfluid::core::Value
static bool getValueTypeFromString (const std::string &ValueTypeString, Value::Type &ValueType)
 
static std::string getStringFromValueType (const Value::Type ValueType)
 
Inheritance diagram for openfluid::core::StringValue:
Inheritance graph
[legend]
Collaboration diagram for openfluid::core::StringValue:
Collaboration graph
[legend]

Constructor & Destructor Documentation

◆ StringValue() [1/7]

openfluid::core::StringValue::StringValue ( )
inline

Default constructor

◆ StringValue() [2/7]

openfluid::core::StringValue::StringValue ( const StringValue &  Val)
inline

Copy constructor

◆ StringValue() [3/7]

openfluid::core::StringValue::StringValue ( const char *  Val)
inline

Constructor from char*

◆ StringValue() [4/7]

openfluid::core::StringValue::StringValue ( const std::string &  Val)
inline

Constructor from std::string

◆ StringValue() [5/7]

openfluid::core::StringValue::StringValue ( bool  Val)

Constructor from bool

◆ StringValue() [6/7]

openfluid::core::StringValue::StringValue ( int  Val)

Constructor from int

◆ StringValue() [7/7]

openfluid::core::StringValue::StringValue ( double  Val)

Constructor from double

◆ ~StringValue()

virtual openfluid::core::StringValue::~StringValue ( )
virtualdefault

Member Function Documentation

◆ clear()

void openfluid::core::StringValue::clear ( )
inline

◆ clone()

Value* openfluid::core::StringValue::clone ( ) const
inlineoverridevirtual

Reimplemented from openfluid::core::Value.

◆ convert()

bool openfluid::core::StringValue::convert ( Value &  Val) const
overridevirtual

Reimplemented from openfluid::core::Value.

◆ data() [1/2]

std::string& openfluid::core::StringValue::data ( )
inline

Returns a reference to the string value as std::string type

Returns
the string value

◆ data() [2/2]

const std::string& openfluid::core::StringValue::data ( ) const
inline

Returns a reference to the string value as std::string type

Returns
the string value

◆ get()

std::string openfluid::core::StringValue::get ( ) const
inline

Returns the string value as std::string type

Returns
the string value

◆ getSize()

unsigned long openfluid::core::StringValue::getSize ( ) const
inline

Returns the size of the string

Returns
size of the string

◆ getType()

Type openfluid::core::StringValue::getType ( ) const
inlineoverridevirtual

◆ guessTypeConversion()

Value::Type openfluid::core::StringValue::guessTypeConversion ( ) const

Try to find the the most adapted type for conversion

Returns
the most adapted type for conversion (if the value is empty)

◆ operator std::string()

openfluid::core::StringValue::operator std::string ( ) const
inline

Cast operator

◆ operator=() [1/4]

StringValue& openfluid::core::StringValue::operator= ( const StringValue &  Other)
default

◆ operator=() [2/4]

StringValue& openfluid::core::StringValue::operator= ( const Value &  )
overridevirtual

Assignment operator

Reimplemented from openfluid::core::Value.

◆ operator=() [3/4]

StringValue& openfluid::core::StringValue::operator= ( StringValue &&  Other)
default

◆ operator=() [4/4]

StringValue& openfluid::core::StringValue::operator= ( Value &&  )
overridevirtual

Move operator

Reimplemented from openfluid::core::Value.

◆ replaceAll()

unsigned int openfluid::core::StringValue::replaceAll ( const std::string &  FindStr,
const std::string &  ReplaceStr 
)

Replaces all occurences of FindStr by ReplaceStr

Parameters
[in]FindStrthe substring to find
[in]ReplaceStrthe substring to replace the found substrings
Returns
the number of occurences

◆ set()

void openfluid::core::StringValue::set ( const std::string &  Val)
inline

Sets the string value

Parameters
[in]Valthe string value

◆ size()

unsigned long openfluid::core::StringValue::size ( ) const
inline

Returns the size of the string

Returns
size of the string

◆ toBoolean()

bool openfluid::core::StringValue::toBoolean ( bool &  Val) const

Converts the contained string to a boolean value (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toBooleanValue()

bool openfluid::core::StringValue::toBooleanValue ( BooleanValue &  Val) const

Converts the contained string to a BooleanValue (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toDouble()

bool openfluid::core::StringValue::toDouble ( double &  Val) const

Converts the contained string to a double value (if possible)

Returns
bool true if the conversion is correct, false otherwise

◆ toDoubleValue()

bool openfluid::core::StringValue::toDoubleValue ( DoubleValue &  Val) const

Converts the contained string to a DoubleValue (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toInteger() [1/2]

bool openfluid::core::StringValue::toInteger ( int &  Val) const

Converts the contained string to an int value (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toInteger() [2/2]

bool openfluid::core::StringValue::toInteger ( long &  Val) const

Converts the contained string to a long value (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toIntegerValue()

bool openfluid::core::StringValue::toIntegerValue ( IntegerValue &  Val) const

Converts the contained string to an IntegerValue (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toMapValue()

bool openfluid::core::StringValue::toMapValue ( MapValue &  Val) const

Converts the contained string to a MapValue value (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toMatrixValue() [1/2]

bool openfluid::core::StringValue::toMatrixValue ( const unsigned int &  RowLength,
MatrixValue &  Val 
) const

Converts the contained string to a MatrixValue value (if possible)

Parameters
[in]RowLengththe size of a row
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toMatrixValue() [2/2]

bool openfluid::core::StringValue::toMatrixValue ( MatrixValue &  Val) const

Converts the contained string to a MatrixValue value (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toNullValue()

bool openfluid::core::StringValue::toNullValue ( NullValue &  Val) const

Converts the contained string to a NullValue (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ toTreeValue()

bool openfluid::core::StringValue::toTreeValue ( TreeValue &  Val) const

Converts the contained string to a TreeValue value (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise
Exceptions
FrameworkExceptionwhen called
Warning
This method is currently not implement and always throws a FrameworkException

◆ toVectorValue()

bool openfluid::core::StringValue::toVectorValue ( VectorValue &  Val) const

Converts the contained string to a VectorValue value (if possible)

Parameters
[out]Valthe converted value
Returns
bool true if the conversion is correct, false otherwise

◆ writeQuotedToStream()

void openfluid::core::StringValue::writeQuotedToStream ( std::ostream &  OutStm) const
inlineoverridevirtual

◆ writeToStream()

void openfluid::core::StringValue::writeToStream ( std::ostream &  OutStm) const
overridevirtual

The documentation for this class was generated from the following file:
openfluid::core::StringValue::set
void set(const std::string &Val)
Definition: StringValue.hpp:200
openfluid::core::StringValue::get
std::string get() const
Definition: StringValue.hpp:173
openfluid::core::StringValue
Definition: StringValue.hpp:76