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

DSearchPath Class Reference

This class stores a list of directories that can be searched, in order, to locate a particular file. More...

#include <dSearchPath.h>

List of all members.

Public Member Functions

 DSearchPath ()
 Creates an empty search path.

 DSearchPath (const string &path, const string &delimiters=":\n\t")
 DSearchPath (const DSearchPath &copy)
void operator= (const DSearchPath &copy)
 ~DSearchPath ()
void clear ()
 Removes all the directories from the search list.

void append_directory (const Filename &directory)
 Adds a new directory to the end of the search list.

void prepend_directory (const Filename &directory)
 Adds a new directory to the front of the search list.

void append_path (const string &path, const string &delimiters=":\n\t")
 Adds all of the directories listed in the search path to the end of the search list.

void append_path (const DSearchPath &path)
 Adds all of the directories listed in the search path to the end of the search list.

void prepend_path (const DSearchPath &path)
 Adds all of the directories listed in the search path to the beginning of the search list.

bool is_empty () const
 Returns true if the search list is empty, false otherwise.

int get_num_directories () const
 Returns the number of directories on the search list.

const Filenameget_directory (int n) const
 Returns the nth directory on the search list.

Filename find_file (const Filename &filename) const
 Searches all the directories in the search list for the indicated file, in order.

int find_all_files (const Filename &filename, Results &results) const
 Searches all the directories in the search list for the indicated file, in order.

void output (ostream &out, const string &separator=":") const
void write (ostream &out, int indent_level=0) const

Static Public Member Functions

Filename search_path (const Filename &filename, const string &path, const string &delimiters=":\n\t")
 A quick-and-easy way to search a searchpath for a file when you don't feel like building or keeping around a DSearchPath object.


Private Types

typedef pvector< FilenameDirectories

Private Attributes

Directories _directories


Detailed Description

This class stores a list of directories that can be searched, in order, to locate a particular file.

It is normally constructed by passing it a traditional searchpath-style string, e.g. a list of directory names delimited by spaces or colons, but it can also be built up explicitly.

Definition at line 47 of file dSearchPath.h.


Member Typedef Documentation

typedef pvector<Filename> DSearchPath::Directories [private]
 

Definition at line 98 of file dSearchPath.h.


Constructor & Destructor Documentation

DSearchPath::DSearchPath  ) 
 

Creates an empty search path.

Definition at line 136 of file dSearchPath.cxx.

References _directories.

DSearchPath::DSearchPath const string &  path,
const string &  delimiters = ": \n\t"
 

Definition at line 147 of file dSearchPath.cxx.

DSearchPath::DSearchPath const DSearchPath &  copy  ) 
 

Definition at line 159 of file dSearchPath.cxx.

References _directories.

DSearchPath::~DSearchPath  ) 
 

Definition at line 184 of file dSearchPath.cxx.

References _directories, path, and size_t.


Member Function Documentation

void DSearchPath::append_directory const Filename directory  ) 
 

Adds a new directory to the end of the search list.

Definition at line 209 of file dSearchPath.cxx.

References _directories, and path.

void DSearchPath::append_path const DSearchPath &  path  ) 
 

Adds all of the directories listed in the search path to the end of the search list.

Definition at line 263 of file dSearchPath.cxx.

void DSearchPath::append_path const string &  path,
const string &  delimiters = ": \n\t"
 

Adds all of the directories listed in the search path to the end of the search list.

Definition at line 237 of file dSearchPath.cxx.

References _directories.

Referenced by Config::ConfigTable::ReadConfigFile().

void DSearchPath::clear  ) 
 

Removes all the directories from the search list.

Definition at line 196 of file dSearchPath.cxx.

int DSearchPath::find_all_files const Filename filename,
DSearchPath::Results results
const
 

Searches all the directories in the search list for the indicated file, in order.

Fills up the results list with *all* of the matching filenames found, if any. Returns the number of matches found.

It is the responsibility of the the caller to clear the results list first; otherwise, the newly-found files will be appended to the list.

Definition at line 391 of file dSearchPath.cxx.

Filename DSearchPath::find_file const Filename filename  )  const
 

Searches all the directories in the search list for the indicated file, in order.

Returns the full matching pathname of the first match if found, or the empty string if not found.

Definition at line 345 of file dSearchPath.cxx.

References _directories.

Referenced by Filename::is_regular_file(), and InterrogateDatabase::remap_indices().

const Filename & DSearchPath::get_directory int  n  )  const
 

Returns the nth directory on the search list.

Definition at line 325 of file dSearchPath.cxx.

Referenced by Filename::compare_timestamps().

int DSearchPath::get_num_directories  )  const
 

Returns the number of directories on the search list.

Definition at line 312 of file dSearchPath.cxx.

References _directories, Filename::exists(), and Filename::is_fully_qualified().

Referenced by Filename::compare_timestamps().

bool DSearchPath::is_empty  )  const
 

Returns true if the search list is empty, false otherwise.

Definition at line 299 of file dSearchPath.cxx.

void DSearchPath::operator= const DSearchPath &  copy  ) 
 

Definition at line 172 of file dSearchPath.cxx.

References _directories.

void DSearchPath::output ostream &  out,
const string &  separator = ":"
const
 

Definition at line 426 of file dSearchPath.cxx.

void DSearchPath::prepend_directory const Filename directory  ) 
 

Adds a new directory to the front of the search list.

Definition at line 222 of file dSearchPath.cxx.

References _directories, and path.

void DSearchPath::prepend_path const DSearchPath &  path  ) 
 

Adds all of the directories listed in the search path to the beginning of the search list.

Definition at line 279 of file dSearchPath.cxx.

References Filename::is_fully_qualified().

Filename DSearchPath::search_path const Filename filename,
const string &  path,
const string &  delimiters = ": \n\t"
[inline, static]
 

A quick-and-easy way to search a searchpath for a file when you don't feel like building or keeping around a DSearchPath object.

This simply constructs a temporary DSearchPath based on the indicated path string, and searches that.

Definition at line 40 of file dSearchPath.I.

void DSearchPath::write ostream &  out,
int  indent_level = 0
const
 

Definition at line 446 of file dSearchPath.cxx.


Member Data Documentation

Directories DSearchPath::_directories [private]
 

Definition at line 99 of file dSearchPath.h.

Referenced by DSearchPath::Results::add_file(), append_directory(), append_path(), DSearchPath(), find_file(), get_num_directories(), operator=(), prepend_directory(), and ~DSearchPath().


The documentation for this class was generated from the following files:
Generated on Thu May 1 22:13:31 2003 for DTool by doxygen1.3