X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fpath.h;h=9bc93f6c003eab2db5a695c2a312c9b1db1fc4c8;hp=c3c599a9e03d0a0dae8b9e47187086b49b407d1a;hb=05f7e9b4c6f804102f261517c8ecdd338e1f67d3;hpb=dce2985e07e6184f000ef176451150710e21ee35 diff --git a/source/fs/path.h b/source/fs/path.h index c3c599a..9bc93f6 100644 --- a/source/fs/path.h +++ b/source/fs/path.h @@ -3,6 +3,7 @@ #include #include +#include namespace Msp { namespace FS { @@ -23,26 +24,32 @@ paths always begin with a single "." component or a sequence ".." components. */ class Path { +private: + typedef std::vector PositionArray; + public: class Iterator { - friend class Path; - private: - const Path &path; - std::string::size_type start, end; + const Path *path; + PositionArray::const_iterator iter; + bool end; - Iterator(const Path &); + Iterator(const Path &, bool = false); public: + static Iterator at_begin(const Path &p) { return Iterator(p); } + static Iterator at_end(const Path &p) { return Iterator(p, true); } + Iterator &operator++(); Iterator &operator--(); std::string operator*() const; - bool operator==(const Iterator &i) const { return (start==i.start && end==i.end); } + bool operator==(const Iterator &i) const { return (iter==i.iter && end==i.end); } bool operator!=(const Iterator &i) const { return !(*this==i); } }; private: std::string path; + std::vector separators; public: Path(); @@ -80,8 +87,14 @@ public: std::string operator[](int) const; bool operator==(const Path &) const; - Iterator begin() const; - Iterator end() 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