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 
47 {
50 
51 public:
53 
55 
59 
60 public:
61  bool is_null() const;
62 
64  std::string get_type() const;
65 
67  std::string get_name() const;
68 
71 
74 
77 
79  std::string get_base_path() const;
80 
84 
85 public:
87 
92  IODevice open_file(const std::string &filename,
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 
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.
std::string get_base_path() const
Returns the base path of the resource.
Resource node for a XMLResourceDocument.
Definition: xml_resource_node.h:47
I/O Device interface.
Definition: iodevice.h:51
FileSystem get_file_system() const
Returns the file system to load resource from.
std::string get_name() const
Returns the name of the resource.
@ open_existing
Open existing file. Fails if it does not exist.
Definition: file.h:99
@ access_read
Generic read access.
Definition: file.h:67
DomElement & get_element()
Returns the DOM element describing the resource.
Definition: clanapp.h:36
Virtual File System (VFS).
Definition: file_system.h:48
XML Resource Document.
Definition: xml_resource_document.h:49
OpenMode
File opening modes.
Definition: file.h:94
XMLResourceDocument get_document()
Returns the resource document owning the resource.
@ share_all
All other sharing flags combined.
Definition: file.h:89
DOM Element class.
Definition: dom_element.h:60
std::string get_type() const
Returns the resource type.
bool is_null() const
bool operator==(const XMLResourceNode &other) const
Compares this resource to another resource.