Commit 59721e0d authored by cutealien's avatar cutealien

SNamePath cleaned up, minor bugfixes, documentation update.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3009 dfc29bdd-3216-0410-991c-e03cc46cb475
parent cf445855
...@@ -26,10 +26,8 @@ struct SNamedPath ...@@ -26,10 +26,8 @@ struct SNamedPath
SNamedPath() {} SNamedPath() {}
//! Constructor //! Constructor
SNamedPath(const path& p) : Path(p), Name(p) SNamedPath(const path& p) : Path(p), Name( PathToName(p) )
{ {
Name.replace( '\\', '/' );
Name.make_lower();
} }
//! Is smaller comparator //! Is smaller comparator
...@@ -38,15 +36,14 @@ struct SNamedPath ...@@ -38,15 +36,14 @@ struct SNamedPath
return Name < other.Name; return Name < other.Name;
} }
//! Set the path. As the name depends on the path it will also be changed. //! Set the path. As the name depends on the path the name will also be changed.
void setPath(const path& p) void setPath(const path& p)
{ {
Path = p; Path = p;
Name = p; Name = PathToName(p);
Name.make_lower();
} }
//! Get the path //! Get the path. This is the original, unprocessed string passed to SNamedPath.
const path& getPath() const const path& getPath() const
{ {
return Path; return Path;
...@@ -61,19 +58,18 @@ struct SNamedPath ...@@ -61,19 +58,18 @@ struct SNamedPath
//! Has the file been given a new name? //! Has the file been given a new name?
bool isRenamed() const bool isRenamed() const
{ {
return !Path.equals_ignore_case(Name); // Note: memory over speed here because of the typical use-cases.
return PathToName(Path) != Name;
} }
//! Get the name which is used to identify the file. By default a lower-case version of the filename. //! Get the name which is used to identify the file.
//! This string is similar to the names and filenames used before Irrlicht 1.7
const path& getName() const const path& getName() const
{ {
return Name; return Name;
} }
//! Returns the name used in serialization //! Returns the string which should be used in serialization.
/** When the name wasn't renamed the path is used otherwise the name is used.
TODO: This is a workaround, as both strings should be serialized in the long run.
*/
const path& getSerializationName() const const path& getSerializationName() const
{ {
if ( isRenamed() ) if ( isRenamed() )
...@@ -81,6 +77,16 @@ struct SNamedPath ...@@ -81,6 +77,16 @@ struct SNamedPath
return Path; return Path;
} }
protected:
// convert the given path string to a name string.
path PathToName(const path& p) const
{
path name(p);
name.replace( '\\', '/' );
name.make_lower();
return name;
}
private: private:
path Path; path Path;
path Name; path Name;
......
Test suite pass at GMT Sun Dec 6 04:47:00 2009 Test suite pass at GMT Sun Dec 6 20:41:05 2009
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment