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

PathReplace Class Reference

This encapsulates the user's command-line request to replace existing, incorrect pathnames to models and textures from a file with correct pathnames. More...

#include <pathReplace.h>

Inheritance diagram for PathReplace:

ReferenceCount List of all members.

Public Member Functions

 PathReplace ()
 ~PathReplace ()
void clear ()
 Removes all the patterns from the specification.

void add_pattern (const string &orig_prefix, const string &replacement_prefix)
 Adds the indicated original/replace pattern to the specification.

int get_num_patterns () const
 Returns the number of original/replace patterns that have been added.

const string & get_orig_prefix (int n) const
 Returns the original prefix associated with the nth pattern.

const string & get_replacement_prefix (int n) const
 Returns the replacement prefix associated with the nth pattern.

bool is_empty () const
 Returns true if the PathReplace object specifies no action, or false if convert_path() may do something.

Filename match_path (const Filename &orig_filename, const DSearchPath &additional_path=DSearchPath())
 Looks for a match for the given filename among all the replacement patterns, and returns the first match found.

Filename store_path (const Filename &orig_filename)
 Given a path to an existing filename, converts it as specified in the _path_store and or _path_directory properties to a form suitable for storing in an output file.

Filename convert_path (const Filename &orig_filename, const DSearchPath &additional_path=DSearchPath())
 Calls match_path() followed by store_path(), to replace the initial prefix and then convert the file for storing, as the user indicated.

void write (ostream &out, int indent_level=0) const
int get_ref_count () const
int ref () const
int unref () const
void test_ref_count_integrity () const

Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()

Public Attributes

DSearchPath _path
PathStore _path_store
Filename _path_directory

Protected Attributes

int _ref_count

Static Protected Attributes

TypeHandle _type_handle

Private Types

typedef pvector< ComponentComponents
typedef pvector< EntryEntries

Private Attributes

Entries _entries

Detailed Description

This encapsulates the user's command-line request to replace existing, incorrect pathnames to models and textures from a file with correct pathnames.

It corresponds to a sequence of -pr command-line options, as well as the -pp option.

This can also go the next step, which is to convert a known file into a suitable form for storing in a model file. In this capacity, it corresponds to the -ps and -pd options.

Definition at line 58 of file pathReplace.h.


Member Typedef Documentation

typedef pvector<Component> PathReplace::Components [private]
 

Definition at line 99 of file pathReplace.h.

typedef pvector<Entry> PathReplace::Entries [private]
 

Definition at line 116 of file pathReplace.h.


Constructor & Destructor Documentation

PathReplace::PathReplace  ) 
 

Definition at line 34 of file pathReplace.cxx.

PathReplace::~PathReplace  ) 
 

Definition at line 46 of file pathReplace.cxx.

References _entries, and PathReplace::Entry::try_match().


Member Function Documentation

void PathReplace::add_pattern const string &  orig_prefix,
const string &  replacement_prefix
[inline]
 

Adds the indicated original/replace pattern to the specification.

If a filename is encountered whose initial prefix matches the indicated orig_prefix, that prefix will be replaced with replacement_prefix.

Definition at line 51 of file pathReplace.I.

References _entries.

Referenced by ProgramBase::dispatch_double_quad().

void PathReplace::clear void   )  [inline]
 

Removes all the patterns from the specification.

Definition at line 32 of file pathReplace.I.

References _entries, and INLINE.

Filename PathReplace::convert_path const Filename orig_filename,
const DSearchPath additional_path = DSearchPath()
[inline]
 

Calls match_path() followed by store_path(), to replace the initial prefix and then convert the file for storing, as the user indicated.

Definition at line 130 of file pathReplace.I.

References PathReplace::Component::_double_star, PathReplace::Component::_orig_prefix, and INLINE.

int PathReplace::get_num_patterns  )  const [inline]
 

Returns the number of original/replace patterns that have been added.

Definition at line 66 of file pathReplace.I.

References _entries, INLINE, and nassertr.

const string & PathReplace::get_orig_prefix int  n  )  const [inline]
 

Returns the original prefix associated with the nth pattern.

Definition at line 81 of file pathReplace.I.

References _entries, _path, _path_store, INLINE, DSearchPath::is_empty(), and PS_keep.

const string & PathReplace::get_replacement_prefix int  n  )  const [inline]
 

Returns the replacement prefix associated with the nth pattern.

Definition at line 97 of file pathReplace.I.

References match_path(), and store_path().

bool PathReplace::is_empty  )  const [inline]
 

Returns true if the PathReplace object specifies no action, or false if convert_path() may do something.

Definition at line 113 of file pathReplace.I.

References INLINE.

Filename PathReplace::match_path const Filename orig_filename,
const DSearchPath additional_path = DSearchPath()
 

Looks for a match for the given filename among all the replacement patterns, and returns the first match found.

If additional_path is nonempty, it is an additional search path on which to look for the file. The model_path is always implicitly searched.

Definition at line 66 of file pathReplace.cxx.

Referenced by get_replacement_prefix().

Filename PathReplace::store_path const Filename orig_filename  ) 
 

Given a path to an existing filename, converts it as specified in the _path_store and or _path_directory properties to a form suitable for storing in an output file.

Definition at line 147 of file pathReplace.cxx.

References PS_invalid, PS_keep, and PS_strip.

Referenced by get_replacement_prefix().

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

Definition at line 191 of file pathReplace.cxx.


Member Data Documentation

Entries PathReplace::_entries [private]
 

Definition at line 117 of file pathReplace.h.

Referenced by add_pattern(), clear(), get_num_patterns(), get_orig_prefix(), and ~PathReplace().

DSearchPath PathReplace::_path
 

Definition at line 83 of file pathReplace.h.

Referenced by get_orig_prefix().

Filename PathReplace::_path_directory
 

Definition at line 87 of file pathReplace.h.

PathStore PathReplace::_path_store
 

Definition at line 86 of file pathReplace.h.

Referenced by get_orig_prefix().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:27:46 2003 for Panda-Tool by doxygen1.3