xml_resource_node.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28
29
30 #pragma once
31
32 #include "../Resources/xml_resource_document.h"
33 #include "../IOData/file_system.h"
34 #include <memory>
35
36 namespace clan
37 {
40
41 class DomElement;
42 class XMLResourceDocument;
43 class XMLResourceNode_Impl;
44
46 class XMLResourceNode
47 {
50
51 public:
52 XMLResourceNode();
53
54 ~XMLResourceNode();
55
59
60 public:
61 bool is_null() const;
62
64 std::string get_type() const;
65
67 std::string get_name() const;
68
70 DomElement &get_element();
71
73 XMLResourceDocument get_document();
74
76 FileSystem get_file_system() const;
77
79 std::string get_base_path() const;
80
84
85 public:
87
92 IODevice open_file(const std::string &filename,
93 File::OpenMode mode = File::open_existing,
94 unsigned int access = File::access_read,
95 unsigned int share = File::share_all,
96 unsigned int flags = 0) const;
97
99 bool operator ==(const XMLResourceNode &other) const;
100
104
105 private:
106
111 XMLResourceNode(DomElement element, XMLResourceDocument &resource_document);
112
113 std::shared_ptr<XMLResourceNode_Impl> impl;
114
115 friend class XMLResourceDocument;
117 };
118
119 }
120
clan::XMLResourceNode::get_document
XMLResourceDocument get_document()
Returns the resource document owning the resource.
clan::XMLResourceNode::open_file
IODevice open_file(const std::string &filename, File::OpenMode mode=File::open_existing, unsigned int access=File::access_read, unsigned int share=File::share_all, unsigned int flags=0) const
Opens a file relative to the resource base path.
clan
Definition: clanapp.h:35
clan::XMLResourceNode::operator==
bool operator==(const XMLResourceNode &other) const
Compares this resource to another resource.
clan::IODevice
I/O Device interface.
Definition: iodevice.h:50
clan::XMLResourceNode::get_name
std::string get_name() const
Returns the name of the resource.
clan::XMLResourceNode::get_base_path
std::string get_base_path() const
Returns the base path of the resource.
clan::StyleTokenType::string
@ keyword
clan::XMLResourceNode::get_type
std::string get_type() const
Returns the resource type.
clan::DomElement
DOM Element class.
Definition: dom_element.h:59
clan::XMLResourceNode::is_null
bool is_null() const
clan::XMLResourceNode::get_file_system
FileSystem get_file_system() const
Returns the file system to load resource from.
clan::FileSystem
Virtual File System (VFS).
Definition: file_system.h:47
clan::File::access_read
Generic read access.
Definition: file.h:67
clan::XMLResourceNode::~XMLResourceNode
~XMLResourceNode()
clan::File::open_existing
Open existing file. Fails if it does not exist.
Definition: file.h:99
clan::File::share_all
All other sharing flags combined.
Definition: file.h:89
clan::XMLResourceNode::get_element
DomElement & get_element()
Returns the DOM element describing the resource.
clan::File::OpenMode
OpenMode
File opening modes.
Definition: file.h:93
clan::XMLResourceDocument
XML Resource Document.
Definition: xml_resource_document.h:48
clan::XMLResourceNode
Resource node for a XMLResourceDocument.
Definition: xml_resource_node.h:46
clan::XMLResourceNode::XMLResourceNode
XMLResourceNode()