]> git.lizzy.rs Git - irrlicht.git/blob - include/path.h
Add back LightManager
[irrlicht.git] / include / path.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine" and the "irrXML" project.\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __IRR_PATH_H_INCLUDED__\r
6 #define __IRR_PATH_H_INCLUDED__\r
7 \r
8 #include "irrString.h"\r
9 \r
10 namespace irr\r
11 {\r
12 namespace io\r
13 {\r
14 \r
15 //! Type used for all file system related strings.\r
16 /** This type will transparently handle different file system encodings. \r
17     NOTE: For historical reasons the tool-functions using io::path are all in coreutil.h\r
18 */\r
19 typedef core::string<fschar_t> path;\r
20 \r
21 //! Used in places where we identify objects by a filename, but don't actually work with the real filename\r
22 /** Irrlicht is internally not case-sensitive when it comes to names.\r
23     Also this class is a first step towards support for correctly serializing renamed objects.\r
24 */\r
25 struct SNamedPath\r
26 {\r
27         //! Constructor\r
28         SNamedPath() {}\r
29 \r
30         //! Constructor\r
31         SNamedPath(const path& p) : Path(p), InternalName( PathToName(p) )\r
32         {\r
33         }\r
34 \r
35         //! Is smaller comparator\r
36         bool operator <(const SNamedPath& other) const\r
37         {\r
38                 return InternalName < other.InternalName;\r
39         }\r
40 \r
41         //! Set the path.\r
42         void setPath(const path& p)\r
43         {\r
44                 Path = p;\r
45                 InternalName = PathToName(p);\r
46         }\r
47 \r
48         //! Get the path.\r
49         const path& getPath() const\r
50         {\r
51                 return Path;\r
52         };\r
53 \r
54         //! Get the name which is used to identify the file.\r
55         //! This string is similar to the names and filenames used before Irrlicht 1.7\r
56         const path& getInternalName() const\r
57         {\r
58                 return InternalName;\r
59         }\r
60 \r
61         //! Implicit cast to io::path\r
62         operator core::stringc() const\r
63         {\r
64                 return core::stringc(getPath());\r
65         }\r
66         //! Implicit cast to io::path\r
67         operator core::stringw() const\r
68         {\r
69                 return core::stringw(getPath());\r
70         }\r
71 \r
72 protected:\r
73         // convert the given path string to a name string.\r
74         path PathToName(const path& p) const\r
75         {\r
76                 path name(p);\r
77                 name.replace( '\\', '/' );\r
78                 name.make_lower();\r
79                 return name;\r
80         }\r
81 \r
82 private:\r
83         path Path;\r
84         path InternalName;\r
85 };\r
86 \r
87 } // io\r
88 } // irr\r
89 \r
90 #endif // __IRR_PATH_H_INCLUDED__\r