Irrlicht 3D Engine
path.h
Go to the documentation of this file.
00001 // Copyright (C) 2002-2012 Nikolaus Gebhardt
00002 // This file is part of the "Irrlicht Engine" and the "irrXML" project.
00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
00004 
00005 #ifndef __IRR_PATH_H_INCLUDED__
00006 #define __IRR_PATH_H_INCLUDED__
00007 
00008 #include "irrString.h"
00009 
00010 namespace irr
00011 {
00012 namespace io
00013 {
00014 
00016 
00017 typedef core::string<fschar_t> path;
00018 
00020 
00023 struct SNamedPath
00024 {
00026     SNamedPath() {}
00027 
00029     SNamedPath(const path& p) : Path(p), InternalName( PathToName(p) )
00030     {
00031     }
00032 
00034     bool operator <(const SNamedPath& other) const
00035     {
00036         return InternalName < other.InternalName;
00037     }
00038 
00040     void setPath(const path& p)
00041     {
00042         Path = p;
00043         InternalName = PathToName(p);
00044     }
00045 
00047     const path& getPath() const
00048     {
00049         return Path;
00050     };
00051 
00054     const path& getInternalName() const
00055     {
00056         return InternalName;
00057     }
00058 
00060     operator core::stringc() const
00061     {
00062         return core::stringc(getPath());
00063     }
00065     operator core::stringw() const
00066     {
00067         return core::stringw(getPath());
00068     }
00069 
00070 protected:
00071     // convert the given path string to a name string.
00072     path PathToName(const path& p) const
00073     {
00074         path name(p);
00075         name.replace( '\\', '/' );
00076         name.make_lower();
00077         return name;
00078     }
00079 
00080 private:
00081     path Path;
00082     path InternalName;
00083 };
00084 
00085 } // io
00086 } // irr
00087 
00088 #endif // __IRR_PATH_H_INCLUDED__