X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fpath.h;h=82600dc35c28d5787f69b56f0af3b8b12af50f22;hp=210b5d93d14c88bf136d07f25a5ddc78c7fc89e2;hb=5a32939eb6e576c223e1be5f80226d9e628a2398;hpb=6c958cd2d8806063580f836e4c3d486832af9635 diff --git a/source/fs/path.h b/source/fs/path.h index 210b5d9..82600dc 100644 --- a/source/fs/path.h +++ b/source/fs/path.h @@ -10,7 +10,7 @@ namespace FS { enum { -#ifdef WIN32 +#ifdef _WIN32 DIRSEP = '\\' #else DIRSEP = '/' @@ -36,10 +36,18 @@ private: public: class Iterator { + public: + typedef PositionArray::difference_type difference_type; + typedef const std::string value_type; + typedef const std::string *pointer; + typedef const std::string &reference; + typedef std::input_iterator_tag iterator_category; + private: const Path *path; PositionArray::const_iterator iter; bool end; + std::string current; Iterator(const Path &, bool = false); public: @@ -47,10 +55,14 @@ public: static Iterator at_end(const Path &p) { return Iterator(p, true); } Iterator &operator++(); + Iterator operator++(int) { Iterator i = *this; ++*this; return i; } Iterator &operator--(); - std::string operator*() const; + const std::string &operator*() const { return current; } + const std::string *operator->() const { return ¤t; } bool operator==(const Iterator &i) const { return (iter==i.iter && end==i.end); } bool operator!=(const Iterator &i) const { return !(*this==i); } + private: + void update(); }; private: @@ -68,6 +80,9 @@ public: /// Returns the path as a string. const std::string &str() const { return path; } + /// Returns the path as a pointer to a null-terminated string. + const char *c_str() const { return path.c_str(); } + /// Returns the number of components in the path. unsigned size() const;