#include <string>
#include <algorithm>
#include <s11n.net/s11n/s11n_debuggering_macros.hpp>
#include <s11n.net/s11n/serialize.hpp>
#include <s11n.net/s11n/traits.hpp>
#include <s11n.net/s11n/type_traits.hpp>
#include <s11n.net/s11n/algo.tpp>
Go to the source code of this file.
Namespaces | |
namespace | s11n |
namespace | s11n::Detail |
namespace | s11n::debug |
Defines | |
#define | s11n_net_s11n_v1_1_ALGO_HPP_INCLUDED 1 |
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 NodeT> | |
void | dump_node_structure (const NodeT &n, int indentlv=0) |
Dumps a tree-like view of n's structure, excluding properties, to cerr. |
|
|
|
Adds ch as a child of parent. Parent takes over ownership of ch. NodeType must have a node_traits<> specialization. |
|
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 |
|
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. |
|
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().
|
|
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:
|
|
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:
|
|
Dumps a tree-like view of n's structure, excluding properties, to cerr. The second parameter is for use by this function in recursion: do not pass a value for it. |
|
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. |
|
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. |
|
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). |
|
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:
|