From: Mikko Rasa Date: Fri, 6 Jul 2012 12:32:05 +0000 (+0300) Subject: Add other comparison operators to FS::Path X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=fbc986fca28ce01240718a7835ee7e4798b5d20d;ds=sidebyside Add other comparison operators to FS::Path --- diff --git a/source/fs/path.cpp b/source/fs/path.cpp index 035e220..c56505e 100644 --- a/source/fs/path.cpp +++ b/source/fs/path.cpp @@ -183,12 +183,30 @@ string Path::operator[](int n) const throw invalid_argument("Path::operator[]"); } -bool Path::operator==(const Path &p) const +bool Path::operator==(const Path &other) const { #ifdef WIN32 - return !strcasecmp(path, p.path); + return strcasecmp(path, other.path)==0; #else - return path==p.path; + return path==other.path; +#endif +} + +bool Path::operator<(const Path &other) const +{ +#ifdef WIN32 + return strcasecmp(path, other.path)<0; +#else + return path(const Path &other) const +{ +#ifdef WIN32 + return strcasecmp(path, other.path)>0; +#else + return path>other.path; #endif } diff --git a/source/fs/path.h b/source/fs/path.h index c3c599a..c701e60 100644 --- a/source/fs/path.h +++ b/source/fs/path.h @@ -80,6 +80,12 @@ public: std::string operator[](int) const; bool operator==(const Path &) const; + bool operator<(const Path &) const; + bool operator>(const Path &) const; + bool operator<=(const Path &other) const { return !(*this>other); } + bool operator>=(const Path &other) const { return !(*this