xml_resource_node.h Source File - ClanLib SDK
Description: xml_resource_node.h Source File

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
45 class XMLResourceNode
46 {
47 public:
48 XMLResourceNode();
49 ~XMLResourceNode();
50
51 bool is_null() const;
52
54 std::string get_type() const;
55
57 std::string get_name() const;
58
60 DomElement &get_element();
61
63 XMLResourceDocument get_document();
64
66 FileSystem get_file_system() const;
67
69 std::string get_base_path() const;
70
72
77 IODevice open_file(const std::string &filename,
78 File::OpenMode mode = File::open_existing,
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}
clan::DomElement
DOM Element class.
Definition dom_element.h:60
clan::FileSystem
Virtual File System (VFS).
Definition file_system.h:47
clan::File::share_all
@ share_all
All other sharing flags combined.
Definition file.h:82
clan::File::access_read
@ access_read
Generic read access.
Definition file.h:60
clan::File::OpenMode
OpenMode
File opening modes.
Definition file.h:87
clan::File::open_existing
@ open_existing
Open existing file. Fails if it does not exist.
Definition file.h:92
clan::IODevice
I/O Device interface.
Definition iodevice.h:50
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::get_name
std::string get_name() const
Returns the name of the resource.
clan::XMLResourceNode::XMLResourceNode
XMLResourceNode()
clan::XMLResourceNode::is_null
bool is_null() const
clan::XMLResourceNode::get_base_path
std::string get_base_path() const
Returns the base path of the resource.
clan::XMLResourceNode::get_element
DomElement & get_element()
Returns the DOM element describing the resource.
clan::XMLResourceNode::get_document
XMLResourceDocument get_document()
Returns the resource document owning the resource.
clan::XMLResourceNode::operator==
bool operator==(const XMLResourceNode &other) const
Compares this resource to another 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::XMLResourceNode::get_file_system
FileSystem get_file_system() const
Returns the file system to load resource from.
clan::XMLResourceNode::get_type
std::string get_type() const
Returns the resource type.
clan::XMLResourceNode::~XMLResourceNode
~XMLResourceNode()
clan
Definition clanapp.h:36