From fbc986fca28ce01240718a7835ee7e4798b5d20d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 6 Jul 2012 15:32:05 +0300 Subject: [PATCH] Add other comparison operators to FS::Path --- source/fs/path.cpp | 24 +++++++++++++++++++++--- source/fs/path.h | 6 ++++++ 2 files changed, 27 insertions(+), 3 deletions(-) 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