Siena C++ API Documentation
Author: Antonio Carzaniga

Siena C++ API documentation (v. 0.4.3)

- Main Page
- Classes
- Files
- Examples

- Class List
- Class Hierarchy
- Class Members

# AttributeValue Class Reference

`#include <Siena.h>`

List of all members.

## Public Member Functions
| AttributeValue ()
| AttributeValue (const AttributeValue &v)
| AttributeValue (const string &)
| AttributeValue (const char *)
| AttributeValue (int)
| AttributeValue (short)
| AttributeValue (long)
| AttributeValue (bool)
| AttributeValue (double)
| ~AttributeValue ()
SXType | type () const
int32_t & | int_value ()
bool & | bool_value ()
string & | string_value ()
double & | double_value ()
const int32_t & | int_value () const
const bool & | bool_value () const
const string & | string_value () const
const double & | double_value () const
| operator long () const
| operator int () const
| operator short () const
| operator string () const
| operator bool () const
| operator double () const
AttributeValue & | operator= (const AttributeValue &)
AttributeValue & | operator= (const string &)
AttributeValue & | operator= (const char *)
AttributeValue & | operator= (int)
AttributeValue & | operator= (short)
AttributeValue & | operator= (long)
AttributeValue & | operator= (bool)
AttributeValue & | operator= (double)
bool | operator== (const AttributeValue &) const
bool | operator< (const AttributeValue &) const
## Protected Attributes
SXType | sxtype
union {
string * str
int32_t num
bool bln
double dbl
}; |

## Detailed Description

value of an attribute in a notification

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

Example:

        AttributeValue x, y;
        //
        // now x.type() == y.type() == SX_null
        //
        x = true;
        y = x;
        //
        // now x.type() == y.type() == SX_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;

## Constructor & Destructor Documentation

AttributeValue::AttributeValue | ( |  | ) |

constructs a null value

AttributeValue::AttributeValue | ( | const AttributeValue & | v | ) |

copy constructor

AttributeValue::AttributeValue | ( | const string & |  | ) |

construct from a string

AttributeValue::AttributeValue | ( | const char * |  | ) |

construct from a C-style string

AttributeValue::AttributeValue | ( | int |  | ) |

construct from an int

AttributeValue::AttributeValue | ( | short |  | ) |

construct from an short

AttributeValue::AttributeValue | ( | long |  | ) |

construct from an long

AttributeValue::AttributeValue | ( | bool |  | ) |

construct from a bool

AttributeValue::AttributeValue | ( | double |  | ) |

construct from a double

AttributeValue::~AttributeValue | ( |  | ) |

construct from a Date

## Member Function Documentation

SXType AttributeValue::type | ( |  | ) | const

returns the actual type of this value

int32_t& AttributeValue::int_value | ( |  | ) |

returns a reference to the value as an integer

returns a reference to the value as an integer

Example:

    	    AttributeValue x = 20;
    	    cout << x.int_value();
    	    x.int_value()++;
    	    cout << x.int_value();

Exceptions:

  | BadType | exception is generated when `type() != SX_integer`

bool& AttributeValue::bool_value | ( |  | ) |

returns a reference to the value as a boolean

Exceptions:

  | BadType | exception is generated when `type() != SX_bool`

string& AttributeValue::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();

Exceptions:

  | BadType | exception is generated when `type() != SX_string`

double& AttributeValue::double_value | ( |  | ) |

returns a reference to the value as a double

Exceptions:

  | BadType | exception is generated when `type() != SX_double`

const int32_t& AttributeValue::int_value | ( |  | ) | const

returns a reference to the value as an integer

Exceptions:

  | BadType | exception is generated when `type() != SX_integer`

const bool& AttributeValue::bool_value | ( |  | ) | const

returns a copy of the value as a boolean

Exceptions:

  | BadType | exception is generated when `type() != SX_bool`

const string& AttributeValue::string_value | ( |  | ) | const

returns a copy of the value as a string

Exceptions:

  | BadType | exception is generated when `type() != SX_string`

const double& AttributeValue::double_value | ( |  | ) | const

returns a copy of the value as a double

Exceptions:

  | BadType | exception is generated when `type() != SX_double`

AttributeValue::operator long | ( |  | ) | const

conversion operator to `long`

returns a copy of the value as an integer whenever the `AttributeValue` is used in place of an `int`.

Example:

    	    AttributeValue x = 20;
    	    long l = x;

Exceptions:

  | BadType | exception is generated when `type() != SX_int`

AttributeValue::operator int | ( |  | ) | const

conversion operator to `int`

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;

Exceptions:

  | BadType | exception is generated when `type() != SX_int`

AttributeValue::operator short | ( |  | ) | const

conversion operator to `short`

returns a copy of the value as an integer whenever the `AttributeValue` is used in place of an `int`.

Example:

    	    AttributeValue x = 20;
    	    short s = x;

Exceptions:

  | BadType | exception is generated when `type() != SX_int`

AttributeValue::operator string | ( |  | ) | const

conversion operator to `string`

Exceptions:

  | BadType | exception is generated when `type() != SX_string`

returns a copy of the value as a string whenever the `AttributeValue` is used in place of a `string`.

Example:

    	    AttributeValue x = "Siena";
    	    string s = x;

AttributeValue::operator bool | ( |  | ) | const

conversion operator to `bool`

Exceptions:

  | BadType | exception is generated when `type() != SX_bool`

conversion operator to `bool`

AttributeValue::operator double | ( |  | ) | const

conversion operator to `double`

Exceptions:

  | BadType | exception is generated when `type() != SX_double`

conversion operator to `double`

AttributeValue& AttributeValue::operator= | ( | const AttributeValue & |  | ) |

copy assignment

AttributeValue& AttributeValue::operator= | ( | const string & |  | ) |

from string

AttributeValue& AttributeValue::operator= | ( | const char * |  | ) |

from C-style string

AttributeValue& AttributeValue::operator= | ( | int |  | ) |

from int

AttributeValue& AttributeValue::operator= | ( | short |  | ) |

from short

AttributeValue& AttributeValue::operator= | ( | long |  | ) |

from long

AttributeValue& AttributeValue::operator= | ( | bool |  | ) |

from bool

AttributeValue& AttributeValue::operator= | ( | double |  | ) |

from double

bool AttributeValue::operator== | ( | const AttributeValue & |  | ) | const

equality relation

bool AttributeValue::operator< | ( | const AttributeValue & |  | ) | const

ordering relation

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

- Siena.h

Copyright © 2001 University of Colorado.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". This documentation is authored and maintained by Antonio Carzaniga