Class AnyScalar¶
Defined in File anyscalar.h
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
class AnyScalar¶
A type-safe variant union capable of holding any of the PVD scalar types (POD or string)
AnyScalar A(5); assert(A.type()==pvInt); assert(A.ref<int32>()==5); assert(A.as<int32>()==5); assert(A.as<double>()==5.0); assert(A.ref<double>()==5.0); // throws AnyScalar::bad_cast
Public Functions
-
inline AnyScalar()¶
Construct empty
- Post
empty()==true
-
AnyScalar(ScalarType type, const void *buf)¶
Construct from un-typed pointer. Caller is responsible to ensure that buf actually points to the provided type
- Version
Added after 7.0.0
-
inline ~AnyScalar()¶
-
void clear()¶
Reset internal state.
- Version
Added after 7.0.0
- Post
empty()==true
-
inline ScalarType type() const¶
Type code of contained value. Or (ScalarType)-1 is empty.
-
inline void *unsafe()¶
-
inline const void *unsafe() const¶
-
inline bool empty() const¶
-
inline operator bool_type() const¶
-
const void *bufferUnsafe() const¶
Provide read-only access to underlying buffer. For a string this is std::string::c_str().
- Version
Added after 7.0.0
-
template<typename T>
inline detail::any_storage_type<typename meta::strip_const<T>::type>::type &ref()¶ Return typed reference to wrapped value. Non-const reference allows value modification
- Throws
bad_cast – when the requested type does not match the stored type
AnyScalar v(42); v.ref<uint32>() = 43; assert(v.ref<uint32>() == 43);
-
template<typename T>
inline meta::decorate_const<typename detail::any_storage_type<typename meta::strip_const<T>::type>::type>::type &ref() const¶ Return typed reference to wrapped value. Const reference does not allow modification.
- Throws
bad_cast – when the requested type does not match the stored type
const AnyScalar v(42); assert(v.ref<uint32>() == 42);
-
struct bad_cast : public exception¶
-
inline AnyScalar()¶