Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Dv::Util::includestream Class Reference

A stream that can include other files. More...

#include <includestream.h>

Collaboration diagram for Dv::Util::includestream:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::list< std::string > directories
 Type of optional second argument: a list of directories to search for included files.

Public Member Functions

 includestream (std::istream &stream, directories *dirs=0)
 Uses open stream.
 includestream (std::istream &stream, const std::string &dir)
 Uses open stream.
 ~includestream ()
 Destructor.

Static Public Member Functions

std::string find (const std::string &filename, const directories &dirs)
 Try to find a file d/filename for some directory d in dirs.

Private Attributes

IncludeFilter filter_

Detailed Description

A stream that can include other files.

An includestream is an istream that replaces lines of the form

 #include "file"
 #include <file>
by the contents of the file. If file is between double quotes and is not absolute, it is interpreted as relative to the current directory. Otherwise (i.e. if it is of the form <file> , it will be searched for (if it is not absolute) in a list of directories.
Warning:
  1. An exception (runtime_error ) is thrown upon an include error (syntax, file not found, ..)
  2. No check is made (yet) for recursive include directives.

Definition at line 38 of file includestream.h.


Member Typedef Documentation

typedef std::list<std::string> Dv::Util::includestream::directories
 

Type of optional second argument: a list of directories to search for included files.

Definition at line 43 of file includestream.h.

Referenced by Dv::Util::includestream::IncludeFilter::dirs().


Constructor & Destructor Documentation

Dv::Util::includestream::includestream std::istream &  stream,
directories dirs = 0
 

Uses open stream.

Parameters:
stream from which original input is taken
dirs pointer (may be 0) to a list of directories to search if an include directive is of the <file> form.
Warning:
No check for recursive include is made (yet).

Dv::Util::includestream::includestream std::istream &  stream,
const std::string &  dir
 

Uses open stream.

Parameters:
stream from which original input is taken
dir a single directory to search if an include directive is of the <file> form.
Warning:
No check for recursive include is made (yet).

Dv::Util::includestream::~includestream  ) 
 

Destructor.


Member Function Documentation

std::string Dv::Util::includestream::find const std::string &  filename,
const directories dirs
[static]
 

Try to find a file d/filename for some directory d in dirs.

Return zero-length string if not found. The directories are tried in order.

Parameters:
filename (relative) path of filename. If filename is absolute, i.e. starts with / , only its existence (without considering dirs ) is checked.
dirs list of directories to try
Returns:
full pathname of first existing file d/filename for some d in dirs, or zero-length string. If filename starts with '/' , only the existence of filename is checked.


Member Data Documentation

IncludeFilter Dv::Util::includestream::filter_ [private]
 

Definition at line 121 of file includestream.h.


The documentation for this class was generated from the following file:
dvutil-0.13.15 [30 December, 2004]