#include <s11n.net/s11n/classload.hpp>
#include <s11n.net/s11n/io/data_node_io.hpp>
#include <s11n.net/s11n/s11n_config.hpp>
Go to the source code of this file.
Namespaces | |
namespace | s11n |
namespace | s11n::io |
Defines | |
#define | s11n_SERIALIZERS_HPP_INCLUDED 1 |
Functions | |
template<typename NodeT, typename ListT> | |
void | serializer_list (ListT &target, bool onlyShortNames=true) |
Intended mainly as a convenience for client applications, serializer_list() populates the target list with the names of registered Serializers. | |
template<typename SerializerT> | |
void | register_serializer (const std::string &classname, const std::string &alias) |
Registers a Serializer type with the s11n::io layer. | |
template<typename NodeT> | |
s11n::io::data_node_serializer< NodeT > * | create_serializer (const std::string &classname) |
Returns a new instance of the given serializer class, or 0 if one could not be loaded. |
|
Definition at line 2 of file serializers.hpp. |
|
Returns a new instance of the given serializer class, or 0 if one could not be loaded. e.g., register_serializer() will do the trick. If no serializer for classname is found and classname does not contain the string "_serializer", then then (classname+"_serializer") is tried. This is intended to ease DLL lookups for the conventional abbreviations for the Serializer classes (i.e., my_serializer). The caller owns the returned pointer, which may be 0. Definition at line 158 of file serializers.hpp. |
|
Registers a Serializer type with the s11n::io layer. It must:
i.e., the conventions of all of the Serializers included with libs11n. Registering makes the type available to the data_node_serializer classloader. Arguments:
SerializeT's magic_cookie() function is called to alias the cookie as an alias for classname. Thus, a SerializerT object is (briefly) instantiated. Node that this function essentially performs the same operations as the reg_serializer.hpp supermacro, and the two should be equivalent (though this seems easier to use). Definition at line 128 of file serializers.hpp. |
|
Intended mainly as a convenience for client applications, serializer_list() populates the target list with the names of registered Serializers. ListT must support push_back(std::string). If onlyShortNames is true (the default) then only "simple" names (only alphanumeric or underscore characters) are put into target, not the "full" names of the classes. This is to make the data more useful in the context of client applications as, e.g., a list of choices for users. When onlyShortNames is false then the list may contain some unsightly magic cookie strings. In either case, the list may very well contain different names for the same underlying Serializer, as most are registered with several aliases. Note that only serializers extending from s11n::io::data_node_serializer<NodeT> are returned. The exact values returned by this function may change in the future. e.g., at the moment it does not return the "real" classnames, only registered aliases, but this is arguable behaviour and may change. Maintenance note: i don't encourage the direc use of s11n::fac here, but that is currently the only way to get the list of class names from the factory layer. Definition at line 51 of file serializers.hpp. |