20 Stores a filesystem path. Paths are always stored in a normalized form; there
21 are never any "." or ".." components in the middle of the path, and relative
22 paths always begin with a single "." component or a sequence ".." components.
33 std::string::size_type start, end;
35 Iterator(const Path &);
37 Iterator &operator++();
38 Iterator &operator--();
39 std::string operator*() const;
40 bool operator==(const Iterator &i) const { return (start==i.start && end==i.end); }
41 bool operator!=(const Iterator &i) const { return !(*this==i); }
49 Path(const std::string &);
52 void init(const std::string &);
55 const std::string &str() const { return path; }
57 /// Returns the number of components in the path.
58 unsigned size() const;
60 bool empty() const { return path.empty(); }
62 /// Determines whether the path starts from the root directory
63 bool is_absolute() const;
65 /// Extracts a range of components from the path.
66 Path subpath(unsigned start, unsigned count = static_cast<unsigned>(-1)) const;
68 /// Concatenates this path with another one, with usual filesystem semantics
69 Path operator/(const Path &p) const;
70 Path &operator/=(const Path &);
73 /** Adds a component to the path. It must not contain the directory
74 separator character. */
75 void add_component(const std::string &);
78 /** Extracts a single component from the path. Negative indices count from
79 the end of the path. */
80 std::string operator[](int) const;
82 bool operator==(const Path &) const;
83 Iterator begin() const;
87 inline std::ostream &operator<<(std::ostream &o, const Path &p) { o<<p.str(); return o; }