Vcsn  2.3
Be Rational
path.hh
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <string>
9 #include <list>
10 
11 #include <vcsn/misc/attributes.hh>
12 #include <vcsn/misc/export.hh>
13 
14 namespace vcsn
15 {
22  {
23  public:
25  class LIBVCSN_API invalid_path : public std::exception
26  {
27  public:
28  invalid_path(const std::string& msg);
29  const char* what() const throw ();
30  virtual ~invalid_path() throw ();
31  private:
32  std::string msg_;
33  };
34 
36  using value_type = std::string;
37 
40 
42 
44  path(const std::string& p);
45 
48  path(const char* p);
50 
53 
55  path& operator/=(const path& rhs);
58  path operator/(const path& rhs) const;
59  bool operator==(const path& rhs) const ATTRIBUTE_PURE;
60 
61  std::string basename() const;
63  std::string extension() const;
65 
67  static path cwd();
68 
70  bool is_absolute() const;
71 
75  path parent_path() const;
76 
78  path filename() const;
79 
83  using path_type = std::list<std::string>;
84  const std::string& string() const;
85  const char* c_str() const;
86  path_type components() const;
87  std::ostream& dump(std::ostream& ostr) const;
89 
90  const value_type& value_get() const;
91  value_type& value_get();
92 
93  private:
96 
98  static const char separator_ = '/';
99  };
100 
102  path absolute(const path& p);
103 
105  bool exists(const path& p);
106 
107 
109  std::ostream& operator<<(std::ostream& o, const path& p);
110 }
111 
112 #include <vcsn/misc/path.hxx>
path absolute(const path &p)
Definition: path.cc:104
Inline implementation of vcsn::path.
std::ostream & operator<<(std::ostream &os, direction d)
Pretty-printing.
Definition: direction.cc:19
bool exists(const path &p)
Definition: path.cc:98
Exception thrown on invalid path.
Definition: path.hh:25
std::string value_type
The "native" type we wrap.
Definition: path.hh:36
Paths in filesystems, i.e., file names.
Definition: path.hh:21
Definition: a-star.hh:8
#define LIBVCSN_API
Definition: export.hh:8
std::list< std::string > path_type
Definition: path.hh:83
value_type value_
Wrapped value.
Definition: path.hh:95
std::string msg_
Definition: path.hh:32
bool operator==(empty_t, empty_t)
Definition: empty.hh:21