xml_resource_node.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2016 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 
35 namespace 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 }
XMLResourceDocument get_document()
Returns the resource document owning the resource.
FileSystem get_file_system() const
Returns the file system to load resource from.
Definition: clanapp.h:35
std::string get_type() const
Returns the resource type.
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.
I/O Device interface.
Definition: iodevice.h:49
std::string get_base_path() const
Returns the base path of the resource.
DOM Element class.
Definition: dom_element.h:59
Virtual File System (VFS).
Definition: file_system.h:46
Generic read access.
Definition: file.h:60
bool is_null() const
Open existing file. Fails if it does not exist.
Definition: file.h:92
All other sharing flags combined.
Definition: file.h:82
DomElement & get_element()
Returns the DOM element describing the resource.
OpenMode
File opening modes.
Definition: file.h:86
XML Resource Document.
Definition: xml_resource_document.h:47
Resource node for a XMLResourceDocument.
Definition: xml_resource_node.h:45
std::string get_name() const
Returns the name of the resource.
bool operator==(const XMLResourceNode &other) const
Compares this resource to another resource.