NCBI C++ ToolKit
deref_impl.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /*
2  * Redistribution and use in source and binary forms, with or without
3  * modification, are permitted provided that the following conditions
4  * are met:
5  *
6  * 1. Redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer.
8  * 2. Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in
10  * the documentation and/or other materials provided with the
11  * distribution.
12  * 3. Neither the name of the Author nor the names of its contributors
13  * may be used to endorse or promote products derived from this software
14  * without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
20  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 /*
31  * $Id: deref_impl.hpp 66006 2015-01-21 17:09:53Z satskyse $
32  */
33 
34 /** @file
35  * This file contains declarations required for iterators dereferencing
36  * support.
37 **/
38 
39 
40 
41 #ifndef _xmlwrapp_deref_impl_h_
42 #define _xmlwrapp_deref_impl_h_
43 
44 // xmlwrapp includes
47 #include <misc/xmlwrapp/node.hpp>
48 
49 #include "pimpl_base.hpp"
50 
51 // libxml2 includes
52 #include <libxml/tree.h>
53 
54 namespace xml
55 {
56  namespace impl
57  {
58 
59  /*
60  * The struct is used to keep a list of the default attributes proxies
61  * which help to track attributes conversions from default to non default ones
62  */
63  struct phantom_attr
64  {
65  xmlAttributePtr def_prop_; // Must always be set correspondingly
66  xmlAttrPtr prop_; // Set if only this default attribute has been converted
67  struct phantom_attr * next; // The next phantom attribute
68  };
69 
70  /*
71  * The struct is used to keep a list of attributes to which a pointer
72  * or a reference was provided when an iterator's operator*() or
73  * operator->() was used.
74  */
76  {
78  struct attr_instance * next;
79 
81  attr_(att), next(NULL)
82  {}
83  };
84 
85 
87  {
91  };
92 
93 
94  /* libxml2 will call it each time a node is destroyed.
95  * The function cleans up the linked list of the
96  * phantom_attrs attached to the node, the linked list of dereferenced
97  * attributes and the dereferenced node
98  */
99  void cleanup_node(xmlNodePtr xmlnode);
100 
101  /* Attaches a new private data structure to the node if it has not been
102  * attached yet.
103  * The argument is actually of type xmlNodePtr
104  */
106 
107  /* Searches for a dereferenced attribute and provides a reference to
108  * it. If not found then a new node is inserted.
109  */
110  void * get_ptr_to_attr_instance(void * att);
111 
112  /* Recursively invalidates the default attributes iterators.
113  * It needs to be done when a swap is done between documents and the
114  * user has already created iterators to the default attributes
115  */
116  void invalidate_default_attr_iterators(xmlNodePtr xmlnode);
117 
118  } // end impl namespace
119 
120 
121 } // end xml namespace
122 
123 #endif
124 
This file contains the definition of the xml::attributes class.
The xml::attributes::attr class is used to hold information about one attribute.
Definition: attributes.hpp:151
The xml::node class is used to hold information about one XML node.
Definition: node.hpp:106
#define NULL
Definition: ncbistd.hpp:225
XML namespace API for XmlWrapp.
This file contains the definition of the xml::node class.
void * get_ptr_to_attr_instance(void *)
Definition: deref_impl.cpp:119
void cleanup_node(xmlNodePtr xmlnode)
Definition: deref_impl.cpp:52
void invalidate_default_attr_iterators(xmlNodePtr xmlnode)
Definition: deref_impl.cpp:141
node_private_data * attach_node_private_data(void *)
Definition: deref_impl.cpp:95
XML library namespace.
Definition: attributes.hpp:57
struct attr_instance * next
Definition: deref_impl.hpp:78
xml::attributes::attr attr_
Definition: deref_impl.hpp:77
attr_instance(const xml::attributes::attr &att)
Definition: deref_impl.hpp:80
struct attr_instance * attr_instances_
Definition: deref_impl.hpp:89
struct phantom_attr * phantom_attrs_
Definition: deref_impl.hpp:88
xmlAttributePtr def_prop_
Definition: deref_impl.hpp:65
struct phantom_attr * next
Definition: deref_impl.hpp:67
Modified on Wed Sep 04 14:58:38 2024 by modify_doxy.py rev. 669887