X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fpath.h;h=6aa16f6d08191a9d7d4000f8f9be65ee4d6217a6;hp=749578a8797cf519695d0e9b321819987aa76521;hb=8552e6a4e4fbc454e08c582d1dbcd55ab58a3c37;hpb=7563bb650aa11207a7c128ba44468cf5ad2897c7 diff --git a/source/fs/path.h b/source/fs/path.h index 749578a..6aa16f6 100644 --- a/source/fs/path.h +++ b/source/fs/path.h @@ -34,11 +34,11 @@ public: Iterator(const Path &); public: - Iterator &operator++(); - Iterator &operator--(); + 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 !(*this==i); } + bool operator==(const Iterator &i) const { return (start==i.start && end==i.end); } + bool operator!=(const Iterator &i) const { return !(*this==i); } }; private: @@ -48,13 +48,16 @@ public: Path(); Path(const std::string &); Path(const char *); +private: + void init(const std::string &); +public: const std::string &str() const { return path; } /// Returns the number of components in the path. - unsigned size() const; + unsigned size() const; - bool empty() const { return path.empty(); } + bool empty() const { return path.empty(); } /// Determines whether the path starts from the root directory bool is_absolute() const; @@ -66,18 +69,19 @@ public: Path operator/(const Path &p) const; Path &operator/=(const Path &); - /** - Extracts a single component from the path. Negative indices count from the - end of the path. - */ - std::string operator[](int) const; - - bool operator==(const Path &) const; - Iterator begin() const; - Iterator end() const; private: - void init(const std::string &); + /** Adds a component to the path. It must not contain the directory + separator character. */ void add_component(const std::string &); + +public: + /** Extracts a single component from the path. Negative indices count from + the end of the path. */ + std::string operator[](int) const; + + bool operator==(const Path &) const; + Iterator begin() const; + Iterator end() const; }; inline std::ostream &operator<<(std::ostream &o, const Path &p) { o<