#include <ostream>
#include <string>
+#include <vector>
namespace Msp {
namespace FS {
*/
class Path
{
+private:
+ typedef std::vector<std::string::size_type> 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<std::string::size_type> separators;
public:
Path();
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<other); }
+ bool operator!=(const Path &other) const { return !(*this==other); }
+
+ Iterator begin() const { return Iterator::at_begin(*this); }
+ Iterator end() const { return Iterator::at_end(*this); }
};
inline std::ostream &operator<<(std::ostream &o, const Path &p) { o<<p.str(); return o; }