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