Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
xml_reader.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27/**
28 * @brief A file containing the XmlReader interface.
29 *
30 * @file xml_reader.h
31 */
32#ifndef API_MIP_XML_READER_H_
33#define API_MIP_XML_READER_H_
34
35#include <string>
36
37#include "mip/mip_namespace.h"
38#include "mip/xml_node.h"
39
40MIP_NAMESPACE_BEGIN
41
42namespace xml {
43
44/**
45 * @brief XmlReader abstraction class.
46 *
47 */
48class XmlReader {
49public:
50 /**
51 * @brief Reads the next node of the element.
52 *
53 * @warning throws XmlParserException on failure
54 *
55 * @return true if read node successfully.
56 */
57 virtual bool Read() = 0;
58 /**
59 * @brief Get current node type.
60 *
61 * @return Xml Reader Node type.
62 */
63 virtual XmlNodeType GetNodeType() const = 0;
64 /**
65 * @brief Returns the name if found, exception otherwise. empty name is possible.
66 *
67 * @warning throws XmlParserException on failure
68 *
69 * @return node name.
70 */
71 virtual std::string GetName() const = 0;
72 /**
73 * @brief Returns if name was found. Sets name only when true. empty name is possible.
74 *
75 * @return node name.
76 */
77 virtual bool GetName(std::string& name) const = 0;
78 /**
79 * @brief Skips current node until it finds a non empty node.
80 *
81 * @warning throws XmlParserException on failure
82 *
83 * @return true if name successful.
84 */
85 virtual bool Skip() = 0;
86 /**
87 * @brief Returns if value was found. Sets value only when true. empty value is possible..
88 *
89 * @param value output value
90 *
91 * @return true if value exists else false.
92 */
93 virtual bool GetValue(std::string& value) const = 0;
94 /**
95 * @brief Returns current node ancestors (for debug text), in the following purpose <node grand parent attributes=...><node parent><node>.
96 *
97 * @note used for debugging purposes, and error logging.
98 */
99 virtual std::string GetAncestors() const = 0;
100 /**
101 * @brief Returns whether the current node as an empty element.
102 *
103 * @warning throws XmlParserException on failure
104 *
105 * @return true if element is empty.
106 */
107 virtual bool IsEmptyElement() const = 0;
108 /**
109 * @brief Returns true if attributes was found. Sets attribute only when true. empty attribute is possible..
110 *
111 * @param attributeName attribute name.
112 * @param attribute attribute value.
113 * @return true if successful
114 */
115 virtual bool GetAttribute(const std::string& attributeName, std::string& attribute) const = 0;
116 /**
117 * @brief Returns whether the current node has attributes.
118 *
119 * @warning throws XmlParserException on failure
120 *
121 * @return true if the current node has attributes.
122 */
123 virtual bool HasAttributes() const = 0;
124 /**
125 * @brief Move to first attribute.
126 *
127 * @warning throws XmlParserException on failure
128 *
129 * @return true if successful
130 */
131 virtual bool MoveToFirstAttribute() = 0;
132 /**
133 * @brief Move to Next attribute.
134 *
135 * @warning throws XmlParserException on failure
136 *
137 * @return true if successful
138 */
139 virtual bool MoveToNextAttribute() = 0;
140 /**
141 * @brief Move from attribute to element.
142 *
143 * @warning throws XmlParserException on failure
144 *
145 * @return true if successful
146 */
147 virtual bool MoveToElement() = 0;
148 /**
149 * @brief Method returns all node elements in an unmodified way from the original xml.
150 *
151 * @warning throws XmlParserException on failure
152 *
153 * @return entire serialized element.
154 *
155 * @note moved to end of node.
156 */
157 virtual std::string DumpNode() = 0;
158 /** @cond DOXYGEN_HIDE */
159 virtual ~XmlReader() {}
160protected:
161 XmlReader() {}
162 /** @endcond */
163};
164
165} // xml
166
167MIP_NAMESPACE_END
168
169#endif // API_MIP_XML_READER_H_
XmlReader abstraction class.
Definition xml_reader.h:48
virtual std::string GetAncestors() const =0
Returns current node ancestors (for debug text), in the following purpose <node grand parent attribut...
virtual bool GetName(std::string &name) const =0
Returns if name was found.
virtual bool GetValue(std::string &value) const =0
Returns if value was found.
virtual bool Skip()=0
Skips current node until it finds a non empty node.
virtual bool MoveToFirstAttribute()=0
Move to first attribute.
virtual bool MoveToElement()=0
Move from attribute to element.
virtual bool HasAttributes() const =0
Returns whether the current node has attributes.
virtual std::string DumpNode()=0
Method returns all node elements in an unmodified way from the original xml.
virtual XmlNodeType GetNodeType() const =0
Get current node type.
virtual std::string GetName() const =0
Returns the name if found, exception otherwise.
virtual bool GetAttribute(const std::string &attributeName, std::string &attribute) const =0
Returns true if attributes was found.
virtual bool Read()=0
Reads the next node of the element.
virtual bool MoveToNextAttribute()=0
Move to Next attribute.
virtual bool IsEmptyElement() const =0
Returns whether the current node as an empty element.
MIP namespace macros.
XmlNodeType
Constants for the different types of xml elements nodes.
Definition xml_node.h:54
Contains XmlNode interface definition used to interact with xml parsers.