Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
path.hh
Go to the documentation of this file.
1 
6 #ifndef VCSN_MISC_PATH_HH
7 # define VCSN_MISC_PATH_HH
8 
9 # include <string>
10 # include <list>
11 
12 # include <vcsn/misc/attributes.hh>
13 # include <vcsn/misc/export.hh>
14 
15 namespace vcsn
16 {
23  {
24  public:
26  class LIBVCSN_API invalid_path : public std::exception
27  {
28  public:
29  invalid_path(const std::string& msg);
30  const char* what() const throw ();
31  virtual ~invalid_path() throw ();
32  private:
33  std::string msg_;
34  };
35 
37  using value_type = std::string;
38 
41 
43 
45  path(const std::string& p);
46 
49  path(const char* p);
51 
54 
56  path& operator/=(const path& rhs);
59  path operator/(const path& rhs) const;
60  bool operator==(const path& rhs) const ATTRIBUTE_PURE;
61 
62  std::string basename() const;
64  std::string extension() const;
66 
68  static path cwd();
69 
71  bool is_absolute() const;
72 
76  path parent_path() const;
77 
79  path filename() const;
80 
84  using path_type = std::list<std::string>;
85  const std::string& string() const;
86  const char* c_str() const;
87  path_type components() const;
88  std::ostream& dump(std::ostream& ostr) const;
90 
91  const value_type& value_get() const;
92  value_type& value_get();
93 
94  private:
97 
99  static const char separator_ = '/';
100  };
101 
103  path absolute(const path& p);
104 
106  bool exists(const path& p);
107 
108 
110  std::ostream& operator<<(std::ostream& o, const path& p);
111 }
112 
113 # include <vcsn/misc/path.hxx>
114 
115 #endif // !VCSN_MISC_PATH_HH
value_type value_
Wrapped value.
Definition: path.hh:96
std::ostream & operator<<(std::ostream &os, direction d)
Pretty-printing.
Definition: direction.cc:19
Inline implementation of vcsn::path.
Paths in filesystems, i.e., file names.
Definition: path.hh:22
std::string msg_
Definition: path.hh:33
std::list< std::string > path_type
Definition: path.hh:84
bool operator==(empty_t, empty_t)
Definition: empty.hh:22
Exception thrown on invalid path.
Definition: path.hh:26
#define LIBVCSN_API
Definition: export.hh:9
std::string value_type
The "native" type we wrap.
Definition: path.hh:37
bool exists(const path &p)
Definition: path.cc:98
path absolute(const path &p)
Definition: path.cc:104