Irrlicht 3D Engine
path.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine" and the "irrXML" project.
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __IRR_PATH_H_INCLUDED__
6 #define __IRR_PATH_H_INCLUDED__
7 
8 #include "irrString.h"
9 
10 namespace irr
11 {
12 namespace io
13 {
14 
16 
18 
20 
23 struct SNamedPath
24 {
27 
29  SNamedPath(const path& p) : Path(p), InternalName( PathToName(p) )
30  {
31  }
32 
34  bool operator <(const SNamedPath& other) const
35  {
36  return InternalName < other.InternalName;
37  }
38 
40  void setPath(const path& p)
41  {
42  Path = p;
43  InternalName = PathToName(p);
44  }
45 
47  const path& getPath() const
48  {
49  return Path;
50  };
51 
54  const path& getInternalName() const
55  {
56  return InternalName;
57  }
58 
60  operator core::stringc() const
61  {
62  return core::stringc(getPath());
63  }
65  operator core::stringw() const
66  {
67  return core::stringw(getPath());
68  }
69 
70 protected:
71  // convert the given path string to a name string.
72  path PathToName(const path& p) const
73  {
74  path name(p);
75  name.replace( '\\', '/' );
76  name.make_lower();
77  return name;
78  }
79 
80 private:
81  path Path;
82  path InternalName;
83 };
84 
85 } // io
86 } // irr
87 
88 #endif // __IRR_PATH_H_INCLUDED__
core::string< fschar_t > path
Type used for all file system related strings.
Definition: path.h:17
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
SNamedPath(const path &p)
Constructor.
Definition: path.h:29
bool operator<(const SNamedPath &other) const
Is smaller comparator.
Definition: path.h:34
void setPath(const path &p)
Set the path.
Definition: path.h:40
path PathToName(const path &p) const
Definition: path.h:72
Used in places where we identify objects by a filename, but don't actually work with the real filenam...
Definition: path.h:23
string< T, TAlloc > & make_lower()
Makes the string lower case.
Definition: irrString.h:533
string< c8 > stringc
Typedef for character strings.
Definition: irrString.h:1458
string< T, TAlloc > & replace(T toReplace, T replaceWith)
Replaces all characters of a special type with another one.
Definition: irrString.h:1064
const path & getPath() const
Get the path.
Definition: path.h:47
const path & getInternalName() const
Definition: path.h:54
SNamedPath()
Constructor.
Definition: path.h:26
string< wchar_t > stringw
Typedef for wide character strings.
Definition: irrString.h:1461