Microsoft Information Protection SDK - C++ 1.17
API Reference Documentation for C++
Loading...
Searching...
No Matches
xml_node.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 */
33#ifndef API_MIP_XML_NODE_H_
34#define API_MIP_XML_NODE_H_
35
36#include <memory>
37#include <string>
38#include <vector>
39
40#include "mip/mip_namespace.h"
41
42MIP_NAMESPACE_BEGIN
43
44namespace xml {
45
47 std::string prefix;
48 std::string uri;
49};
50
54enum class XmlNodeType : int {
55 UNKNOWN = -1,
56 NONE = 0,
57 ELEMENT = 1,
58 ATTRIBUTE = 2,
59 TEXT = 3,
60 CDATA = 4,
62 ENTITY = 6,
64 COMMENT = 8,
65 DOCUMENT = 9,
66 DOCUMENT_TYPE = 10,
68 NOTATION = 12,
69 WHITESPACE = 13,
71 END_ELEMENT = 15,
72 END_ENTITY = 16,
74};
75
81/* Example XML for methods
82(1) <bk:book xmlns:bk='testbook' bk:ISBN='1-861001-57-5'>
83(2) <title>
84(3) Pride And Prejudice
85(4) </title>
86(5) <author>Jane Austen</author>
87(6) </bk:book>
88*/
89class XmlNode {
90public:
100 virtual std::string GetAttributeValue(const std::string& attributeName) const = 0;
108 virtual std::vector<std::pair<std::string, std::string>> GetAttributes() const = 0;
116 virtual std::shared_ptr<XmlNode> GetNextNode() const = 0;
124 virtual std::shared_ptr<XmlNode> GetFirstChild() const = 0;
132 virtual std::string GetName() const = 0;
140 virtual std::string GetContent() const = 0;
148 virtual std::string GetInnerText() const = 0;
157 virtual XmlNamespace GetNamespace() const = 0;
163 virtual XmlNodeType GetNodeType() const = 0;
169 virtual bool IsNull() const = 0;
170
177 virtual void AddAttribute(const std::string& attributeName, const std::string& attributeValue) = 0;
178
186 virtual int RemoveAttribute(const std::string& attributeName) = 0;
194 virtual std::shared_ptr<XmlNode> AddNewChild(const std::string& name) = 0;
203 virtual std::shared_ptr<XmlNode> AddNewChild(const std::string& name, const std::string& namespaceName) = 0;
211 virtual bool AddContent(const std::string& content) = 0;
217 virtual bool RemoveNodeFromDocument() = 0;
218
220 virtual ~XmlNode() {}
222};
223
224} // xml
225
226MIP_NAMESPACE_END
227
228#endif // API_MIP_XML_NODE_H_
Definition xml_node.h:89
virtual std::shared_ptr< XmlNode > AddNewChild(const std::string &name)=0
Add a child to this XmlNode. New child is inserted after any existing children.
virtual std::string GetContent() const =0
virtual std::shared_ptr< XmlNode > GetFirstChild() const =0
virtual std::string GetAttributeValue(const std::string &attributeName) const =0
virtual std::vector< std::pair< std::string, std::string > > GetAttributes() const =0
virtual int RemoveAttribute(const std::string &attributeName)=0
Removes a node property by name.
virtual void AddAttribute(const std::string &attributeName, const std::string &attributeValue)=0
Add a property to an existing node.
virtual std::string GetName() const =0
virtual std::shared_ptr< XmlNode > GetNextNode() const =0
virtual bool RemoveNodeFromDocument()=0
Remove this node and children from the xml document.
virtual std::shared_ptr< XmlNode > AddNewChild(const std::string &name, const std::string &namespaceName)=0
Add a child to this XmlNode. New child is inserted after any existing children.
virtual XmlNodeType GetNodeType() const =0
Get the type of node this xml is represented as.
virtual std::string GetInnerText() const =0
virtual bool IsNull() const =0
See if the object has been initialized with an underlying xml node.
virtual XmlNamespace GetNamespace() const =0
virtual bool AddContent(const std::string &content)=0
Add inner text to this xml node.
MIP namespace macros.
Definition xml_load_exception.h:12
XmlNodeType
Constants for the different types of xml elements nodes.
Definition xml_node.h:54
Definition xml_node.h:46
std::string prefix
Definition xml_node.h:47
std::string uri
Definition xml_node.h:48