abstract_creator is an internal helper to avoid some code having to know if a type is created on a stack or the heap. More...
#include <abstract_creator.hpp>
Public Types | |
typedef T | value_type |
Same as (T). | |
typedef T | base_value_type |
Same as (T). | |
Static Public Member Functions | |
static bool | create (value_type &v, const std::string &=std::string()) throw () |
This implementation assigns v to value_type() and returns true. |
abstract_creator is an internal helper to avoid some code having to know if a type is created on a stack or the heap.
This makes some template code easier to write, as it avoids syntax errors when trying something like:
if( object type is a pointer type ) delete(object); else { ... }
This implementation creates items the stack via the default ctor. If instantiated with (T *) a pointer/heap-based specialization is activated instead.
Designed for use with, e.g., ListType<T>, for which T may be either T or (T *).
These objects contain no state information.
The member function release() was removed in s11n 1.1.3, as it was potentially dangerous. s11n_traits::cleanup_functor replaces that functionality and does so correctly.
Definition at line 44 of file abstract_creator.hpp.
typedef T s11n::Private::abstract_creator< T >::base_value_type |
Same as (T).
Definition at line 50 of file abstract_creator.hpp.
typedef T s11n::Private::abstract_creator< T >::value_type |
Same as (T).
Definition at line 47 of file abstract_creator.hpp.
static bool s11n::Private::abstract_creator< T >::create | ( | value_type & | v, | |
const std::string & | = std::string() | |||
) | throw () [inline, static] |
This implementation assigns v to value_type() and returns true.
The string argument is bogus for this implementation, and is used by the pointer specialization to implement polymorphic classloading of value_type.
Historical note: before s11n release 0.9.17 this function incorrectly did nothing. While this works for many cases, it caused a subtle, hard-to-track bug in s11n::list::deserialize_list(), in which a deserialized list was re-used when the function was called recursively. Many thanks to Patrick Lin for reporting that problem.
Definition at line 68 of file abstract_creator.hpp.