X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fpath.h;fp=source%2Ffs%2Fpath.h;h=9bc93f6c003eab2db5a695c2a312c9b1db1fc4c8;hp=d515d7817031c1df3f98d0ad459c92a597b0dbcc;hb=05f7e9b4c6f804102f261517c8ecdd338e1f67d3;hpb=96dadad38bc0b114174a7d4a707cdd8e88fce3aa diff --git a/source/fs/path.h b/source/fs/path.h index d515d78..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; + 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(); @@ -86,8 +93,8 @@ public: bool operator>=(const Path &other) const { return !(*this