lestes::lang::cplus::lex::file_system Class Reference

File system binding. More...

#include <file_system.hh>

Inheritance diagram for lestes::lang::cplus::lex::file_system:

Inheritance graph
[legend]
List of all members.

Public Types

enum  name_type {
  NM_INVALID, NM_FILE_REL, NM_FILE_ABS, NM_PATH_REL,
  NM_PATH_ABS
}
 The type of name for classification. More...

Public Member Functions

ptr< named_istreamopen_file (const lstring &name)
 Opens a file stream, using only working directory.
ptr< named_istreamfind_file (const lstring &path, const lstring &name, bool system)
 Opens a file stream, searching given paths.
bool add_search_path (const lstring &path)
 Adds search path.

Static Public Member Functions

static ptr< file_systemcreate (void)
 Returns new instance.
static name_type classify_name (const lstring &name)
 Classifies path and file name.

Protected Member Functions

 file_system (void)
 Creates the object.
virtual void gc_mark (void)
 Marks the object.

Private Types

typedef ::lestes::std::vector<
lstring > 
lstrings_type
 Type of sequence of strings, used for search path list.

Private Member Functions

 file_system (const file_system &)
 Hides copy constructor.
file_systemoperator= (const file_system &)
 Hides assignment operator.

Static Private Member Functions

static ptr< lstrings_typesplit (const lstring &str, hchar delimiter)
 Splits string into parts.

Private Attributes

srp< lstrings_typesearch_paths
 System search paths.

Detailed Description

File system binding.

Provides acces to the file system. Enables opening file streams and include path search.


Member Typedef Documentation

typedef ::lestes::std::vector<lstring> lestes::lang::cplus::lex::file_system::lstrings_type [private]

Type of sequence of strings, used for search path list.


Member Enumeration Documentation

enum lestes::lang::cplus::lex::file_system::name_type

The type of name for classification.

Enumerator:
NM_INVALID  Invalid name.
NM_FILE_REL  Relative file name.
NM_FILE_ABS  Absolute file name.
NM_PATH_REL  Relative path.
NM_PATH_ABS  Absolute path.


Constructor & Destructor Documentation

lestes::lang::cplus::lex::file_system::file_system ( void   )  [protected]

Creates the object.

Creates the object.

lestes::lang::cplus::lex::file_system::file_system ( const file_system  )  [private]

Hides copy constructor.


Member Function Documentation

ptr< named_istream > lestes::lang::cplus::lex::file_system::open_file ( const lstring &  name  ) 

Opens a file stream, using only working directory.

Opens a stream for the given file name or standard input. Relative file name is searched for in the working directory.

Parameters:
name Absolute or relative file name, "" used for stdin.
Returns:
The opened stream or NULL for error (file not found or not accessible).

ptr< named_istream > lestes::lang::cplus::lex::file_system::find_file ( const lstring &  base_path,
const lstring &  name,
bool  system 
)

Opens a file stream, searching given paths.

Opens a stream for the given file name. Relative names are searched for in search paths if system is set to true, otherwise in the given path, and in the search paths in this order.

Parameters:
base_path Absolute or relative path for the search.
name Absolute or relative file name of the file to open.
system Flag set to true for system header.
Returns:
The opened stream or NULL for error (invalid name, file not found or not accessible).

bool lestes::lang::cplus::lex::file_system::add_search_path ( const lstring &  a_path  ) 

Adds search path.

Adds search path for file searching.

Parameters:
a_path A path to add.
Returns:
false If the path is invalid.

ptr< file_system > lestes::lang::cplus::lex::file_system::create ( void   )  [static]

Returns new instance.

Returns new instance.

Returns:
The new instance.

file_system::name_type lestes::lang::cplus::lex::file_system::classify_name ( const lstring &  name  )  [static]

Classifies path and file name.

Classifies the name according to its properties. Distinguishes relative and absolute path and file names.

Parameters:
str The string to classify.
Returns:
The kind of name represented by the string.

void lestes::lang::cplus::lex::file_system::gc_mark ( void   )  [protected, virtual]

Marks the object.

Marks the object.

Reimplemented from lestes::std::mem::keystone.

ptr< file_system::lstrings_type > lestes::lang::cplus::lex::file_system::split ( const lstring &  str,
hchar  delimiter 
) [static, private]

Splits string into parts.

Splits string into sequence of parts separated by delimiter. If delimiter is found at the beginning, or at the end of the string, or two delimiters are adjacent, an empty string is added to the appropriate place. So empty string results in empty sequence, while string containing sole delimiter results in sequence containing two empty strings.

Parameters:
str The string to split.
delimiter The delimiter to separate the parts.
Returns:
The sequence of parts, in the original order, without the delimiters.

file_system& lestes::lang::cplus::lex::file_system::operator= ( const file_system  )  [private]

Hides assignment operator.


Member Data Documentation

srp<lstrings_type> lestes::lang::cplus::lex::file_system::search_paths [private]

System search paths.


The documentation for this class was generated from the following files:
Generated on Mon Feb 12 18:43:42 2007 for lestes by doxygen 1.5.1-20070107