#include <anyreference.hpp>
|
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...
|
|
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.
qi::detail::AnyReferenceBase::AnyReferenceBase |
( |
| ) |
|
|
inlineprotected |
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 | ) |
|
|
inlineexplicitprotected |
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 |
|
) |
| |
|
inlineprotected |
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.
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 | ) |
|
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 |
float& qi::detail::AnyReferenceBase::asFloat |
( |
| ) |
|
|
inline |
int16_t& qi::detail::AnyReferenceBase::asInt16 |
( |
| ) |
|
|
inline |
int32_t& qi::detail::AnyReferenceBase::asInt32 |
( |
| ) |
|
|
inline |
int64_t& qi::detail::AnyReferenceBase::asInt64 |
( |
| ) |
|
|
inline |
int8_t& qi::detail::AnyReferenceBase::asInt8 |
( |
| ) |
|
|
inline |
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 |
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 |
uint32_t& qi::detail::AnyReferenceBase::asUInt32 |
( |
| ) |
|
|
inline |
uint64_t& qi::detail::AnyReferenceBase::asUInt64 |
( |
| ) |
|
|
inline |
uint8_t& qi::detail::AnyReferenceBase::asUInt8 |
( |
| ) |
|
|
inline |
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 |
AnyIterator qi::detail::AnyReferenceBase::begin |
( |
| ) |
const |
Return an iterator on the beginning of the container.
AnyReference qi::detail::AnyReferenceBase::content |
( |
| ) |
const |
- Returns
- contained AnyValue or throw if type is not dynamic.
- Note
- Returned AnyReference might be empty.
Attempts the conversion of the value behind the reference to the given type. Converted value is invalid if conversion failed.
Helper function that converts and always clone.
void qi::detail::AnyReferenceBase::destroy |
( |
| ) |
|
|
inline |
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 | ) |
|
template<typename T >
AnyReference qi::detail::AnyReferenceBase::from |
( |
const T & |
ref | ) |
|
|
static |
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 |
|
) |
| |
bool qi::detail::AnyReferenceBase::isValid |
( |
| ) |
const |
|
inline |
bool qi::detail::AnyReferenceBase::isValue |
( |
| ) |
const |
|
inline |
TypeKind qi::detail::AnyReferenceBase::kind |
( |
| ) |
const |
|
inline |
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.
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 |
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 |
void qi::detail::AnyReferenceBase::set |
( |
int32_t |
v | ) |
|
|
inline |
void qi::detail::AnyReferenceBase::set |
( |
uint64_t |
v | ) |
|
|
inline |
void qi::detail::AnyReferenceBase::set |
( |
uint32_t |
v | ) |
|
|
inline |
void qi::detail::AnyReferenceBase::set |
( |
float |
v | ) |
|
|
inline |
void qi::detail::AnyReferenceBase::set |
( |
double |
v | ) |
|
|
inline |
void qi::detail::AnyReferenceBase::set |
( |
const std::string & |
v | ) |
|
|
inline |
void qi::detail::AnyReferenceBase::setDouble |
( |
double |
v | ) |
|
void qi::detail::AnyReferenceBase::setDynamic |
( |
const AnyReference & |
value | ) |
|
void qi::detail::AnyReferenceBase::setFloat |
( |
float |
v | ) |
|
|
inline |
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 | ) |
|
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 |
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 |
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 |
float qi::detail::AnyReferenceBase::toFloat |
( |
| ) |
const |
|
inline |
int64_t qi::detail::AnyReferenceBase::toInt |
( |
| ) |
const |
|
inline |
template<typename T >
std::vector< T > qi::detail::AnyReferenceBase::toList |
( |
| ) |
const |
|
inline |
template<typename K , typename V >
std::map< K, V > qi::detail::AnyReferenceBase::toMap |
( |
| ) |
const |
|
inline |
AnyObject qi::detail::AnyReferenceBase::toObject |
( |
| ) |
const |
template<typename T >
boost::optional< T > qi::detail::AnyReferenceBase::toOptional |
( |
| ) |
const |
|
inline |
std::string qi::detail::AnyReferenceBase::toString |
( |
| ) |
const |
|
inline |
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 |
TODO: update == set (remove one) Update the value with the one in b
void* qi::detail::AnyReferenceBase::_value |
|
protected |
The documentation for this class was generated from the following files: