Vcsn  2.3a
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_list_type = std::list< path >
 Broken on Mac OS X (https://trac.macports.org/ticket/41588). More...
 
using strings_type = std::list< 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

Broken on Mac OS X (https://trac.macports.org/ticket/41588).

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

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

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

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

Constructor & Destructor Documentation

vcsn::file_library::file_library ( )

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

References push_cwd().

Here is the call graph for this function:

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

Init the library with one path.

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

References push_back(), and push_cwd().

Here is the call graph for this function:

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 45 of file file-library.cc.

References push_back(), and push_cwd().

Here is the call graph for this function:

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 13 of file file-library.hxx.

References push_back(), and push_cwd().

Here is the call graph for this function:

Member Function Documentation

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

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

References push_back().

Here is the call graph for this function:

auto vcsn::file_library::current_directory_get ( ) const

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

References current_directory_.

Referenced by find_file().

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

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

References search_path_.

Referenced by vcsn::operator<<().

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 118 of file file-library.cc.

References current_directory_get(), vcsn::exists(), and find_in_search_path().

Here is the call graph for this function:

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 140 of file file-library.cc.

References vcsn::exists(), and search_path_.

Referenced by find_file().

Here is the call graph for this function:

void vcsn::file_library::pop_current_directory ( )

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

References current_directory_.

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

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

References push_front().

Here is the call graph for this function:

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

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

References push_back(), and split().

Here is the call graph for this function:

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 48 of file file-library.hxx.

References push_back(), and split().

Here is the call graph for this function:

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

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

References vcsn::absolute(), and search_path_.

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

Here is the call graph for this function:

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 72 of file file-library.cc.

References push_back(), and split().

Here is the call graph for this function:

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).
template<typename Iterable >
self_t& vcsn::file_library::push_back ( const std::string &  user_path,
const Iterable &  default_path,
const char sep 
)
void vcsn::file_library::push_current_directory ( const path p)

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

References vcsn::absolute(), and current_directory_.

Referenced by push_cwd().

Here is the call graph for this function:

void vcsn::file_library::push_cwd ( )
private

Push the working directory on the stack.

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

References vcsn::path::cwd(), and push_current_directory().

Referenced by file_library().

Here is the call graph for this function:

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

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

References vcsn::absolute(), and search_path_.

Referenced by prepend(), and push_front().

Here is the call graph for this function:

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 88 of file file-library.cc.

References push_front(), and split().

Here is the call graph for this function:

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

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

References search_path_.

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

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

References search_path_.

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 52 of file file-library.cc.

References vcsn::res.

Referenced by push_back(), and push_front().

Member Data Documentation

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().

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: