7 #ifndef _QI_TYPE_DETAIL_ANYREFERENCE_HPP_
8 #define _QI_TYPE_DETAIL_ANYREFERENCE_HPP_
19 #include <ka/scoped.hpp>
20 #include <boost/type_traits/remove_const.hpp>
21 #include <boost/optional.hpp>
30 class UniqueAnyReference;
97 T* ptr(
bool check =
true);
100 bool isValid()
const;
103 bool isValue()
const;
121 template <
typename T>
130 template <
typename T>
151 T to(
const T&)
const;
155 float toFloat()
const;
156 double toDouble()
const;
157 std::string toString()
const;
160 std::vector<T> toList()
const;
162 template<
typename K,
typename V>
163 std::map<K, V> toMap()
const;
166 template <
typename T> boost::optional<T> toOptional()
const;
175 AnyValue toTuple(
bool homogeneous)
const;
212 std::string&
asString() {
return as<std::string>();}
215 std::pair<char*, size_t> asRaw()
const;
217 boost::optional<AnyReference> asOptional()
const;
234 std::map<AnyReference, AnyReference> asMapValuePtr();
243 void set(
const T& val);
249 void set(
float v) { setFloat(v); }
250 void set(
double v) { setDouble(v); }
251 void set(
const std::string& v) { setString(v); }
255 void setFloat(
float v);
256 void setDouble(
double v);
257 void setString(
const std::string& v);
262 void setOptional(
const boost::optional<AnyReference>& opt);
269 void setRaw(
const char *buffer,
size_t size);
277 void resetOptional();
298 template<
typename E,
typename K>
299 E& element(
const K& key);
318 bool optionalHasValue()
const;
323 void append(
const T& element);
326 template<
typename K,
typename V>
327 void insert(
const K& key,
const V& val);
350 std::vector<TypeInterface*> membersType()
const;
367 : AnyReferenceBase(rhs)
371 : AnyReferenceBase(type)
375 : AnyReferenceBase(type, value)
384 throw std::runtime_error(
"invalid internal operation.");
398 const std::vector<TypeInterface*>& types,
399 const std::vector<void*>& values);
432 typename = ka::EnableIfNotBaseOf<detail::AnyReferenceBase, T>>
463 , owned{ ka::exchange(o.owned,
false) }
470 owned = ka::exchange(o.owned,
false);
508 owned = newRef.isValid();
AnyReference(TypeInterface *type)
void destroy()
Stop and flush the logging system.
AutoAnyReference(const AutoAnyReference &b)
AnyReference & operator*()
bool ownsReference() const
void reset(AnyReference newRef, DeferOwnership)
const AnyReference & operator*() const
const AnyReference * operator->() const
void set(const std::string &v)
dll import/export and compiler message
UniqueAnyReference(AnyReference ref, DeferOwnership)
UniqueAnyReference(UniqueAnyReference &&o)
AutoAnyReference(const AnyReference &self)
AnyReference makeGenericTuplePtr(const std::vector< TypeInterface * > &types, const std::vector< void * > &values)
AnyReference makeGenericTuple(const AnyReferenceVector &values)
AutoAnyReference(const detail::AnyReferenceBase &self)
std::vector< AnyReference > AnyReferenceVector
UniqueAnyReference & operator=(UniqueAnyReference &&o)
bool operator==(const Signature &lhs, const Signature &rhs)
TypeInterface * type() const
AnyReference * operator->()
AnyReferenceBase(TypeInterface *type, void *value)
AutoAnyReference(const T &ptr)
UniqueAnyReference()=default
void reset(AnyReference newRef={})
QI_NO_TYPE(qi::AnyReference)
struct QI_API_DEPRECATED_MSG(Use 'QI_TYPE_ENUM'instead) QI_TYPE_ENUM_REGISTER_
AnyReference(const AnyReferenceBase &rhs)
static AnyReference from(const T &ref)
bool operator<(const AnyReference &a, const AnyReference &b)
AnyReference(TypeInterface *type, void *value)
bool operator!=(const Signature &lhs, const Signature &rhs)