]> git.tdb.fi Git - libs/core.git/commitdiff
Add other comparison operators to FS::Path
authorMikko Rasa <tdb@tdb.fi>
Fri, 6 Jul 2012 12:32:05 +0000 (15:32 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 6 Jul 2012 12:32:05 +0000 (15:32 +0300)
source/fs/path.cpp
source/fs/path.h

index 035e2200609bf5f6b4f1c4e6ca59a31a6e22cf6f..c56505e907eb3fd9ce756f430f23e6f22aed7bd1 100644 (file)
@@ -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<other.path;
+#endif
+}
+
+bool Path::operator>(const Path &other) const
+{
+#ifdef WIN32
+       return strcasecmp(path, other.path)>0;
+#else
+       return path>other.path;
 #endif
 }
 
index c3c599a9e03d0a0dae8b9e47187086b49b407d1a..c701e60f7fb97dbf507cf0295ea13adefb32aec1 100644 (file)
@@ -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<other); }
+       bool operator!=(const Path &other) const { return !(*this==other); }
+
        Iterator begin() const;
        Iterator end() const;
 };