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"
Public Member Functions | |
void | add_pattern (const std::string &orig_prefix, const std::string &replacement_prefix) |
Adds the indicated original/replace pattern to the specification. More... | |
void | clear () |
Removes all the patterns from the specification. More... | |
void | clear_error () |
Resets the error flag to the no-error state. More... | |
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. More... | |
void | full_convert_path (const Filename &orig_filename, const DSearchPath &additional_path, Filename &resolved_path, Filename &output_path) |
Converts the input path into two different forms: A resolved path, and an output path. More... | |
int | get_num_patterns () const |
Returns the number of original/replace patterns that have been added. More... | |
const std::string & | get_orig_prefix (int n) const |
Returns the original prefix associated with the nth pattern. More... | |
const std::string & | get_replacement_prefix (int n) const |
Returns the replacement prefix associated with the nth pattern. More... | |
bool | had_error () const |
Returns true if an error was detected since the last call to clear_error(), false otherwise. More... | |
bool | is_empty () const |
Returns true if the PathReplace object specifies no action, or false if convert_path() may do something. More... | |
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. More... | |
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. More... | |
void | write (std::ostream &out, int indent_level=0) const |
Public Member Functions inherited from ReferenceCount | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Public Attributes | |
bool | _copy_files |
Filename | _copy_into_directory |
bool | _exists |
bool | _noabs |
DSearchPath | _path |
Filename | _path_directory |
PathStore | _path_store |
Public Attributes inherited from ReferenceCount | |
get_ref_count | |
Returns the current reference count. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from ReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
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 36 of file pathReplace.h.
|
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 47 of file pathReplace.I.
|
inline |
Removes all the patterns from the specification.
Definition at line 36 of file pathReplace.I.
References clear_error().
|
inline |
Resets the error flag to the no-error state.
had_error() will return false until a new error is generated.
Definition at line 19 of file pathReplace.I.
Referenced by clear().
|
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 91 of file pathReplace.I.
References full_convert_path().
void PathReplace::full_convert_path | ( | const Filename & | orig_filename, |
const DSearchPath & | additional_path, | ||
Filename & | resolved_path, | ||
Filename & | output_path | ||
) |
Converts the input path into two different forms: A resolved path, and an output path.
The resolved path is an absolute path if at all possible. The output path is in the form specified by the -ps path store option.
Definition at line 198 of file pathReplace.cxx.
References Filename::is_local(), and Filename::make_absolute().
Referenced by convert_path().
|
inline |
Returns the number of original/replace patterns that have been added.
Definition at line 55 of file pathReplace.I.
|
inline |
Returns the original prefix associated with the nth pattern.
Definition at line 63 of file pathReplace.I.
|
inline |
Returns the replacement prefix associated with the nth pattern.
Definition at line 72 of file pathReplace.I.
|
inline |
Returns true if an error was detected since the last call to clear_error(), false otherwise.
Definition at line 28 of file pathReplace.I.
|
inline |
Returns true if the PathReplace object specifies no action, or false if convert_path() may do something.
Definition at line 82 of file pathReplace.I.
References DSearchPath::is_empty().
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 46 of file pathReplace.cxx.
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 149 of file pathReplace.cxx.
References Filename::is_local(), and Filename::make_absolute().