Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

s11n Namespace Reference

The s11n serialization (s11n) framework is an object serialization framework for C++ modelled heavily off work by Rusty Ballinger (bozo@users.sourceforge.net http://libfunutil.sourceforge.net). More...


Classes

struct  object_deleter
 Deletes an object passed to it. More...
struct  object_reference_wrapper
 object_reference_wrapper is a type for giving access to T objects via their dot operator, regardless of whether they are pointers or not. More...
struct  object_reference_wrapper< T * >
 A specialization to wrap pointers to (T *) such that they can be accessed, via this wrapper, using a dot instead of ->. More...
struct  const_object_reference_wrapper
 const_object_reference_wrapper is identical in usage to object_reference_wrapper, except that it deals with const objects. More...
struct  const_object_reference_wrapper< T * >
 A specialization to wrap pointers to (T *) such that they can be accessed, via this wrapper, using a dot instead of ->. More...
struct  subnode_serializer_f
 A helper functor to loop over serializable children. More...
struct  streamable_type_serialization_proxy
 A Serializable Proxy for streamable types. More...
struct  serialize_subnode_f
 A functor which simply forwards its arguments to s11n::serialize_subnode(). More...
struct  deserialize_subnode_f
 A functor which simply forwards its arguments to s11n::deserialize_subnode(). More...
struct  s11n_exception
 The base-most exception type used by s11n. More...
struct  factory_exception
 An exception type for classloader-related exceptions. More...
struct  io_exception
 Really for use by clients, i/o layers, and s11nlite, not by the s11n core. More...
struct  reference_base_f
 Holds a [const] reference to an object. More...
struct  reference_f
 Holds a reference to an object. More...
struct  reference_f< T const >
 Holds a const reference to an object. More...
struct  reference_f< T * >
 Added in 1.1.3. More...
struct  reference_f< T const * >
 Added in 1.1.3. More...
struct  pointer_base_f
 Pointer equivalent of reference_base_f. More...
struct  pointer_f
 Pointer equivalent of reference_f. More...
struct  pointer_f< T const >
 Pointer equivalent of reference_f. More...
struct  pointer_f< T * >
 Pointer equivalent of reference_f. More...
struct  pointer_f< T const * >
 Pointer equivalent of reference_f. More...
struct  value_f
 Holds a value. More...
struct  value_f< T const >
 Quasi-bogus specialization. More...
struct  value_f< T & >
 Quasi-bogus specialization. More...
struct  value_f< T const & >
 Quasi-bogus specialization. More...
struct  serialize_f
 A functor which simply forwards its arguments to s11n::serialize(). More...
struct  deserialize_f
 A functor which simply forwards its arguments to s11n::deserialize(). More...
struct  serialize_nullary_f
 Conforms to serialize_nullary_f_tag expectations and converts a serialize_binary_f_tag type to serialize_nullary_f_tag type. More...
struct  node_to_serialize_unary_f
 Converts an S-Node to a unary functor taking a Serializable argument. More...
struct  node_to_deserialize_unary_f
 Converts an S-Node to a unary functor taking a Serializable argument. More...
struct  serializable_to_serialize_unary_f
 Converts a Serializable to a type compliant with serialize_unary_node_f_tag. More...
struct  serializable_to_deserialize_unary_f
 Converts a Serializable to a type compliant with deserialize_unary_node_f_tag. More...
struct  deserialize_nullary_f
 Conforms to deserialize_nullary_f_tag expectations and converts a deserialize_binary_f_tag type to deserialize_nullary_f_tag type. More...
struct  serializable_f
 Experimental. More...
struct  deserializable_f
 Experimental. More...
struct  deserialize_to_output_iter_f
 A functor to allow us to easily walk a list of S-Nodes and deserialize each one into a target container. More...
struct  serialize_to_subnode_f
 Experimental. More...
struct  serialize_to_subnode_unary_f
 Experimental. More...
struct  deserialize_from_subnode_f
 BinaryFunctorT requires this signature:. More...
struct  deserialize_from_subnode_unary_f
 BinaryFunctorT requires this signature:. More...
struct  logical_and_binary_f
 Functor implementing AND logic and between two functors, which are expected to return values convertable to bool. More...
struct  logical_and_unary_f
 Functor implementing AND logic and between two functors, which are expected to return values convertable to bool. More...
struct  logical_and_nullary_f
 Functor implementing AND logic and between two functors, which are expected to return values convertable to bool. More...
struct  default_cleanup_functor< S11N_LIST_TYPE< T1 > >
 Specialization for list-compliant types. More...
struct  default_cleanup_functor< S11N_MAP_TYPE< T1, T2 > >
 Specialization for std::map-compliant types. More...
struct  s11n_traits< S11N_TEMPLATE_TYPE_Q >
 s11n_traits<> specialization for template types taking one template parameter, like std::list types. More...
struct  s11n_traits< S11N_TYPE >
class  s11n_node
 s11n_node is a slightly lighter-weight replacement for the data_node type used in s11n 1.0.x. More...
struct  cleaner_upper
 Intended for use with for_each(), this type cleans up Serializables using cleanup_serializable(). More...
struct  cleanup_ptr
 An auto_ptr-like type intended to simplify pointer/exception safety in some deserialization algorithms by providing a way to completely and safely destroy partially-deserialized objects. More...
struct  serialize_f_tag
 A tag type for serialization functors. More...
struct  serialize_nullary_f_tag
 A tag type for serialization functors which look like:. More...
struct  serialize_binary_f_tag
 A tag type for serialization functors which look like:. More...
struct  serialize_unary_node_f_tag
 A tag type for serialization functors which look like:. More...
struct  serialize_unary_serializable_f_tag
 A tag type for serialization functors which look like:. More...
struct  deserialize_f_tag
 A tag type for deserialization functors. More...
struct  deserialize_nullary_f_tag
 A tag type for deserialization functors which look like:. More...
struct  deserialize_binary_f_tag
 A tag type for deserialization functors which look like:. More...
struct  deserialize_unary_node_f_tag
 A tag type for deserialization functors which look like:. More...
struct  deserialize_unary_serializable_f_tag
 A tag type for deserialization functors which look like:. More...
struct  node_traits
 node_traits encapsulates information relevant to Data Nodes, much in the same way that std::char_traits encapsulates character type information. More...
struct  default_serialize_functor
 A default serialization proxy, which simply forwards de/serialize calls to an interface implemented as two overloaded member functions SerializableType::operator()( NodeT ). More...
struct  default_cleanup_functor
 A default implementation for s11n_traits::cleanup_functor. More...
struct  s11n_traits
 s11n_traits encapsulates information about what type(s) are responsible for handling de/serialize operations for a given type, plus the factory for that type. More...
struct  s11n_traits< T * >
 A general specialization to treat (T*) as (T) for s11n_traits purposes. More...
struct  type_traits_base
 A base type for type_traits. More...
struct  type_traits
 A simple type traits container. More...
struct  type_traits< const T >
 Specialization for (const T). More...
struct  type_traits< T & >
 Specialization for (T &). More...
struct  type_traits< const T & >
 Specialization for (const T &). More...
struct  type_traits< T * >
 Specialization for (T *). More...
struct  type_traits< const T * >
 Specialization for (const T *). More...
struct  default_cleanup_functor< std::pair< T1, T2 > >
struct  s11n_traits< std::valarray< ValueType > >
 s11n_traits<> specialization for std::valarray types. More...

Namespaces

namespace  cl
 The s11n::cl namespace encapsulates the public classloader-related API for libs11n.
namespace  debug
 The s11n::debug namespace holds some code for debugging and tracing s11n internals.
namespace  Detail
 The Detail namespace holds types which aren't strictly internal/private, but are nonetheless considered to be "implementation details." Unless specifically documented otherwise, clients are discouraged from using the Detail-namespace API from client code, as any part of it may change significantly or be replaced/removed without any warning.
namespace  fac
 The s11n::fac namespace contains s11n's "private" object factory manager.
namespace  io
 The s11n::io namespace defines some i/o-related types which conform to the conventions expected by the s11n::de/serialize() core functions.
namespace  list
 The s11n::list namespace defines functors and algorithms for working with std::list/vector-style containers.
namespace  map
 The s11n::map namespace defines functors and algorithms for working with std::map, std::pair, and conventions-compatible containers.
namespace  plugin
 The plugin namespace encapsulates the braindeadly basic API for loading plugins.
namespace  Private
 The Private namespace holds internal library types: these should not be used in client code.
namespace  sharing
namespace  util
 The s11n::util namespace encapsulates some utility code for client-side use alongside the s11n framework.
namespace  va
 s11n::va encapsulates de/serialization operators for std::valarray objects.

Functions

template<typename DataNodeType, typename SerializableT>
bool serialize_subnode (DataNodeType &target, const std::string &nodename, const SerializableT &src)
 Serializes src to as a subnode of target, named nodename.
template<typename DataNodeType, typename DeserializableT>
bool deserialize_subnode (const DataNodeType &src, const std::string &subnodename, DeserializableT &target)
 If a child named subnodename is found in src then this function returns deserialize( child, target ) and returns it's result, otherwise it returns 0.
template<typename DataNodeType, typename DeserializableT>
DeserializableT * deserialize_subnode (const DataNodeType &src, const std::string &subnodename)
 If a child named subnodename is found in src then this function returns the result of deserialize(child), otherwise it returns 0.
template<typename InputIt, typename OutputIt, typename UnaryPredicate>
OutputIt copy_if (InputIt first, InputIt last, OutputIt result, UnaryPredicate pred)
 For each item in [first,last), copies the item to OutputIt if pred(*item) returns true.
template<typename IterT>
void delete_objects (IterT begin, IterT end)
 For each item in [begin,end) object_deleter()(*item) is called.
template<typename NodeType, typename ChildType>
void add_child (NodeType &parent, ChildType *ch)
 Adds ch as a child of parent.
template<typename NodeType>
NodeType & create_child (NodeType &parent, const std::string nodename)
 Creates a new node, named nodename, as a child of parent.
template<typename NodeT, typename DestContainerT>
size_t find_children_by_name (const NodeT &parent, const std::string &name, DestContainerT &target)
 Each child in parent.children() which has the given name is copied into the target container.
template<typename NodeT>
const NodeT * find_child_by_name (const NodeT &parent, const std::string &name)
 Finds the FIRST child in parent with the given name and returns a pointer to it, or 0 if no such child is found.
template<typename NodeT>
NodeT * find_child_by_name (NodeT &parent, const std::string &name)
 A non-const overload of find_child_by_name().
template<typename T>
reference_f< T > ref (T &ref)
 Convenience function to return reference_f<T>(ref).
template<typename T>
value_f< T > val (const T &v)
 Returns value_f<T>(v).
template<typename NodeType, typename SerializableT, typename BinaryFunctorT>
serialize_nullary_f< NodeType,
SerializableT, BinaryFunctorT > 
ser_nullary_f (NodeType &n, SerializableT const &s, BinaryFunctorT const &f)
 Returns serialize_nullary_f<NodeType,SerializableT,BinaryFunctorT>( n, s, f ).
template<typename NodeType, typename SerializableT>
serialize_nullary_f< NodeType,
SerializableT > 
ser_nullary_f (NodeType &n, SerializableT const &s)
 Returns serialize_nullary_f<NodeType,SerializableT>( n, s ).
template<typename NodeType, typename BinaryFunctorT>
node_to_serialize_unary_f<
NodeType, BinaryFunctorT > 
node_to_ser_unary_f (NodeType &n, BinaryFunctorT f)
 Returns node_to_serialize_unary_f<NodeType,BinaryFunctorT>(n,f).
template<typename NodeType>
node_to_serialize_unary_f<
NodeType > 
node_to_ser_unary_f (NodeType &n)
 Returns node_to_serialize_unary_f<NodeType>(n).
template<typename NodeType, typename BinaryFunctorT>
node_to_deserialize_unary_f<
NodeType, BinaryFunctorT > 
node_to_deser_unary_f (NodeType const &n, BinaryFunctorT const &f)
 Returns node_to_deserialize_unary_f<NodeType,BinaryFunctorT>(n,f).
template<typename NodeType>
node_to_deserialize_unary_f<
NodeType > 
node_to_deser_unary_f (NodeType const &n)
 Returns node_to_deserialize_unary_f<NodeType>(n).
template<typename SerT, typename BinaryFunctorT>
serializable_to_serialize_unary_f<
SerT, BinaryFunctorT > 
ser_to_ser_unary_f (SerT const &s, BinaryFunctorT const &f)
 Returns serializable_to_serialize_unary_f<SerT,BinaryFunctorT>( s, f ).
template<typename SerT>
serializable_to_serialize_unary_f<
SerT > 
ser_to_ser_unary_f (SerT const &s)
 Returns serializable_to_serialize_unary_f<SerT>( s ).
template<typename SerT, typename BinaryFunctorT>
serializable_to_deserialize_unary_f<
SerT, BinaryFunctorT > 
ser_to_deser_unary_f (SerT &s, BinaryFunctorT const &f)
 Returns serializable_to_deserialize_unary_f<SerT,BinaryFunctorT>( s, f ).
template<typename SerT>
serializable_to_deserialize_unary_f<
SerT > 
ser_to_deser_unary_f (SerT const &s)
 Returns serializable_to_deserialize_unary_f<SerT>( s ).
template<typename NodeType, typename DeserializableT, typename BinaryFunctorT>
deserialize_nullary_f< NodeType,
DeserializableT, BinaryFunctorT > 
deser_nullary_f (NodeType const &n, DeserializableT &s, BinaryFunctorT const &f)
 Returns deserialize_nullary_f<NodeType,DeserializableT,BinaryFunctorT>( n, s, f ).
template<typename NodeType, typename DeserializableT>
deserialize_nullary_f< NodeType,
DeserializableT > 
deser_nullary_f (NodeType const &n, DeserializableT &s)
 Returns deserialize_nullary_f<NodeType,DeserializableT>( n, s );.
template<typename SerializableT>
serializable_f< SerializableT > ser_f (SerializableT const &ref)
 Experimental.
template<typename SerializableT, typename BinaryFunctorT>
serializable_f< SerializableT,
BinaryFunctorT > 
ser_f (SerializableT const &ref, BinaryFunctorT f)
 Experimental.
template<typename DeserializableT>
deserializable_f< DeserializableT > deser_f (DeserializableT &ref)
 Added in 1.1.3.
template<typename DeserializableT, typename BinaryFunctorT>
deserializable_f< DeserializableT,
BinaryFunctorT > 
deser_f (DeserializableT &ref, BinaryFunctorT f)
 Added in 1.1.3.
template<typename SerializableType, typename OutIterator, typename BinaryFunctorT>
deserialize_to_output_iter_f<
SerializableType, OutIterator,
BinaryFunctorT > 
deser_to_outiter_f (OutIterator target, BinaryFunctorT f)
 Convenience function returning:.
template<typename SerializableType, typename OutIterator>
deserialize_to_output_iter_f<
SerializableType, OutIterator > 
deser_to_outiter_f (OutIterator target)
 Convenience function returning:.
serialize_to_subnode_f ser_to_subnode_f (const std::string &subnodename)
 Returns serialize_to_subnode_f<>( subnodename ).
template<typename BinaryFunctorT>
serialize_to_subnode_f< BinaryFunctorT > ser_to_subnode_f (const std::string &subnodename, BinaryFunctorT f)
 Returns serialize_to_subnode_f<BinaryFunctorT>( subnodename, f ).
template<typename NodeType>
serialize_to_subnode_unary_f<
NodeType > 
ser_to_subnode_unary_f (NodeType &parent, const std::string &subnodename)
 Returns serialize_to_subnode_f<NodeType>( parent, subnodename ).
template<typename NodeType, typename BinaryFunctorT>
serialize_to_subnode_unary_f<
NodeType, BinaryFunctorT > 
ser_to_subnode_unary_f (NodeType &parent, const std::string &subnodename, BinaryFunctorT f)
 Returns serialize_to_subnode_unary_f<NodeType,BinaryFunctorT>( parent, subnodename, f ).
deserialize_from_subnode_f deser_from_subnode_f (const std::string &subnodename)
 Returns deserialize_from_subnode_f<>( parent, subnodename ).
template<typename BinaryFunctorT>
deserialize_from_subnode_f<
BinaryFunctorT > 
deser_from_subnode_f (const std::string &subnodename, BinaryFunctorT f)
 Returns deserialize_from_subnode_f<BinaryFunctorT>( parent, subnodename, f ).
template<typename NodeType>
deserialize_from_subnode_unary_f<
NodeType > 
deser_from_subnode_unary_f (const NodeType &parent, const std::string &subnodename)
 Returns deserialize_from_subnode_unary_f<NodeType>( parent, subnodename ).
template<typename NodeType, typename BinaryFunctorT>
deserialize_from_subnode_unary_f<
NodeType, BinaryFunctorT > 
deser_from_subnode_unary_f (const NodeType &parent, const std::string &subnodename, BinaryFunctorT f)
 Experimental.
template<typename F1, typename F2>
logical_and_nullary_f< F1,
F2 > 
logical_and (F1 const &f1, F2 const &f2)
 Returns logical_and_nullary<F1,F2>(f1,f2).
template<typename F1>
logical_and_unary_f< F1 > logical_and (F1 const &f1)
 Returns logical_and_unary<F1>(f1).
logical_and_binary_f logical_and ()
 Returns logical_and_binary().
std::string library_version ()
 Returns the string form of the s11n library version.
template<typename DataNodeType, typename SerializableT>
bool serialize (DataNodeType &target, const SerializableT &src)
 Serializes src to target using the default API marshaling mechanism.
template<typename SerializableType>
void cleanup_serializable (SerializableType &s) throw ()
 Calls s11n_traits<SerializableType>::cleanup_functor()(s).
template<typename SerializableType>
void cleanup_serializable (SerializableType *&s) throw ()
 This overload provides cleanup handling for pointer types.
template<typename DataNodeType, typename DeserializableT>
bool deserialize (const DataNodeType &src, DeserializableT &target)
 Deserializes target from src using the default API marshaling mechanism.
template<typename DataNodeType, typename DeserializableT>
bool deserialize (const DataNodeType &src, DeserializableT *&target)
 Like the standard form of deserialize(), but if passed a null pointer, it attempts to classload the class and assign the passed-in pointer to it.
template<typename DataNodeType, typename DeserializableT>
bool deserialize (const DataNodeType &src, cleanup_ptr< DeserializableT > &target)
 Identical to deserialize(const DataNodeType&,DeserializableT*&) except that it works on a cleanup_ptr<>.
template<typename DataNodeType, typename DeserializableT>
DeserializableT * deserialize (const DataNodeType &src)
 Tries to deserialize a DeserializableT from src, using s11n_traits<DeserializableT>::factory_type()(node_traits<DataNodeType>::class_name(src)) to create a new DeserializableT.
template<typename DataNodeType, typename SerializableType>
SerializableType * s11n_clone (const SerializableType &tocp)
 Clones an arbitrary SerializableType using its DataNodeType serialization implementation.
template<typename NodeType, typename Type1, typename Type2>
bool s11n_cast (const Type1 &t1, Type2 &t2)
 "Casts" t1 to t2 using serialization.


Detailed Description

The s11n serialization (s11n) framework is an object serialization framework for C++ modelled heavily off work by Rusty Ballinger (bozo@users.sourceforge.net http://libfunutil.sourceforge.net).

It provides a framework off of which a wide variety of C++ objects can be serialized and deserialized (saved and loaded) with a trivial amount of effort.

As far as i know Rusty was the one to coin the phrase "s11n" (short for "serialization", in the same way that i18n is short for "internationalization").

In addition to the API documentation, please see the library manual, available in the source tree, in the docs subdir. It is also available for download on our web site in other formats (i.e., not LyX).

The most important concepts for clients to understand:

See the source tree, under src/client/sample, for many examples of client code.


Function Documentation

template<typename NodeType, typename ChildType>
void s11n::add_child NodeType &  parent,
ChildType *  ch
[inline]
 

Adds ch as a child of parent.

Parent takes over ownership of ch.

NodeType must have a node_traits<> specialization.

Definition at line 597 of file algo.hpp.

template<typename SerializableType>
void s11n::cleanup_serializable SerializableType *&  s  )  throw ()
 

This overload provides cleanup handling for pointer types.

This simplifies many algorithms over using s11n_traits<SerializableType>::cleanup_functor directly, as the algorithms do not need to care if they're using pointer-qualified types or not in order to clean them up properly.

SerializableType requirements are as for the non-pointered variant of this function, plus:

  • delete aSerializableTypeInstance; must be well-formed and must neither throw nor invoke undefined behaviour. (Did you realize that "neither" is an exception to English's "i-before-e" rule?)

This function does nothing if s is null, otherwise it calls cleanup_serializable(*s), deletes s, then assigns it to 0.

Postcondition: (0 == s)

Added in 1.1.3.

template<typename SerializableType>
void s11n::cleanup_serializable SerializableType &  s  )  throw ()
 

Calls s11n_traits<SerializableType>::cleanup_functor()(s).

This function is declared as no-throw because of its logical role in the destruction process, and dtors are normally prohibited from throwing. Any exceptions caught by this function are silently ignored (a warning might go out to a debug channel, probably cerr, but don't rely on it).

SerializableType requirements:

  • Must be a Serializable. Specifically, it must have an s11n_traits specialization installed.

Technically, if the type can be delete()d without leaking pointers, it's safe for use with this function, but this function SHOULD NOT be used as general cleanup tool. It is ONLY intended to be used with REGISTERED Serializables.

This function guarantees not to leak when "cleaning up" containers holding unmanaged pointers as long as the associated cleanup_functors do their part. The model is such that once a cleanup_functor is in place for a given type, this function will inherently walk it and invoke the cleanup rules, which includes freeing any pointers along the way.

Added in 1.1.3.

template<typename InputIt, typename OutputIt, typename UnaryPredicate>
OutputIt s11n::copy_if InputIt  first,
InputIt  last,
OutputIt  result,
UnaryPredicate  pred
 

For each item in [first,last), copies the item to OutputIt if pred(*item) returns true.

Code copied from:

http://www.bauklimatik-dresden.de/privat/nicolai/html/en/cpp.html

Definition at line 98 of file algo.hpp.

template<typename NodeType>
NodeType& s11n::create_child NodeType &  parent,
const std::string  nodename
 

Creates a new node, named nodename, as a child of parent.

Returns a reference to the new child, which parent now owns.

NodeType must have a node_traits<> specialization or work using the default.

Development tip: this function often comes in handy during serialization.

template<typename IterT>
void s11n::delete_objects IterT  begin,
IterT  end
 

For each item in [begin,end) object_deleter()(*item) is called.

After this call the container from which the iterators come still contains the items but they are invalid - deleted pointers. The client should call erase(begin,end) to delete the entries, or use convenience function free_list_entries(), which accepts a list-style container and empties the list.

DEPRECATED: this will be removed in favor of cleanup_serializable().

Deprecated:

Definition at line 178 of file algo.hpp.

template<typename DeserializableT, typename BinaryFunctorT>
deserializable_f<DeserializableT,BinaryFunctorT> s11n::deser_f DeserializableT &  ref,
BinaryFunctorT  f
[inline]
 

Added in 1.1.3.

Returns deserializable_f<DeserializableT,BinaryFunctorT>( ref, f ).

ref must outlive the object returned by this function!

Definition at line 768 of file functional.hpp.

template<typename DeserializableT>
deserializable_f<DeserializableT> s11n::deser_f DeserializableT &  ref  )  [inline]
 

Added in 1.1.3.

Returns deserializable_f<DeserializableT>( ref ).

ref must outlive the object returned by this function!

Definition at line 754 of file functional.hpp.

template<typename BinaryFunctorT>
deserialize_from_subnode_f<BinaryFunctorT> s11n::deser_from_subnode_f const std::string &  subnodename,
BinaryFunctorT  f
[inline]
 

Returns deserialize_from_subnode_f<BinaryFunctorT>( parent, subnodename, f ).

Added in 1.1.3.

Definition at line 1114 of file functional.hpp.

deserialize_from_subnode_f s11n::deser_from_subnode_f const std::string &  subnodename  )  [inline]
 

Returns deserialize_from_subnode_f<>( parent, subnodename ).

Added in 1.1.3.

Definition at line 1103 of file functional.hpp.

template<typename NodeType, typename BinaryFunctorT>
deserialize_from_subnode_unary_f<NodeType,BinaryFunctorT> s11n::deser_from_subnode_unary_f const NodeType &  parent,
const std::string &  subnodename,
BinaryFunctorT  f
[inline]
 

Experimental.

Added in 1.1.3.

Returns deserialize_from_subnode_unary_f<NodeType,BinaryFunctorT>( parent, subnodename, f ).

Definition at line 1177 of file functional.hpp.

template<typename NodeType>
deserialize_from_subnode_unary_f<NodeType> s11n::deser_from_subnode_unary_f const NodeType &  parent,
const std::string &  subnodename
[inline]
 

Returns deserialize_from_subnode_unary_f<NodeType>( parent, subnodename ).

Added in 1.1.3.

Definition at line 1166 of file functional.hpp.

template<typename NodeType, typename DeserializableT>
deserialize_nullary_f<NodeType,DeserializableT> s11n::deser_nullary_f NodeType const &  n,
DeserializableT &  s
[inline]
 

Returns deserialize_nullary_f<NodeType,DeserializableT>( n, s );.

Definition at line 614 of file functional.hpp.

template<typename NodeType, typename DeserializableT, typename BinaryFunctorT>
deserialize_nullary_f<NodeType,DeserializableT,BinaryFunctorT> s11n::deser_nullary_f NodeType const &  n,
DeserializableT &  s,
BinaryFunctorT const &  f
[inline]
 

Returns deserialize_nullary_f<NodeType,DeserializableT,BinaryFunctorT>( n, s, f ).

Definition at line 604 of file functional.hpp.

template<typename SerializableType, typename OutIterator>
deserialize_to_output_iter_f<SerializableType,OutIterator> s11n::deser_to_outiter_f OutIterator  target  )  [inline]
 

Convenience function returning:.

deserialize_to_output_iter_f<SerializableType,OutIterator>( target )

Definition at line 875 of file functional.hpp.

template<typename SerializableType, typename OutIterator, typename BinaryFunctorT>
deserialize_to_output_iter_f<SerializableType,OutIterator,BinaryFunctorT> s11n::deser_to_outiter_f OutIterator  target,
BinaryFunctorT  f
[inline]
 

Convenience function returning:.

deserialize_to_output_iter_f<SerializableType,OutIterator,BinaryFunctorT>( target, f )

Definition at line 863 of file functional.hpp.

template<typename DataNodeType, typename DeserializableT>
DeserializableT* s11n::deserialize const DataNodeType &  src  ) 
 

Tries to deserialize a DeserializableT from src, using s11n_traits<DeserializableT>::factory_type()(node_traits<DataNodeType>::class_name(src)) to create a new DeserializableT.

DeserializableT may not be a pointer-qualified type.

On error it returns 0 or propagates on an exception, otherwise returns a pointer to a new object, which the caller takes ownership of.

As of 1.1.3, this function relies on s11n::cleanup_serializable() in order to be able to specify what happens to the internally allocated object if deserialization fails. That function is called on the object before this function returns if deserialization fails.

Prior to 1.1.3 this function would leak if this function failed and if DeserializableT contained unmanaged pointers (even indirectly, via sub-containment), such as in list<int*> or list<map<int,string*>>.

template<typename DataNodeType, typename DeserializableT>
bool s11n::deserialize const DataNodeType &  src,
cleanup_ptr< DeserializableT > &  target
 

Identical to deserialize(const DataNodeType&,DeserializableT*&) except that it works on a cleanup_ptr<>.

The target may be empty (pointing to zero): if it is then dynamic loading is attempted, as described in the docs for the non-cleanup_ptr variant of this function.

Returns true if deserialization to the target succeeds, else false. If it returns false, target.get() still points to the same object it did when function was called (which may be 0). Whether or not the contained object is modified on deserialization failure depends on the underlying algorithm used to deserialize it.

template<typename DataNodeType, typename DeserializableT>
bool s11n::deserialize const DataNodeType &  src,
DeserializableT *&  target
 

Like the standard form of deserialize(), but if passed a null pointer, it attempts to classload the class and assign the passed-in pointer to it.

If passed a non-null target then it behaves as if target were a reference, simply passing on the target after dereferencing it.

For example:

T * t = 0;
deserialize<NodeType,T>( mynode, t );
t will be non-0 if it worked.

T * x = new X;
if( deserialize<NodeType,T>( mynode, x ) )
{
x is now populated exactly as if we had called:
deserialize<NodeType,T>( mynode, *x );
}

To get the class name, the algorithm first tries node_traits<DataNodeType>::class_name(src). If it cannot load a class using that name, it tries s11n_traits<DeserializableT>::class_name(target).

Underlying calls to s11n::cl::classload() and serialization proxies may throw. If they do, the exception is passed on to the caller.

If passed a null pointer and this function fails, target is not modified. If deserialization fails, any internally-created (DeserializableT*) is deallocated using cleanup_serializable(). If passed a non-null pointer and the function fails, behaviour is as for the non-pointer variant of deserialize() - target may or may not be in a defined state, as defined by the specific proxy algorithm.

Added in s11n version 1.1.3.

template<typename DataNodeType, typename DeserializableT>
bool s11n::deserialize const DataNodeType &  src,
DeserializableT &  target
 

Deserializes target from src using the default API marshaling mechanism.

Returns true on success.

On error it returns false or passes on an exception. In either case, target might be in an undefined state, and may need manual interaction to free up resources (e.g., a list of pointers might have some pointers which need to be cleaned up during exception handling). The exact definition of its state after a failure is specified by the algorithm which deserializes the target (as defined via s11n_traits<DeserializableT>::deserialize_functor).

Referenced by s11n::io::data_node_serializer< NodeType >::deserialize().

template<typename DataNodeType, typename DeserializableT>
DeserializableT* s11n::deserialize_subnode const DataNodeType &  src,
const std::string &  subnodename
 

If a child named subnodename is found in src then this function returns the result of deserialize(child), otherwise it returns 0.

The function might throw, as it uses the two-arg form of deserialize().

This is a convenience function: not part of the s11n kernel.

Changed in 1.1.3:

template<typename DataNodeType, typename DeserializableT>
bool s11n::deserialize_subnode const DataNodeType &  src,
const std::string &  subnodename,
DeserializableT &  target
 

If a child named subnodename is found in src then this function returns deserialize( child, target ) and returns it's result, otherwise it returns 0.

The function might throw, as it uses the two-arg form of deserialize().

This is a convenience function: not part of the s11n kernel.

Changed in 1.1.3:

template<typename NodeT>
NodeT* s11n::find_child_by_name NodeT &  parent,
const std::string &  name
 

A non-const overload of find_child_by_name().

Functionally identical to the const form, except for the constness of the parent argument and return value.

Ownership of the returned pointer is not changed by calling this function (normally parent owns it, but clients may change that without affecting this function). When in doubt, i.e. during "normal usage", do NOT delete the returned pointer, because the parent node owns it. This function can be used to find a child for manual removal from parent via the API for the node_traits<NodeT>::children(parent) object.

template<typename NodeT>
const NodeT* s11n::find_child_by_name const NodeT &  parent,
const std::string &  name
 

Finds the FIRST child in parent with the given name and returns a pointer to it, or 0 if no such child is found.

Ownership of the child does not change by calling this function: parent still owns it.

Complexity is linear.

Referenced by s11n::deserialize_from_subnode_unary_f< NodeType, BinaryFunctorT >::operator()(), and s11n::deserialize_from_subnode_f< BinaryFunctorT >::operator()().

template<typename NodeT, typename DestContainerT>
size_t s11n::find_children_by_name const NodeT &  parent,
const std::string &  name,
DestContainerT &  target
 

Each child in parent.children() which has the given name is copied into the target container.

Returns the number of items added to target.

DestContainerT must support an insert iterator which will insert the pointer type contained in the list returned by parent.children(). i.e., it must hold (const NodeT *).

Ownership of the children do not change by calling this function. Normally they are owned by the parent node (unless the client explicitely does something to change that).

std::string s11n::library_version  ) 
 

Returns the string form of the s11n library version.

logical_and_binary_f s11n::logical_and  )  [inline]
 

Returns logical_and_binary().

Definition at line 1257 of file functional.hpp.

template<typename F1>
logical_and_unary_f<F1> s11n::logical_and F1 const &  f1  )  [inline]
 

Returns logical_and_unary<F1>(f1).

Definition at line 1248 of file functional.hpp.

template<typename F1, typename F2>
logical_and_nullary_f<F1,F2> s11n::logical_and F1 const &  f1,
F2 const &  f2
[inline]
 

Returns logical_and_nullary<F1,F2>(f1,f2).

Definition at line 1238 of file functional.hpp.

template<typename NodeType>
node_to_deserialize_unary_f<NodeType> s11n::node_to_deser_unary_f NodeType const &  n  )  [inline]
 

Returns node_to_deserialize_unary_f<NodeType>(n).

Definition at line 463 of file functional.hpp.

template<typename NodeType, typename BinaryFunctorT>
node_to_deserialize_unary_f<NodeType,BinaryFunctorT> s11n::node_to_deser_unary_f NodeType const &  n,
BinaryFunctorT const &  f
 

Returns node_to_deserialize_unary_f<NodeType,BinaryFunctorT>(n,f).

Definition at line 453 of file functional.hpp.

template<typename NodeType>
node_to_serialize_unary_f<NodeType> s11n::node_to_ser_unary_f NodeType &  n  ) 
 

Returns node_to_serialize_unary_f<NodeType>(n).

Definition at line 421 of file functional.hpp.

template<typename NodeType, typename BinaryFunctorT>
node_to_serialize_unary_f<NodeType,BinaryFunctorT> s11n::node_to_ser_unary_f NodeType &  n,
BinaryFunctorT  f
 

Returns node_to_serialize_unary_f<NodeType,BinaryFunctorT>(n,f).

Definition at line 411 of file functional.hpp.

template<typename T>
reference_f<T> s11n::ref T &  ref  )  [inline]
 

Convenience function to return reference_f<T>(ref).

Added in 1.1.3.

Definition at line 115 of file functional.hpp.

template<typename NodeType, typename Type1, typename Type2>
bool s11n::s11n_cast const Type1 &  t1,
Type2 &  t2
 

"Casts" t1 to t2 using serialization.

This will work whenever t1 and t2 are "semantically compatible", whatever that really means. It can be used, e.g., to copy a list<int> to a vector<double>, provided both types have been proxied. In practice, this means: if Type1 and Type2 both use the same, or compatible, de/ser algorithms, they are s11n_cast-able to one another.

Note that in the case of containers, the pointerness of the contained types is irrelevant: this works on both, thus a list<int> can be "cast" to a vector<double*>.

As usual for a failed deserialization, if it returns false then t2 may be in an undefined state. There is no guaranty, however, that t2's deserialize operator will ever be called, as the serialization of t1 must first succeed for that to happen.

Type2 may not currently be a pointer type, but Type1 may be. This will be fixed someday (when someone complains).

Exceptions and errors:

On error this function will return false or propagate an exception, as dictated by serialize() and then deserialize() (in that order).

If Type1 and Type2 are not guaranteed to be monomorphic or base-most Serializable types, then it is good practice to explicitely specify them as templatized parameters, and not rely on implicit type selection, which might choose the wrong type (not the base-most one, which is what s11n is "keyed" to), which will mean that s11n "can't find" the registration code for the type.

Definition at line 407 of file s11nlite.hpp.

References s11nlite::instance().

template<typename DataNodeType, typename SerializableType>
SerializableType* s11n::s11n_clone const SerializableType &  tocp  ) 
 

Clones an arbitrary SerializableType using its DataNodeType serialization implementation.

This function was renamed from clone() in version 1.1.

Definition at line 398 of file s11nlite.hpp.

References s11nlite::instance().

template<typename SerializableT, typename BinaryFunctorT>
serializable_f<SerializableT,BinaryFunctorT> s11n::ser_f SerializableT const &  ref,
BinaryFunctorT  f
[inline]
 

Experimental.

Added in 1.1.3.

Returns serializable_f<SerializableT,BinaryFunctorT>( ref, f ).

ref must outlive the object returned by this function!

Definition at line 691 of file functional.hpp.

template<typename SerializableT>
serializable_f<SerializableT> s11n::ser_f SerializableT const &  ref  )  [inline]
 

Experimental.

Added in 1.1.3.

Returns serializable_f<SerializableT>( ref ).

ref must outlive the object returned by this function!

Definition at line 677 of file functional.hpp.

template<typename NodeType, typename SerializableT>
serialize_nullary_f<NodeType,SerializableT> s11n::ser_nullary_f NodeType &  n,
SerializableT const &  s
[inline]
 

Returns serialize_nullary_f<NodeType,SerializableT>( n, s ).

Definition at line 379 of file functional.hpp.

template<typename NodeType, typename SerializableT, typename BinaryFunctorT>
serialize_nullary_f<NodeType,SerializableT,BinaryFunctorT> s11n::ser_nullary_f NodeType &  n,
SerializableT const &  s,
BinaryFunctorT const &  f
[inline]
 

Returns serialize_nullary_f<NodeType,SerializableT,BinaryFunctorT>( n, s, f ).

Definition at line 369 of file functional.hpp.

template<typename SerT>
serializable_to_deserialize_unary_f<SerT> s11n::ser_to_deser_unary_f SerT const &  s  )  [inline]
 

Returns serializable_to_deserialize_unary_f<SerT>( s ).

Definition at line 553 of file functional.hpp.

template<typename SerT, typename BinaryFunctorT>
serializable_to_deserialize_unary_f<SerT,BinaryFunctorT> s11n::ser_to_deser_unary_f SerT &  s,
BinaryFunctorT const &  f
[inline]
 

Returns serializable_to_deserialize_unary_f<SerT,BinaryFunctorT>( s, f ).

Definition at line 543 of file functional.hpp.

template<typename SerT>
serializable_to_serialize_unary_f<SerT> s11n::ser_to_ser_unary_f SerT const &  s  )  [inline]
 

Returns serializable_to_serialize_unary_f<SerT>( s ).

Definition at line 508 of file functional.hpp.

template<typename SerT, typename BinaryFunctorT>
serializable_to_serialize_unary_f<SerT,BinaryFunctorT> s11n::ser_to_ser_unary_f SerT const &  s,
BinaryFunctorT const &  f
[inline]
 

Returns serializable_to_serialize_unary_f<SerT,BinaryFunctorT>( s, f ).

Definition at line 498 of file functional.hpp.

template<typename BinaryFunctorT>
serialize_to_subnode_f<BinaryFunctorT> s11n::ser_to_subnode_f const std::string &  subnodename,
BinaryFunctorT  f
[inline]
 

Returns serialize_to_subnode_f<BinaryFunctorT>( subnodename, f ).

Added in 1.1.3.

Definition at line 952 of file functional.hpp.

serialize_to_subnode_f s11n::ser_to_subnode_f const std::string &  subnodename  )  [inline]
 

Returns serialize_to_subnode_f<>( subnodename ).

Added in 1.1.3.

Definition at line 940 of file functional.hpp.

template<typename NodeType, typename BinaryFunctorT>
serialize_to_subnode_unary_f<NodeType,BinaryFunctorT> s11n::ser_to_subnode_unary_f NodeType &  parent,
const std::string &  subnodename,
BinaryFunctorT  f
[inline]
 

Returns serialize_to_subnode_unary_f<NodeType,BinaryFunctorT>( parent, subnodename, f ).

Example:

	   std::for_each( vec.begin(),
		       vec.end(),
		       ser_to_subnode_f( mynode, "child", my_serialize_to_subnode_unary_functor() )
		       );
	   

Added in 1.1.3.

Definition at line 1049 of file functional.hpp.

template<typename NodeType>
serialize_to_subnode_unary_f<NodeType> s11n::ser_to_subnode_unary_f NodeType &  parent,
const std::string &  subnodename
[inline]
 

Returns serialize_to_subnode_f<NodeType>( parent, subnodename ).

Example:

	   std::for_each( vec.begin(),
		          vec.end(),
		          ser_to_subnode_unary_f( mynode, "child" )
		        );
	   

Added in 1.1.3.

Definition at line 1028 of file functional.hpp.

template<typename DataNodeType, typename SerializableT>
bool s11n::serialize DataNodeType &  target,
const SerializableT &  src
 

Serializes src to target using the default API marshaling mechanism.

On success it always returns true, else false.

If a the underlying operation throws, it will pass on the exception.

Referenced by s11n::io::data_node_serializer< NodeType >::serialize().

template<typename DataNodeType, typename SerializableT>
bool s11n::serialize_subnode DataNodeType &  target,
const std::string &  nodename,
const SerializableT &  src
 

Serializes src to as a subnode of target, named nodename.

Except for the addition of a subnode, it is identical to serialize( target, src ).

If serialization into the subnode throws the subnode is not added to target (it is destroyed) and any exception is propagated back to the caller.

This is a convenience function: not part of the s11n kernel.

Changed in 1.1.3:

Referenced by s11n::subnode_serializer_f< NodeType >::operator()().

template<typename T>
value_f<T> s11n::val const T &  v  )  [inline]
 

Returns value_f<T>(v).

Definition at line 291 of file functional.hpp.

Referenced by s11n::io::key_value_serializer< NodeType >::operator()(), s11n::io::wesnoth_serializer< NodeType >::serialize(), and s11n::io::strtool::translate().


Generated on Mon Dec 26 15:53:18 2005 for libs11n-1.2.3 by  doxygen 1.4.4