TREE: Add documentation of emplace functions

This commit is contained in:
Patrick Pelissier committed 2023-01-28 14:48:58 +01:00
1 parent e421851525
commit 840226c7fd
1 file changed
+26 -2
+26 -2
View File
@@ -851,9 +851,9 @@ which types can be used to construct the object and which methods to use to cons
* EMPLACE\_TYPE( (typeA, typeB, ...) ) means that the object can be constructed from the lists of types 'typeA, typeB, ...' using the method of the INIT_WITH operator. An emplace function without suffix will be generated.
* EMPLACE\_TYPE( LIST( (suffix, function, typeA, typeB, ...), (suffix, function, typeA, typeB, ...), ...) means that the object can be constructed from all the provided lists of types 'typeA, typeB, ...' using the provided method 'function'. The 'function' is the method to call to construct the object from the list of types. It supports API transformation if needed. As many emplace function will be generated as there are constructor function. Each generated function will be generated by suffixing it with the provided 'suffix' (if suffix is empty, no suffix will be added).
For example, for an ARRAY definition named vec, if there is such a definition of EMPLACE\_TYPE(const char *), it will generate a function vec_emplace_back(const char *). This function will take a const char * parameter, construct the object from it (for example a string\_t) then push the result back on the array.
For example, for an ARRAY definition named vec, if there is such a definition of EMPLACE\_TYPE(const char *), it will generate a function vec\_emplace\_back(const char *). This function will take a const char * parameter, construct the object from it (for example a string\_t) then push the result back on the array.
Another example, for an ARRAY definition named vec, if there is such a definition of EMPLACE\_TYPE( LIST( (_ui, mpz\_init\_set\_ui, unsigned int), (_si, mpz\_init\_set\_si, int) ) ), it will generate two functions vec_emplace_back_ui(unsigned int) and vec_emplace_back_si(int). Theses functions will take the (unsigned) int parameter, construct the object from it then push the result back on the array.
Another example, for an ARRAY definition named vec, if there is such a definition of EMPLACE\_TYPE( LIST( (_ui, mpz\_init\_set\_ui, unsigned int), (_si, mpz\_init\_set\_si, int) ) ), it will generate two functions vec\_emplace\_back\_ui(unsigned int) and vec\_emplace\_back\_si(int). Theses functions will take the (unsigned) int parameter, construct the object from it then push the result back on the array.
If the container is an associative array, the name will be constructed as follow:
name\_emplace[\_key\_keysuffix][\_val\_valsuffix]
@@ -3131,6 +3131,14 @@ won't move on inserting a new node.
Set the tree to a single root node and set this node to 'value'.
##### name\_it\_t name\_emplace\_root\[suffix\](name\_t tree, args...)
Set the tree to a single root node and set this node to the value
initialized with the given args.
The provided arguments shall therefore match one of the constructor provided
by the EMPLACE\_TYPE operator.
See emplace chapter for more details.
##### it\_t name\_insert\_up\_raw(it\_t ref)
##### it\_t name\_insert\_left\_raw(it\_t ref)
##### it\_t name\_insert\_right\_raw(it\_t ref)
@@ -3172,6 +3180,22 @@ It returns an iterator to the inserted node.
name\_move\_down will move all children of the referenced node as children of the inserted children,
whereas name\_move\_down will insert the node as the new first child of the referenced node.
##### it\_t name\_emplace\_up\[suffix\](it\_t ref, args...)
##### it\_t name\_emplace\_left\[suffix\](it\_t ref, args...)
##### it\_t name\_emplace\_right\[suffix\](it\_t ref, args...)
##### it\_t name\_emplace\_down\[suffix\](it\_t ref, args...)
##### it\_t name\_emplace\_child\[suffix\](it\_t ref, args...)
Insert a node up (resp. left, right, down and down) the given referenced iterator
and initialize this node to the value initialized with the given args.
The provided arguments shall therefore match one of the constructor provided
by the EMPLACE\_TYPE operator.
See emplace chapter for more details.
It returns an iterator to the inserted node.
name\_emplace\_down will move all children of the referenced node as children of the inserted children,
whereas name\_emplace\_down will insert the node as the new first child of the referenced node.
##### type *name\_up\_ref(name\_it\_t it)
##### type *name\_down\_ref(name\_it\_t it)
##### type *name\_left\_ref(name\_it\_t it)