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

s11n::list Namespace Reference

The s11n::list namespace defines functors and algorithms for working with std::list/vector-style containers. More...


Classes

class  list_serializer_proxy
 list_serializer_proxy is a functor for de/serializing lists of Serializables. More...

Functions

template<typename NodeT, typename ListType>
bool serialize_pointer_list (NodeT &dest, const std::string &subnodename, const ListType &src)
 Deprecated.
template<typename NodeT, typename ListType>
bool deserialize_pointer_list (const NodeT &src, const std::string &subnodename, ListType &dest)
 Deprecated.
template<typename NodeType, typename SerType>
bool serialize_list (NodeType &dest, const SerType &src)
 serialize_list() supports list/vector-like types containing any Serializable type.
template<typename NodeType, typename SerType>
bool serialize_list (NodeType &dest, const std::string &subnodename, const SerType &src)
 Identical to the two-argument form of serialize_list(), but serializes src into a subnode of dest, named subnodename.
template<typename NodeType, typename SerType>
bool deserialize_list (const NodeType &src, SerType &dest)
 For each (src.children().begin(),end()] an object of type SerType::value_type is created, deserialized, and is added to dest via push_back( item ).
template<typename NodeType, typename SerType>
bool deserialize_list (const NodeType &src, const std::string &subnodename, SerType &dest)
 Identical to the two-argument form of deserialize_list(), but deserializes a subnode of src, named subnodename.
template<typename NodeType, typename ListType>
size_t serialize_streamable_list (NodeType &dest, const ListType &src)
 serialize_streamable_list serializes objects of type std::list<X> (and compatible list types, such as std::vector).
template<typename NodeType, typename ListType>
size_t serialize_streamable_list (NodeType &dest, const std::string &subnodename, const ListType &src)
 Identical to serialize_streamable_list(dest,src), but creates a subnode in dest, named subnodename, where the data is stored.
template<typename NodeType, typename ListType>
size_t deserialize_streamable_list (const NodeType &src, ListType &dest)
 Deserializes dest from src.
template<typename NodeType, typename ListType>
size_t deserialize_streamable_list (const NodeType &src, const std::string &subnodename, ListType &dest)
 Identical to deserialize_streamable_list(), but looks for the data in a subnode of src named subnodename.


Detailed Description

The s11n::list namespace defines functors and algorithms for working with std::list/vector-style containers.

Function Documentation

template<typename NodeType, typename SerType>
bool s11n::list::deserialize_list const NodeType &  src,
const std::string &  subnodename,
SerType &  dest
 

Identical to the two-argument form of deserialize_list(), but deserializes a subnode of src, named subnodename.

If no such child is found in src then false is returned.

Definition at line 237 of file list.h.

References s11n::find_child_by_name().

template<typename NodeType, typename SerType>
bool s11n::list::deserialize_list const NodeType &  src,
SerType &  dest
 

For each (src.children().begin(),end()] an object of type SerType::value_type is created, deserialized, and is added to dest via push_back( item ).

See serialize_list() for the list type requirements.

If SerType::value_type is a pointer type then dest owns any newly-created pointers, and it's owner (or the container itself) is responsible for cleaning them up. (Non-pointer types need no explicit clean-up, of course.)

Returns true if all deserializations succeed. Stops processing and returns false at the first error, in which case dest is in an undefined state: some children may or may not have been successfully deserialized into it. The immediate implication of this is that it will fail if src contains any other children than the type which dest expects!

Definition at line 196 of file list.h.

References s11n::deserialize(), and s11n::dump_node_debug().

Referenced by s11n::list::list_serializer_proxy::operator()().

template<typename NodeT, typename ListType>
bool s11n::list::deserialize_pointer_list const NodeT &  src,
const std::string &  subnodename,
ListType &  dest
 

Deprecated.

See deserialize_list().

The complement to serialize_pointer_list().

Looks for child nodes of src named subnodename. For each one that it finds it tries to deserialize it to a (ListType::value_type) and insert it into dest.

Returns false only if children are found but their deserialization fails. If that happens, dest is in an undefined state: any other children (not the one which failed deserialization) might still be in the list, and there is know way for the client to know which child failed or why it failed.

Definition at line 75 of file list.h.

References s11n::copy_if().

template<typename NodeType, typename ListType>
size_t s11n::list::deserialize_streamable_list const NodeType &  src,
const std::string &  subnodename,
ListType &  dest
 

Identical to deserialize_streamable_list(), but looks for the data in a subnode of src named subnodename.

Returns 0 if no child could be found.

Definition at line 354 of file list.h.

References s11n::find_child_by_name().

template<typename NodeType, typename ListType>
size_t s11n::list::deserialize_streamable_list const NodeType &  src,
ListType &  dest
 

Deserializes dest from src.

It reads in all properties from src, ignoring their keys and taking only their values. This is suitable for use with the result of a serialize_streamable_list() call. See that function for more information, including the conventions which must be supported by NodeType and ListType.

Returns the number of items deserialized.

Definition at line 331 of file list.h.

template<typename NodeType, typename SerType>
bool s11n::list::serialize_list NodeType &  dest,
const SerType &  src
 

serialize_list() supports list/vector-like types containing any Serializable type.

Serializes (src.begin(),src.end()] to dest. Each item has a node name of that given to the ctor or an unspecified dummy value.

Returns true on success. If false is returned then dest is in an undefined state: some number of serializations may have succeeded before the failure. This operation stops processing at the first serialization error.

Compatible ListTypes must support:

  • a value_type typedef describing the type of it's contents.

  • push_back( value_type )

  • const_iterator typedefs.

Restrictions on value_type's type:

  • Must be a Serializable. This includes any i/o streamable type which has a proxy installed by s11n (includes all PODs and std::string by default).

  • may be a pointer type.

Some s11n-side requirements:

  • ListType must be registered with the ListType classloader.

ACHTUNG: never pass the same destination container to this function more than once or you will get duplicate and/or incorrect data.

Definition at line 134 of file list.h.

References s11n::dump_node_debug(), and s11n::serialize().

Referenced by s11n::list::list_serializer_proxy::operator()().

template<typename NodeT, typename ListType>
bool s11n::list::serialize_pointer_list NodeT &  dest,
const std::string &  subnodename,
const ListType &  src
 

Deprecated.

See serialize_list().

Serializes all Serializable objects in the given list.

ListType must contain ([const] SomeSerializableType *).

True is returned on success.

False is returned if any child Serializable in src fails to serialize. If false is returned then dest is in an undefined state: it may have been partially serialized, and certainly wasn't *completely* serialized.

Note that a subnodename is required because it is patentedly a Bad Idea to store more than one Serializable in the same node, so this function creates subnodes in dest.

Definition at line 47 of file list.h.

template<typename NodeType, typename ListType>
size_t s11n::list::serialize_streamable_list NodeType &  dest,
const ListType &  src
 

serialize_streamable_list serializes objects of type std::list<X> (and compatible list types, such as std::vector).

It stores them in such a way that they can be loaded into any compatible container via deserialize_streamable_list().

Conventions:

  • NodeType must support a generic set(Key,Val) function, as implemented by the s11n::data_node interface.

  • ListType must conform to std::list conventions and it's value_type must be a non-pointer type which is i/ostreamable (this includes all PODs and std::string). Pointers are not supported by this function.

ACHTUNG:

  • This function sets dummy property keys, both to please the conventions of keys having non-empty values and to keep the list in the proper order. It uses keys which should be portable to, e.g., standard XML.

Returns the number of items serialized.

Definition at line 278 of file list.h.


Generated on Thu Jun 16 16:18:13 2005 for s11n by  doxygen 1.4.3-20050530