xml_resource_node.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 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#pragma once
30
31#include "../Resources/xml_resource_document.h"
32#include "../../Core/IOData/file_system.h"
33#include <memory>
34
35namespace clan
36{
39
40 class DomElement;
41 class XMLResourceDocument;
42 class XMLResourceNode_Impl;
43
46 {
47 public:
50
51 bool is_null() const;
52
54 std::string get_type() const;
55
57 std::string get_name() const;
58
61
64
67
69 std::string get_base_path() const;
70
72
77 IODevice open_file(const std::string &filename,
79 unsigned int access = File::access_read,
80 unsigned int share = File::share_all,
81 unsigned int flags = 0) const;
82
84 bool operator ==(const XMLResourceNode &other) const;
85
86 private:
91 XMLResourceNode(DomElement element, XMLResourceDocument &resource_document);
92
93 std::shared_ptr<XMLResourceNode_Impl> impl;
94
95 friend class XMLResourceDocument;
96 };
97
99}
DOM Element class.
Definition dom_element.h:60
Virtual File System (VFS).
Definition file_system.h:47
@ share_all
All other sharing flags combined.
Definition file.h:82
@ access_read
Generic read access.
Definition file.h:60
OpenMode
File opening modes.
Definition file.h:87
@ open_existing
Open existing file. Fails if it does not exist.
Definition file.h:92
I/O Device interface.
Definition iodevice.h:50
XML Resource Document.
Definition xml_resource_document.h:48
Resource node for a XMLResourceDocument.
Definition xml_resource_node.h:46
std::string get_name() const
Returns the name of the resource.
bool is_null() const
std::string get_base_path() const
Returns the base path of the resource.
DomElement & get_element()
Returns the DOM element describing the resource.
XMLResourceDocument get_document()
Returns the resource document owning the resource.
bool operator==(const XMLResourceNode &other) const
Compares this resource to another resource.
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.
FileSystem get_file_system() const
Returns the file system to load resource from.
std::string get_type() const
Returns the resource type.
Definition clanapp.h:36