3 This file is part of libmsppath
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_PATH_PATH_H_
9 #define MSP_PATH_PATH_H_
31 Iterator &operator++();
32 Iterator &operator--();
33 std::string operator*() const;
34 bool operator==(const Iterator &i) const { return (start==i.start && end==i.end); }
35 bool operator!=(const Iterator &i) const { return !(*this==i); }
40 Iterator(const Path &);
46 Path(const std::string &p) { init(p); }
47 Path(const char *p) { init(p); }
48 const std::string &str() const { return path; }
49 unsigned size() const;
50 bool empty() const { return path.empty(); }
51 bool is_absolute() const;
52 Path subpath(unsigned, unsigned =static_cast<unsigned>(-1)) const;
53 Path operator/(const Path &p) const { Path a=*this; a/=p; return a; }
54 Path &operator/=(const Path &);
55 std::string operator[](int) const;
56 bool operator==(const Path &) const;
57 Iterator begin() const { return Iterator(*this); }
58 Iterator end() const { Iterator i(*this); i.start=i.end=std::string::npos; return i; }
62 void init(const std::string &);
63 void add_component(const std::string &);
66 inline std::ostream &operator<<(std::ostream &o, const Path &p) { o<<p.str(); return o; }