Siena C++ API documentation.

class AttributeValue

value of an attribute in a notification

Inheritance:


Public

[more] Constructors
[more] Access functions
[more] Assignment operators


Documentation

An AttributeValue stores the value of an attribute. Attributes can be of a pre-defined set of types (SienaType). AttributeValue provides methods for accessing and assigning values in the form of C++ types. In particular, an AttributeValue of type Siena_integer can be assigned to and from an int, an AttributeValue of type Siena_string can be assigned to and from a C++ standard string, etc.

Example:

    AttributeValue x, y;
    //
    // now x.type() == y.type() == Siena_null
    //
    x = true;
    y = x;
    //
    // now x.type() == y.type() == Siena_bool
    //
    int i = 10;
    if (x.bool_value()) y = i + 10;
    x = i + 20;
    cout << x.int_value() + y.int_value() << endl;
    i = x;
    y = "ciao";
    cout << y.string_value() << endl;
    
o Constructors

o AttributeValue()
null value

o AttributeValue(const AttributeValue &v)
copy constructor

o AttributeValue(const string &)
construct from a string

o AttributeValue(const char *)
construct from a C-style string

o AttributeValue(int)
construct from an int

o AttributeValue(bool)
construct from a bool

o AttributeValue(double)
construct from a double

o Access functions

oSienaType type() const
returns the actual type of this value

oint& int_value()
returns a reference to the value as an integer

Example:

	AttributeValue x = 20;
	cout << x.int_value();
	x.int_value()++;
	cout << x.int_value();
	
Throws:
BadType exception is generated when type() != Siena_integer

ostring& string_value()
returns a reference to the value as a string

Example:

	AttributeValue x = "ciao";
	cout << x.string_value();
	x.string_value() += " ciao";
	cout << x.string_value();
	
Throws:
BadType exception is generated when type() != Siena_string

o operator int () const
returns a copy of the value as an integer whenever the AttributeValue is used in place of an int.

Example:

	AttributeValue x = 20;
	int i = x;
	
Throws:
BadType exception is generated when type() != Siena_int

o operator string () const
returns a copy of the value as a boolean whenever the AttributeValue is used in place of an int.

Example:

	AttributeValue x = "Siena";
	string s = x;
	
Throws:
BadType exception is generated when type() != Siena_string

o Assignment operators

oAttributeValue& operator = (const AttributeValue &)
copy

oAttributeValue& operator = (const string &)
from string

oAttributeValue& operator = (const char *)
from C-style string

oAttributeValue& operator = (int)
from int

oAttributeValue& operator = (bool)
from bool

oAttributeValue& operator = (double)
from double


Direct child classes:
AttributeConstraint
See Also:
Event SienaType

Alphabetic index HTML hierarchy of classes or Java


This document is part of Siena. Please, direct any comment or suggestion to Antonio Carzaniga