Vcsn  2.3
Be Rational
file-library.hh
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <stdexcept>
9 #include <list>
10 #include <string>
11 
12 #include <vcsn/misc/path.hh>
13 
14 #include <vcsn/misc/export.hh>
15 
16 namespace vcsn LIBVCSN_API
17 {
23  {
24  public:
26 
28  // using path = boost::filesystem::path;
29  using path_list_type = std::list<path>;
30 
32  class LIBVCSN_API not_found : public std::runtime_error
33  {
34  public:
35  not_found(const path& file);
36  };
37 
41  file_library();
43  file_library(const path& p);
45  file_library(const std::string& library, const char* separator);
46 
53  template <typename ForwardRange>
54  file_library(const ForwardRange& r, const char* sep);
56 
59  self_t& push_back(const path& p);
61  self_t& push_back(const std::string& library, const char* separator);
62 
69  template <typename ForwardRange>
70  self_t& push_back(const ForwardRange& r, const char* sep);
71 
72  template <typename Iterable>
73  self_t& push_back(const std::string& user_path,
74  const Iterable& default_path,
75  const char* sep);
76 
77  self_t& append(const path& p);
78 
79  self_t& push_front(const path& p);
80 
84  self_t& push_front(const std::string& library, const char* separator);
85  self_t& prepend(const path& p);
87 
90  void push_current_directory(const path& p);
91  void pop_current_directory();
94 
95 
96  using strings_type = std::list<std::string>;
102  static strings_type split(const std::string& lib, const char* sep);
103 
104 
107 
115  path find_file(const path& file) const;
117 
120  std::ostream& dump(std::ostream& ostr) const;
122 
125  const path_list_type& search_path_get() const;
128 
129  private:
131  void push_cwd();
132 
136  path find_in_search_path(const path& filename) const;
137 
140 
143  };
144 
146  std::ostream& operator<<(std::ostream& o, const file_library& l);
147 
148 }
149 
self_t & push_front(const path &p)
Definition: file-library.cc:81
std::list< std::string > strings_type
Definition: file-library.hh:96
std::ostream & operator<<(std::ostream &os, direction d)
Pretty-printing.
Definition: direction.cc:19
self_t & prepend(const path &p)
path find_in_search_path(const path &filename) const
Find file filename using include path.
void push_current_directory(const path &p)
Definition: file-library.cc:97
const path_list_type & search_path_get() const
std::list< path > path_list_type
Broken on Mac OS X (https://trac.macports.org/ticket/41588).
Definition: file-library.hh:29
void pop_current_directory()
Declaration of vcsn::path.
path_list_type current_directory_
Current directory stack.
Implement inline functions of vcsn/misc/file-library.hh.
path find_file(const path &file) const
Search a file.
Exception thrown when a file cannot be located.
Definition: file-library.hh:32
Paths in filesystems, i.e., file names.
Definition: path.hh:21
Definition: a-star.hh:8
path_list_type & search_path()
self_t & push_back(const path &p)
Definition: file-library.cc:65
#define LIBVCSN_API
Definition: export.hh:8
path_list_type search_path_
Inclusion path list.
std::ostream & dump(std::ostream &ostr) const
self_t & append(const path &p)
path current_directory_get() const
void push_cwd()
Push the working directory on the stack.
Definition: file-library.cc:26
Manage search paths.
Definition: file-library.hh:22
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
static strings_type split(const std::string &lib, const char *sep)
Split lib at each occurrence of sep, return the list of components.
Definition: file-library.cc:52