X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fpath.h;h=1da6a934cd800874107503ab0fea7d259061f951;hp=9e1e3747fed37c0b6687ee48c0925071bbccd6ea;hb=0ba3e9d15af4e8c30eef5445d2b64fee4870505f;hpb=4cc2d6ced17e8cbe1ae3251069131d22a292b857 diff --git a/source/path.h b/source/path.h index 9e1e374..1da6a93 100644 --- a/source/path.h +++ b/source/path.h @@ -1,8 +1,10 @@ -/* +/* $Id$ + This file is part of libmsppath -Copyright © 2006 Mikko Rasa, Mikkosoft Productions +Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ + #ifndef MSP_PATH_PATH_H_ #define MSP_PATH_PATH_H_ @@ -10,7 +12,6 @@ Distributed under the LGPL #include namespace Msp { -namespace Path { enum { @@ -24,19 +25,19 @@ enum class Path { public: - class iterator + class Iterator { 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: const Path &path; unsigned start,end; - iterator(const Path &); + Iterator(const Path &); friend class Path; }; @@ -48,22 +49,22 @@ public: unsigned size() const; bool empty() const { return path.empty(); } bool is_absolute() const; - Path subpath(unsigned, unsigned =(unsigned)-1) const; + Path subpath(unsigned, unsigned =static_cast(-1)) const; Path operator/(const Path &p) const { Path a=*this; a/=p; return a; } Path &operator/=(const Path &); std::string operator[](int) const; bool operator==(const Path &) const; - iterator begin() const { return iterator(*this); } - iterator end() const { iterator i(*this); i.start=i.end=std::string::npos; return i; } + Iterator begin() const { return Iterator(*this); } + Iterator end() const { Iterator i(*this); i.start=i.end=std::string::npos; return i; } private: std::string path; void init(const std::string &); + void add_component(const std::string &); }; inline std::ostream &operator<<(std::ostream &o, const Path &p) { o<