- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
qi::detail::AnyReferenceBase Class Reference

`#include <anyreference.hpp>`

## Public Member Functions
qi::Signature | signature (bool resolveDynamic=false) const
TypeKind | kind () const
AnyReference | unwrap () const
void | update (const AutoAnyReference &b)
template<typename T >
void | set (const T &val)
| Update the value to val, which will be converted if required. More...
void | set (int64_t v)
void | set (int32_t v)
void | set (uint64_t v)
void | set (uint32_t v)
void | set (float v)
void | set (double v)
void | set (const std::string &v)
void | setInt (int64_t v)
void | setUInt (uint64_t v)
void | setFloat (float v)
void | setDouble (double v)
void | setString (const std::string &v)
void | setDynamic (const AnyReference &value)
void | setOptional (const boost::optional< AnyReference > &opt)
void | setOptional (const AnyReference &opt)
void | setRaw (const char *buffer, size_t size)
void | setTuple (const AnyReferenceVector &values)
void | resetOptional ()
TypeInterface * | type () const
std::vector< TypeInterface * > | membersType () const
void * | rawValue () const
template<>
void | to () const
template<typename T >
T | to () const
| Convert to anything or throw trying. More...
template<typename T >
T | to (const T &) const
| Similar to previous method, but uses a dummy value to get the target type. More...
int64_t | toInt () const
uint64_t | toUInt () const
float | toFloat () const
double | toDouble () const
std::string | toString () const
template<typename T >
std::vector< T > | toList () const
template<typename K , typename V >
std::map< K, V > | toMap () const
AnyObject | toObject () const
template<typename T >
boost::optional< T > | toOptional () const
AnyValue | toTuple (bool homogeneous) const
template<typename T >
T & | as ()
int64_t & | asInt64 ()
uint64_t & | asUInt64 ()
int32_t & | asInt32 ()
uint32_t & | asUInt32 ()
int16_t & | asInt16 ()
uint16_t & | asUInt16 ()
int8_t & | asInt8 ()
uint8_t & | asUInt8 ()
double & | asDouble ()
float & | asFloat ()
std::string & | asString ()
std::pair< char *, size_t > | asRaw () const
boost::optional< AnyReference > | asOptional () const
AnyReference | content () const
AnyReferenceVector | asTupleValuePtr ()
AnyReferenceVector | asListValuePtr ()
std::map< AnyReference, AnyReference > | asMapValuePtr ()
template<typename K >
AnyReference | operator[] (const K &key)
AnyReference | operator[] (const AnyReference &key)
template<typename E , typename K >
E & | element (const K &key)
| Call operator[](key).as<E>, element type must match E. More...
template<typename K >
AnyReference | at (const K &key)
template<typename K >
AnyReference | at (const K &key) const
AnyReference | at (const AnyReference &key)
AnyReference | at (const AnyReference &key) const
size_t | size () const
bool | optionalHasValue () const
template<typename T >
void | append (const T &element)
void | append (const AnyReference &element)
template<typename K , typename V >
void | insert (const K &key, const V &val)
void | insert (const AnyReference &key, const AnyReference &val)
template<typename K >
AnyReference | find (const K &key)
AnyIterator | begin () const
| Return an iterator on the beginning of the container. More...
AnyIterator | end () const
| Return an iterator on the end of the container. More...
AnyReference | operator* () const
| Dereference pointer, iterator or dynamic. More...

## Protected Attributes
TypeInterface * | _type
void * | _value
| AnyReferenceBase ()
| Constructs an invalid reference, pointing to nothing. More...
| AnyReferenceBase (TypeInterface *type)
| AnyReferenceBase (TypeInterface *type, void *value)
AnyReference | _element (const AnyReference &key, bool throwOnFailure, bool autoInsert)
UniqueAnyReference | convert (TypeInterface *targetType) const
UniqueAnyReference | convert (ListTypeInterface *targetType) const
UniqueAnyReference | convert (StructTypeInterface *targetType) const
UniqueAnyReference | convert (MapTypeInterface *targetType) const
UniqueAnyReference | convert (IntTypeInterface *targetType) const
UniqueAnyReference | convert (FloatTypeInterface *targetType) const
UniqueAnyReference | convert (RawTypeInterface *targetType) const
UniqueAnyReference | convert (StringTypeInterface *targetType) const
UniqueAnyReference | convert (PointerTypeInterface *targetType) const
UniqueAnyReference | convert (DynamicTypeInterface *targetType) const
UniqueAnyReference | convert (OptionalTypeInterface *targetType) const
template<typename T >
T * | ptr (bool check=true)
bool | isValid () const
bool | isValue () const
AnyReference | convertCopy (TypeInterface *targetType) const
| Helper function that converts and always clone. More...
AnyReference | clone () const
void | destroy ()
| Deletes storage. More...
template<typename T >
static AnyReference | from (const T &ref)
template<typename T >
static AnyReference | fromPtr (const T *ptr)

## Detailed Description

Class that holds any value, with informations to manipulate it. operator=() makes a shallow copy.

Warning
  AnyReference should not be used directly as call arguments. Use qi::AnyValue which has value semantics instead.

Definition at line 40 of file anyreference.hpp.

## Constructor & Destructor Documentation

qi::detail::AnyReferenceBase::AnyReferenceBase | ( |  | ) |
| inline protected

Constructs an invalid reference, pointing to nothing.

Low level Internal API

Definition at line 41 of file anyreference.hxx.

qi::detail::AnyReferenceBase::AnyReferenceBase | ( | TypeInterface * | type | ) |
| inline explicit protected

Store type and allocate storage of value.

Parameters

  type | use this type for initialization

Definition at line 47 of file anyreference.hxx.

qi::detail::AnyReferenceBase::AnyReferenceBase | ( | TypeInterface * | type,
|  | void * | value
| ) |  |
| inline protected

Create a generic value with type and a value who should have already been allocated.

Parameters

  type | type of this generic value
  value | an already alloc place to store value

Definition at line 59 of file anyreference.hpp.

## Member Function Documentation

AnyReference qi::detail::AnyReferenceBase::_element | ( | const AnyReference & | key,
|  | bool | throwOnFailure,
|  | bool | autoInsert
| ) |  |
| protected

Get item with key/index 'key'.

Parameters

  throwOnFailure | controls what happens in case of failure (key out of range or invalid type): true - the function throws, false - returns empty AnyReferece. If the container is a 'Map' type, this parameter is ignored.
  autoInsert | if the container is a 'Map' type, this parameter controls what happens if the value with the given key does not already exist in the map: true - a new entry is added to the map and then returned, false - an empty AnyReference is returned (no insertion is performed).

template<typename T >

void qi::detail::AnyReferenceBase::append | ( | const T & | element | ) |

Definition at line 270 of file anyreference.hxx.

void qi::detail::AnyReferenceBase::append | ( | const AnyReference & | element | ) |

template<typename T >

T & qi::detail::AnyReferenceBase::as | ( |  | ) |
| inline

Read and update functions The following functions access or modify the existing value. They never change the storage location or type. They will fail by throwing an exception if the requested operation is incompatible with the current value type.

Warning
  a AnyReference refering to a container element will become invalid as soon as the container is modified.

Returns
  a typed reference to the underlying value

Warning
  This method will only succeed if T exactly matches the type of the value stored. No conversion will be performed. So if you only want a value and not a reference, use to() instead.

Definition at line 120 of file anyreference.hxx.

double& qi::detail::AnyReferenceBase::asDouble | ( |  | ) |
| inline

Definition at line 210 of file anyreference.hpp.

float& qi::detail::AnyReferenceBase::asFloat | ( |  | ) |
| inline

Definition at line 211 of file anyreference.hpp.

int16_t& qi::detail::AnyReferenceBase::asInt16 | ( |  | ) |
| inline

Definition at line 206 of file anyreference.hpp.

int32_t& qi::detail::AnyReferenceBase::asInt32 | ( |  | ) |
| inline

Definition at line 204 of file anyreference.hpp.

int64_t& qi::detail::AnyReferenceBase::asInt64 | ( |  | ) |
| inline

Definition at line 202 of file anyreference.hpp.

int8_t& qi::detail::AnyReferenceBase::asInt8 | ( |  | ) |
| inline

Definition at line 208 of file anyreference.hpp.

AnyReferenceVector qi::detail::AnyReferenceBase::asListValuePtr | ( |  | ) |
| inline

Definition at line 209 of file anyreference.hxx.

std::map<AnyReference, AnyReference> qi::detail::AnyReferenceBase::asMapValuePtr | ( |  | ) |

boost::optional<AnyReference> qi::detail::AnyReferenceBase::asOptional | ( |  | ) | const

std::pair<char*, size_t> qi::detail::AnyReferenceBase::asRaw | ( |  | ) | const

Returns
  a pair of (char*, size) corresponding to the raw buffer. No copy made.

std::string& qi::detail::AnyReferenceBase::asString | ( |  | ) |
| inline

Definition at line 212 of file anyreference.hpp.

AnyReferenceVector qi::detail::AnyReferenceBase::asTupleValuePtr | ( |  | ) |

Container partial unboxing. The following functions unbox the container-part of the value. The values in the contairer are exposed as AnyReference. The values can be modified using the set and as function families, But the container itself is a copy.

Warning
  for better performances use the begin() and end() iterator API

uint16_t& qi::detail::AnyReferenceBase::asUInt16 | ( |  | ) |
| inline

Definition at line 207 of file anyreference.hpp.

uint32_t& qi::detail::AnyReferenceBase::asUInt32 | ( |  | ) |
| inline

Definition at line 205 of file anyreference.hpp.

uint64_t& qi::detail::AnyReferenceBase::asUInt64 | ( |  | ) |
| inline

Definition at line 203 of file anyreference.hpp.

uint8_t& qi::detail::AnyReferenceBase::asUInt8 | ( |  | ) |
| inline

Definition at line 209 of file anyreference.hpp.

template<typename K >

AnyReference qi::detail::AnyReferenceBase::at | ( | const K & | key | ) |

Similar to operator[], but Map container type is not modified if the key does not exist. Returns an empty AnyReference if the key is invalid (out of bounds for list/tuple or key not found for the map)

Definition at line 243 of file anyreference.hxx.

template<typename K >

AnyReference qi::detail::AnyReferenceBase::at | ( | const K & | key | ) | const

Definition at line 254 of file anyreference.hxx.

AnyReference qi::detail::AnyReferenceBase::at | ( | const AnyReference & | key | ) |
| inline

Definition at line 259 of file anyreference.hxx.

AnyReference qi::detail::AnyReferenceBase::at | ( | const AnyReference & | key | ) | const
| inline

Definition at line 264 of file anyreference.hxx.

AnyIterator qi::detail::AnyReferenceBase::begin | ( |  | ) | const

Return an iterator on the beginning of the container.

AnyReference qi::detail::AnyReferenceBase::clone | ( |  | ) | const
| inline

Definition at line 18 of file anyreference.hxx.

AnyReference qi::detail::AnyReferenceBase::content | ( |  | ) | const

Returns
  contained AnyValue or throw if type is not dynamic.

Note
  Returned AnyReference might be empty.

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | TypeInterface * | targetType | ) | const

Attempts the conversion of the value behind the reference to the given type. Converted value is invalid if conversion failed.

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | ListTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | StructTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | MapTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | IntTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | FloatTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | RawTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | StringTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | PointerTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | DynamicTypeInterface * | targetType | ) | const

UniqueAnyReference qi::detail::AnyReferenceBase::convert | ( | OptionalTypeInterface * | targetType | ) | const

AnyReference qi::detail::AnyReferenceBase::convertCopy | ( | TypeInterface * | targetType | ) | const

Helper function that converts and always clone.

void qi::detail::AnyReferenceBase::destroy | ( |  | ) |
| inline

Deletes storage.

Definition at line 34 of file anyreference.hxx.

template<typename E , typename K >

E & qi::detail::AnyReferenceBase::element | ( | const K & | key | ) |

Call operator[](key).as<E>, element type must match E.

Definition at line 226 of file anyreference.hxx.

AnyIterator qi::detail::AnyReferenceBase::end | ( |  | ) | const

Return an iterator on the end of the container.

template<typename K >

AnyReference qi::detail::AnyReferenceBase::find | ( | const K & | key | ) |

Similar to operator[](), but return an empty AnyValue If the key is not present.

Definition at line 282 of file anyreference.hxx.

template<typename T >

AnyReference qi::detail::AnyReferenceBase::from | ( | const T & | ref | ) |
| static

Construction and assign. Wraps the given value into an AnyReference, allowing an introspectable, type-erased access to the value.

Warning
  the AnyReference has an undefined behavior if the value it references is destroyed.

Note
  AnyReference can be used to wrap another AnyValue or AnyReference, even if they are invalid.

Definition at line 64 of file anyreference.hxx.

template<typename T >

AnyReference qi::detail::AnyReferenceBase::fromPtr | ( | const T * | ptr | ) |
| static

Construct a AnyValue with storage pointing to ptr.

Warning
  the AnyReference will become invalid if ptr is destroyed (if it gets deleted or points to the stack and goes out of scope).

Definition at line 54 of file anyreference.hxx.

template<typename K , typename V >

void qi::detail::AnyReferenceBase::insert | ( | const K & | key,
|  | const V & | val
| ) |  |

Definition at line 276 of file anyreference.hxx.

void qi::detail::AnyReferenceBase::insert | ( | const AnyReference & | key,
|  | const AnyReference & | val
| ) |  |

bool qi::detail::AnyReferenceBase::isValid | ( |  | ) | const
| inline

Returns
  false if this is invalid.

Definition at line 156 of file anyreference.hxx.

bool qi::detail::AnyReferenceBase::isValue | ( |  | ) | const
| inline

Returns
  true if value is valid and not void

Definition at line 161 of file anyreference.hxx.

TypeKind qi::detail::AnyReferenceBase::kind | ( |  | ) | const
| inline

Definition at line 71 of file anyreference.hxx.

std::vector<TypeInterface*> qi::detail::AnyReferenceBase::membersType | ( |  | ) | const

Returns
  list of tuple elements type, or throw if not a tuple

AnyReference qi::detail::AnyReferenceBase::operator* | ( |  | ) | const

Dereference pointer, iterator or dynamic.

template<typename K >

AnyReference qi::detail::AnyReferenceBase::operator[] | ( | const K & | key | ) |

In-place container manipulation. Return a reference to container element at index or key idx. Use set methods on the result for inplace modification. Behavior depends on the container kind:

- List or tuple: The key must be of integral type. Boundary checks are performed.
- Map: The key must be of a convertible type to the container key type. If the key is not found in the container, a new default-valued Element will be created, inserted. and returned.
  Warning
    the returned value is only valid until owning container is changed.

Definition at line 232 of file anyreference.hxx.

AnyReference qi::detail::AnyReferenceBase::operator[] | ( | const AnyReference & | key | ) |
| inline

Definition at line 237 of file anyreference.hxx.

bool qi::detail::AnyReferenceBase::optionalHasValue | ( |  | ) | const

Returns true if the optional has a value.

Exceptions

  std::runtime_error | if kind of `this` is not Optional

template<typename T >

T * qi::detail::AnyReferenceBase::ptr | ( | bool | check = `true` | ) |
| inline

Return the typed pointer behind a AnyReference. T must be the type of the value.

Returns
  a pointer to the value as a T or 0 if value is not a T.

Parameters

  check | if false, does not validate type before converting

Definition at line 111 of file anyreference.hxx.

void* qi::detail::AnyReferenceBase::rawValue | ( |  | ) | const
| inline

Definition at line 351 of file anyreference.hpp.

void qi::detail::AnyReferenceBase::resetOptional | ( |  | ) |

Resets the value of the optional.

Exceptions

  std::runtime_error | if kind of `this` is not Optional

template<typename T >

void qi::detail::AnyReferenceBase::set | ( | const T & | val | ) |

Update the value to val, which will be converted if required.

Definition at line 215 of file anyreference.hxx.

void qi::detail::AnyReferenceBase::set | ( | int64_t | v | ) |
| inline

Definition at line 245 of file anyreference.hpp.

void qi::detail::AnyReferenceBase::set | ( | int32_t | v | ) |
| inline

Definition at line 246 of file anyreference.hpp.

void qi::detail::AnyReferenceBase::set | ( | uint64_t | v | ) |
| inline

Definition at line 247 of file anyreference.hpp.

void qi::detail::AnyReferenceBase::set | ( | uint32_t | v | ) |
| inline

Definition at line 248 of file anyreference.hpp.

void qi::detail::AnyReferenceBase::set | ( | float | v | ) |
| inline

Definition at line 249 of file anyreference.hpp.

void qi::detail::AnyReferenceBase::set | ( | double | v | ) |
| inline

Definition at line 250 of file anyreference.hpp.

void qi::detail::AnyReferenceBase::set | ( | const std::string & | v | ) |
| inline

Definition at line 251 of file anyreference.hpp.

void qi::detail::AnyReferenceBase::setDouble | ( | double | v | ) |

void qi::detail::AnyReferenceBase::setDynamic | ( | const AnyReference & | value | ) |

void qi::detail::AnyReferenceBase::setFloat | ( | float | v | ) |
| inline

Definition at line 220 of file anyreference.hxx.

void qi::detail::AnyReferenceBase::setInt | ( | int64_t | v | ) |

void qi::detail::AnyReferenceBase::setOptional | ( | const boost::optional< AnyReference > & | opt | ) |

Sets the value of the optional. A copy will be made.

Exceptions

  std::runtime_error | if `this` is not Optional.

void qi::detail::AnyReferenceBase::setOptional | ( | const AnyReference & | opt | ) |

void qi::detail::AnyReferenceBase::setRaw | ( | const char * | buffer,
|  | size_t | size
| ) |  |

set the value of the raw buffer, a copy will be made.

Exceptions

  std::runtime_error | when kind is not Raw

void qi::detail::AnyReferenceBase::setString | ( | const std::string & | v | ) |

void qi::detail::AnyReferenceBase::setTuple | ( | const AnyReferenceVector & | values | ) |

set the values of the tuple. A copy will be made.

Exceptions

  std::runtime_error | when kind is not Tuple

void qi::detail::AnyReferenceBase::setUInt | ( | uint64_t | v | ) |

qi::Signature qi::detail::AnyReferenceBase::signature | ( | bool | resolveDynamic = `false` | ) | const
| inline

Definition at line 26 of file anyreference.hxx.

size_t qi::detail::AnyReferenceBase::size | ( |  | ) | const

template<typename T >

T qi::detail::AnyReferenceBase::to | ( |  | ) | const
| inline

Convert to anything or throw trying.

The following methods return a typed copy of the stored value, converting if necessary. They throw in case of conversion failure.

Definition at line 138 of file anyreference.hxx.

template<>

void qi::detail::AnyReferenceBase::to | ( |  | ) | const
| inline

Definition at line 151 of file anyreference.hxx.

template<typename T >

T qi::detail::AnyReferenceBase::to | ( | const T & |  | ) | const
| inline

Similar to previous method, but uses a dummy value to get the target type.

Definition at line 129 of file anyreference.hxx.

double qi::detail::AnyReferenceBase::toDouble | ( |  | ) | const
| inline

Definition at line 181 of file anyreference.hxx.

float qi::detail::AnyReferenceBase::toFloat | ( |  | ) | const
| inline

Definition at line 176 of file anyreference.hxx.

int64_t qi::detail::AnyReferenceBase::toInt | ( |  | ) | const
| inline

Definition at line 166 of file anyreference.hxx.

template<typename T >

std::vector< T > qi::detail::AnyReferenceBase::toList | ( |  | ) | const
| inline

Definition at line 192 of file anyreference.hxx.

template<typename K , typename V >

std::map< K, V > qi::detail::AnyReferenceBase::toMap | ( |  | ) | const
| inline

Definition at line 198 of file anyreference.hxx.

AnyObject qi::detail::AnyReferenceBase::toObject | ( |  | ) | const

template<typename T >

boost::optional< T > qi::detail::AnyReferenceBase::toOptional | ( |  | ) | const
| inline

Definition at line 204 of file anyreference.hxx.

std::string qi::detail::AnyReferenceBase::toString | ( |  | ) | const
| inline

Definition at line 186 of file anyreference.hxx.

AnyValue qi::detail::AnyReferenceBase::toTuple | ( | bool | homogeneous | ) | const

Convert the value to a tuple. If value is currently a tuple, it will be returned. If value is a list its elements will become the tuple components.

Parameters

  homogeneous | if true, all tuple elements will be of the type of the list element type. If false, the effective type of elements of kind dynamic will be used.

uint64_t qi::detail::AnyReferenceBase::toUInt | ( |  | ) | const
| inline

Definition at line 171 of file anyreference.hxx.

TypeInterface* qi::detail::AnyReferenceBase::type | ( |  | ) | const
| inline

Definition at line 348 of file anyreference.hpp.

AnyReference qi::detail::AnyReferenceBase::unwrap | ( |  | ) | const
| inline

Definition at line 79 of file anyreference.hxx.

void qi::detail::AnyReferenceBase::update | ( | const AutoAnyReference & | b | ) |

TODO: update == set (remove one) Update the value with the one in b

## Member Data Documentation

TypeInterface* qi::detail::AnyReferenceBase::_type
| protected

Definition at line 354 of file anyreference.hpp.

void* qi::detail::AnyReferenceBase::_value
| protected

Definition at line 355 of file anyreference.hpp.

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

- /home/opennao/work/release-2.8/sdk/libqi/qi/type/detail/anyreference.hpp
- /home/opennao/work/release-2.8/sdk/libqi/qi/type/detail/anyreference.hxx