Vcsn  2.8
Be Rational
vcsn::file_library Class Reference

Manage search paths. More...

#include <file-library.hh>

Collaboration diagram for vcsn::file_library:

Classes

class  not_found
 Exception thrown when a file cannot be located. More...
 

Public Types

using self_t = file_library
 
using path = boost::filesystem::path
 
using path_list_type = std::list< path >
 Yes, a list is really handy here, for push/pop front. More...
 
using strings_type = std::vector< std::string >
 

Public Member Functions

template<typename ForwardRange >
file_librarypush_back (const ForwardRange &r, const char *sep)
 
template<typename Iterable >
file_librarypush_back (const std::string &user_path, const Iterable &default_path, const char *sep)
 
Constructor.

An empty library.

 file_library ()
 
 file_library (const path &p)
 Init the library with one path. More...
 
 file_library (const std::string &library, const char *separator)
 Init the library with a string to split at separator. More...
 
template<typename ForwardRange >
 file_library (const ForwardRange &r, const char *sep)
 Handle a list of search-paths. More...
 
Managing inclusion paths.
self_tpush_back (const path &p)
 
self_tpush_back (const std::string &library, const char *separator)
 Split library on separator and put at the end of path list. More...
 
template<typename ForwardRange >
self_tpush_back (const ForwardRange &r, const char *sep)
 Handle a list of search-paths. More...
 
template<typename Iterable >
self_tpush_back (const std::string &user_path, const Iterable &default_path, const char *sep)
 
self_tappend (const path &p)
 
self_tpush_front (const path &p)
 
self_tpush_front (const std::string &library, const char *separator)
 Split library on separator and put at the beginning of path list. More...
 
self_tprepend (const path &p)
 
current directory.
void push_current_directory (const path &p)
 
void pop_current_directory ()
 
path current_directory_get () const
 
Finding files.
path find_file (const path &file) const
 Search a file. More...
 
Printing.
std::ostream & dump (std::ostream &ostr) const
 
Accessor.
const path_list_typesearch_path_get () const
 
path_list_typesearch_path ()
 

Static Public Member Functions

static strings_type split (const std::string &lib, const char *sep)
 Split lib at each occurrence of sep, return the list of components. More...
 

Private Member Functions

void push_cwd ()
 Push the working directory on the stack. More...
 
path find_in_search_path (const path &filename) const
 Find file filename using include path. More...
 

Private Attributes

path_list_type search_path_
 Inclusion path list. More...
 
path_list_type current_directory_
 Current directory stack. More...
 

Detailed Description

Manage search paths.

Store a search path and all informations used for handling paths when processing import directives.

Definition at line 22 of file file-library.hh.

Member Typedef Documentation

◆ path

using vcsn::file_library::path = boost::filesystem::path

Definition at line 27 of file file-library.hh.

◆ path_list_type

Yes, a list is really handy here, for push/pop front.

Definition at line 29 of file file-library.hh.

◆ self_t

Definition at line 25 of file file-library.hh.

◆ strings_type

using vcsn::file_library::strings_type = std::vector<std::string>

Definition at line 96 of file file-library.hh.

Constructor & Destructor Documentation

◆ file_library() [1/4]

vcsn::file_library::file_library ( )

Definition at line 33 of file file-library.cc.

References push_cwd().

Here is the call graph for this function:

◆ file_library() [2/4]

vcsn::file_library::file_library ( const path p)

Init the library with one path.

Definition at line 38 of file file-library.cc.

References push_back(), and push_cwd().

Here is the call graph for this function:

◆ file_library() [3/4]

vcsn::file_library::file_library ( const std::string &  library,
const char separator 
)

Init the library with a string to split at separator.

Definition at line 46 of file file-library.cc.

References push_back(), and push_cwd().

Here is the call graph for this function:

◆ file_library() [4/4]

template<typename ForwardRange >
vcsn::file_library::file_library ( const ForwardRange &  r,
const char sep 
)

Handle a list of search-paths.

Parameters
rthe collection of search-paths. each occurrence of an additional colon marks the place where the following search-paths will be inserted. If there is none, the remaining components are ignored.
septhe separator to split search-paths (typically colon).

Definition at line 12 of file file-library.hxx.

References push_back(), and push_cwd().

Here is the call graph for this function:

Member Function Documentation

◆ append()

file_library & vcsn::file_library::append ( const path p)
inline

Definition at line 78 of file file-library.hxx.

References push_back().

Here is the call graph for this function:

◆ current_directory_get()

auto vcsn::file_library::current_directory_get ( ) const

Definition at line 111 of file file-library.cc.

References current_directory_.

Referenced by find_file().

◆ dump()

std::ostream & vcsn::file_library::dump ( std::ostream &  ostr) const

Definition at line 158 of file file-library.cc.

References search_path_.

Referenced by vcsn::operator<<().

◆ find_file()

auto vcsn::file_library::find_file ( const path file) const

Search a file.

Determine real path of file, by looking in search path if necessary.

Returns
Path for file.
Exceptions
not_foundfile cannot be found, in which case errno is set to ENOENT.

Definition at line 119 of file file-library.cc.

References current_directory_get(), find_in_search_path(), and vcsn::file_library::not_found::not_found().

Here is the call graph for this function:

◆ find_in_search_path()

auto vcsn::file_library::find_in_search_path ( const path filename) const
private

Find file filename using include path.

Returns
Absolute path where the file lies.
Exceptions
not_foundfile not found.

Definition at line 141 of file file-library.cc.

References vcsn::file_library::not_found::not_found(), and search_path_.

Referenced by find_file().

Here is the call graph for this function:

◆ pop_current_directory()

void vcsn::file_library::pop_current_directory ( )

Definition at line 104 of file file-library.cc.

References current_directory_.

◆ prepend()

file_library & vcsn::file_library::prepend ( const path p)
inline

Definition at line 84 of file file-library.hxx.

References push_front().

Here is the call graph for this function:

◆ push_back() [1/6]

template<typename ForwardRange >
file_library& vcsn::file_library::push_back ( const ForwardRange &  r,
const char sep 
)

Definition at line 20 of file file-library.hxx.

References push_back(), and split().

Here is the call graph for this function:

◆ push_back() [2/6]

template<typename Iterable >
file_library& vcsn::file_library::push_back ( const std::string &  user_path,
const Iterable &  default_path,
const char sep 
)

Definition at line 47 of file file-library.hxx.

References push_back(), and split().

Here is the call graph for this function:

◆ push_back() [3/6]

file_library & vcsn::file_library::push_back ( const path p)

Definition at line 66 of file file-library.cc.

References search_path_.

Referenced by append(), file_library(), and push_back().

◆ push_back() [4/6]

file_library & vcsn::file_library::push_back ( const std::string &  library,
const char separator 
)

Split library on separator and put at the end of path list.

Definition at line 73 of file file-library.cc.

References push_back(), and split().

Here is the call graph for this function:

◆ push_back() [5/6]

template<typename ForwardRange >
self_t& vcsn::file_library::push_back ( const ForwardRange &  r,
const char sep 
)

Handle a list of search-paths.

Parameters
rthe collection of search-paths. each occurrence of an additional colon marks the place where the following search-paths will be inserted. If there is none, the remaining components are ignored.
septhe separator to split search-paths (typically colon).

◆ push_back() [6/6]

template<typename Iterable >
self_t& vcsn::file_library::push_back ( const std::string &  user_path,
const Iterable &  default_path,
const char sep 
)

◆ push_current_directory()

void vcsn::file_library::push_current_directory ( const path p)

Definition at line 98 of file file-library.cc.

References current_directory_.

Referenced by push_cwd().

◆ push_cwd()

void vcsn::file_library::push_cwd ( )
private

Push the working directory on the stack.

Definition at line 27 of file file-library.cc.

References push_current_directory().

Referenced by file_library().

Here is the call graph for this function:

◆ push_front() [1/2]

file_library & vcsn::file_library::push_front ( const path p)

Definition at line 82 of file file-library.cc.

References search_path_.

Referenced by prepend(), and push_front().

◆ push_front() [2/2]

file_library & vcsn::file_library::push_front ( const std::string &  library,
const char separator 
)

Split library on separator and put at the beginning of path list.

Warning
"a:b:c" will end with "c" first, then "b", then "a", then what was already here.

Definition at line 89 of file file-library.cc.

References push_front(), and split().

Here is the call graph for this function:

◆ search_path()

file_library::path_list_type & vcsn::file_library::search_path ( )
inline

Definition at line 96 of file file-library.hxx.

References search_path_.

◆ search_path_get()

const file_library::path_list_type & vcsn::file_library::search_path_get ( ) const
inline

Definition at line 90 of file file-library.hxx.

References search_path_.

Referenced by vcsn::detail::xlt_advise::open().

◆ split()

auto vcsn::file_library::split ( const std::string &  lib,
const char sep 
)
static

Split lib at each occurrence of sep, return the list of components.

Behaves especially on Windows when splitting on ":", in order to preserve drive prefixes (i.e., "c:foo:d:bar" is split in "c:foo", "d:bar").

Definition at line 53 of file file-library.cc.

References vcsn::res.

Referenced by push_back(), and push_front().

Member Data Documentation

◆ current_directory_

path_list_type vcsn::file_library::current_directory_
private

Current directory stack.

Definition at line 142 of file file-library.hh.

Referenced by current_directory_get(), pop_current_directory(), and push_current_directory().

◆ search_path_

path_list_type vcsn::file_library::search_path_
private

Inclusion path list.

Definition at line 139 of file file-library.hh.

Referenced by dump(), find_in_search_path(), push_back(), push_front(), search_path(), and search_path_get().


The documentation for this class was generated from the following files: