s11n::cpp0x Namespace Reference

EXPERIMENTAL code based on C++0x features. More...


Classes

struct  count< T, Args...>
struct  count<>

Namespaces

namespace  Detail

Functions

template<typename NodeT, typename SerT, typename... SerList>
bool serialize_group (NodeT &dest, std::string const &groupName, SerT const &src, SerList &&...srcN)
 serialize_group() works similarly to s11n::serialize_subnode(), except that it can be passed one or more Serializables.
template<typename NodeT, typename SerT, typename... SerList>
bool deserialize_group (NodeT const &src, std::string const &groupName, SerT &dest, SerList &&...destN)
 deserialize_group() is the counterpart to serialize_group().
template<typename NodeT, typename SerT, typename... SerList>
bool serialize_subnodes (NodeT &dest, std::string const &name, SerT const &src, SerList &&...srcN)
 A variadic form of s11n::serialize_subnode(), it takes pairs of (string,Serializable) and calls serialize_subnode() for each one.
template<typename NodeT, typename SerT, typename... SerList>
bool deserialize_subnodes (NodeT const &src, std::string const &name, SerT &dest, SerList &&...destN)
 The counterpart to serialize_subnodes().
template<typename NodeT, typename VersionT, typename SerT, typename... SerList>
bool serialize_versioned (NodeT &dest, VersionT ver, SerT const &src, SerList &&...srcN)
 A variadic form of s11n::serialize_versioned(), except that it bundles multiple Serializables with a single version.
template<typename NodeT, typename VersionT, typename SerT, typename... SerList>
bool deserialize_versioned (NodeT &src, VersionT ver, SerT &dest, SerList &&...destN)
 A variadic form of s11n::deserialize_versioned().


Detailed Description

EXPERIMENTAL code based on C++0x features.

Code in this namespace uses C++0x features, as currently supported by gcc 4.3 (at the time of this writing). It won't compile on any older compilers.


Function Documentation

template<typename NodeT, typename SerT, typename... SerList>
bool s11n::cpp0x::deserialize_group ( NodeT const &  src,
std::string const &  groupName,
SerT &  dest,
SerList &&...  destN 
) [inline]

deserialize_group() is the counterpart to serialize_group().

See that function for important caveats.

If src contains no child node named groupName then this function will throw and s11n_exception, otherwise it will return the cumulative success/fail value of deserialization on each item in the list [SerT,SerList]. It will propagate any exceptions throws by the underlying deserialize() calls.

Definition at line 149 of file ohex.hpp.

References s11n::cpp0x::Detail::deserialize_group_impl(), s11n::find_child_by_name(), and S11N_SOURCEINFO.

Referenced by deserialize_versioned().

template<typename NodeT, typename SerT, typename... SerList>
bool s11n::cpp0x::deserialize_subnodes ( NodeT const &  src,
std::string const &  name,
SerT &  dest,
SerList &&...  destN 
) [inline]

The counterpart to serialize_subnodes().

See that function for how it works. Unlike serialize_group(), this function does not care about the order of the (string,Serializable) pairs because they are looked up by name instead of position. (OTOH, this function is slightly slower because of that.)

Definition at line 202 of file ohex.hpp.

References s11n::deserialize_subnode().

template<typename NodeT, typename VersionT, typename SerT, typename... SerList>
bool s11n::cpp0x::deserialize_versioned ( NodeT &  src,
VersionT  ver,
SerT &  dest,
SerList &&...  destN 
) [inline]

A variadic form of s11n::deserialize_versioned().

See the variadic form of serialize_version() for important information.

TODO: try to re-implement in terms of the non-variadic form, to avoid duplicate code/key names.

Definition at line 241 of file ohex.hpp.

References deserialize_group(), and S11N_SOURCEINFO.

template<typename NodeT, typename SerT, typename... SerList>
bool s11n::cpp0x::serialize_group ( NodeT &  dest,
std::string const &  groupName,
SerT const &  src,
SerList &&...  srcN 
) [inline]

serialize_group() works similarly to s11n::serialize_subnode(), except that it can be passed one or more Serializables.

A child node is added to dest, named groupName, and each serializable is serialized as a child of that "group node".

Quite Significant Points of Interest:

(Please do refrain from failing to read these notes!)

#1:

SerT and all of SerList must be Serializable types. NodeT must conform to s11n::node_traits<NodeT> conventions.

#2:

To deserialize items call deserialize_group() with the EXACT same group name and the same types of arguments (but non-const) in the EXACT same order as were passed to the corresponding serialize_group() call. Changing the types or order of the SerT+SerList list will likely lead to deserialization errors when reading data saved using previous calls of serialize_group().

The reason for #2 is because this routine has to synthesize node-name-compatible name tokens for each Serializable. The only halfway reasonable thing it can do is name them numerically. This number, in turn, is used as a lookup key when deserializing, so the object in that position in the deser call needs to be the same (or s11n-compatible) type as the one passed at that arg position to serialize_group().

#3:

The string passed for the groupName parameter should be a unique name amongst the children of the dest node. If it is not unique then deserialization is likely to fail because it might get the wrong child node.

Added in version 1.3.1.

Definition at line 106 of file ohex.hpp.

References s11n::node_traits< NodeT >::class_name(), s11n::create_child(), and s11n::cpp0x::Detail::serialize_group_impl().

Referenced by serialize_versioned().

template<typename NodeT, typename SerT, typename... SerList>
bool s11n::cpp0x::serialize_subnodes ( NodeT &  dest,
std::string const &  name,
SerT const &  src,
SerList &&...  srcN 
) [inline]

A variadic form of s11n::serialize_subnode(), it takes pairs of (string,Serializable) and calls serialize_subnode() for each one.

If the argument list has an odd number of elements then this function will not compile (a static assertion fails).

Definition at line 185 of file ohex.hpp.

References s11n::serialize_subnode().

template<typename NodeT, typename VersionT, typename SerT, typename... SerList>
bool s11n::cpp0x::serialize_versioned ( NodeT &  dest,
VersionT  ver,
SerT const &  src,
SerList &&...  srcN 
) [inline]

A variadic form of s11n::serialize_versioned(), except that it bundles multiple Serializables with a single version.

This function has one notable caveat: it uses serialize_group() to do the leg-work, which means that when you call deserialize_versioned() to fetch the data the arguments passed to it must be of the same type and in the same order as those passed to serialized_versioned(). See serialize_group() for more information on that requirement.

TODO: try to re-implement in terms of the non-variadic form to avoid duplicate code/key names.

Definition at line 226 of file ohex.hpp.

References serialize_group().


Generated on Wed Jun 4 21:47:18 2008 for libs11n by  doxygen 1.5.3