22 #ifndef PROGRAM_OPTIONS_VALUE_STORE_H_INCLUDED
23 #define PROGRAM_OPTIONS_VALUE_STORE_H_INCLUDED
26 namespace ProgramOptions {
49 : vptr_(detail::
vtable(static_cast<const T*>(0)))
77 bool empty()
const {
return vptr_ == 0; }
88 ? extract(const_cast<void**>(&value_))
92 enum { call_extract = 0, vcall_clone = 1, vcall_destroy = 2, vcall_typeid = 3 };
94 void clone(
const void* obj,
void**
out)
const;
95 void* extract(
void** o)
const;
101 const char *
what()
const throw() {
102 return "value_cast: invalid conversion on ValueStore";
112 if (v.
type() ==
typeid(T)) {
113 return *
static_cast<const T*
>(
const_cast<const void*
>(v.
extract_raw()));
120 if (v->
type() ==
typeid(T)) {
121 return static_cast<const T*
>(
const_cast<const void*
>(v->
extract_raw()));
130 return const_cast<T&
>(
value_cast(const_cast<const ValueStore&>(v),
p));
134 return const_cast<T*
>(
value_cast(const_cast<const ValueStore*>(v),
p));
140 return static_cast<const T*
>(
const_cast<const void*
>(v->
extract_raw()));
const T & value_cast(const ValueStore &v, const T *=0)
Extracts a typed value from a ValueStore.
Definition: value_store.h:111
const char * what() const
Definition: value_store.h:101
ValueStore()
creates an empty object
Definition: value_store.cpp:26
vptr_type vtable(const T *=0)
Definition: value_store.h:78
vptr_type base_vtable(const T *=0)
Definition: value_store.h:83
bool empty() const
Returns true if holder does not contain a value.
Definition: value_store.h:77
void(* vcall_type)(const void *in, void **out)
Definition: value_store.h:28
const std::type_info & type() const
Returns the type of the stored value.
Definition: value_store.cpp:49
void * extract_raw() const
Definition: value_store.h:86
A type that can hold any kind of value type.
Definition: value_store.h:40
Definition: value_store.h:100
void swap(ValueStore &other)
swaps this with other
Definition: value_store.cpp:44
~ValueStore()
releases any stored value
Definition: value_store.cpp:37
ValueStore & assimilate(T *obj)
stores obj in this and takes over ownership of obj
Definition: value_store.h:68
void clear()
destroys and releases any stored value
Definition: value_store.cpp:59
const T * unsafe_value_cast(const ValueStore *v, const T *=0)
Extracts a typed value from a ValueStore without checking if the type matches.
Definition: value_store.h:139
void surrender()
surrenders any stored value without destroying it
Definition: value_store.cpp:66
tuple p
Definition: server.py:49
ValueStore(const T &obj)
stores a copy of obj
Definition: value_store.h:48
ValueStore & operator=(ValueStore other)
stores a copy of other releasing any previous value
Definition: value_store.cpp:40
vtable_type * vptr_type
Definition: value_store.h:30
ValueStore & operator=(const T &obj)
stores a copy of obj releasing any previous value
Definition: value_store.h:59
LparseOutputter & out
Definition: output.cc:685
vcall_type vtable_type[4]
Definition: value_store.h:29