Panda3D
|
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. | |
void | clear () |
Removes all the patterns from the specification. | |
void | clear_error () |
Resets the error flag to the no-error state. | |
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 | 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. | |
int | get_num_patterns () const |
Returns the number of original/replace patterns that have been added. | |
const std::string & | get_orig_prefix (int n) const |
Returns the original prefix associated with the nth pattern. | |
const std::string & | get_replacement_prefix (int n) const |
Returns the replacement prefix associated with the nth pattern. | |
bool | had_error () const |
Returns true if an error was detected since the last call to clear_error(), false otherwise. | |
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. | |
void | write (std::ostream &out, int indent_level=0) const |
![]() | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. | |
void | ref () const |
Explicitly increments the reference count. | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
virtual bool | unref () const |
Explicitly decrements the reference count. | |
bool | unref_if_one () const |
Atomically decreases the reference count of this object if it is one. | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. | |
![]() | |
void | operator delete (void *, void *) |
void | operator delete (void *ptr) |
void | operator delete[] (void *, void *) |
void | operator delete[] (void *ptr) |
void * | operator new (size_t size) |
void * | operator new (size_t size, void *ptr) |
void * | operator new[] (size_t size) |
void * | operator new[] (size_t size, void *ptr) |
Public Attributes | |
bool | _copy_files |
Filename | _copy_into_directory |
bool | _exists |
bool | _noabs |
DSearchPath | _path |
Filename | _path_directory |
PathStore | _path_store |
![]() | |
get_ref_count | |
Returns the current reference count. | |
Additional Inherited Members | |
![]() | |
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.
PathReplace::PathReplace | ( | ) |
Definition at line 23 of file pathReplace.cxx.
PathReplace::~PathReplace | ( | ) |
Definition at line 35 of file pathReplace.cxx.
|
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 46 of file pathReplace.I.
|
inline |
Removes all the patterns from the specification.
Definition at line 35 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 18 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 90 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 197 of file pathReplace.cxx.
References VirtualFileSystem::exists(), Filename::get_basename(), VirtualFileSystem::get_global_ptr(), Filename::is_fully_qualified(), Filename::is_local(), Filename::make_absolute(), Filename::make_relative_to(), and VirtualFileSystem::resolve_filename().
Referenced by convert_path(), and EggBase::convert_paths().
|
inline |
Returns the number of original/replace patterns that have been added.
Definition at line 54 of file pathReplace.I.
|
inline |
Returns the original prefix associated with the nth pattern.
Definition at line 62 of file pathReplace.I.
|
inline |
Returns the replacement prefix associated with the nth pattern.
Definition at line 71 of file pathReplace.I.
|
inline |
Returns true if an error was detected since the last call to clear_error(), false otherwise.
Definition at line 27 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 81 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 45 of file pathReplace.cxx.
References VirtualFileSystem::exists(), VirtualFileSystem::get_global_ptr(), Filename::is_fully_qualified(), Filename::is_local(), and VirtualFileSystem::resolve_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 148 of file pathReplace.cxx.
References Filename::get_basename(), Filename::is_local(), Filename::make_absolute(), and Filename::make_relative_to().
void PathReplace::write | ( | std::ostream & | out, |
int | indent_level = 0 ) const |
Definition at line 356 of file pathReplace.cxx.
bool PathReplace::_copy_files |
Definition at line 74 of file pathReplace.h.
Filename PathReplace::_copy_into_directory |
Definition at line 75 of file pathReplace.h.
bool PathReplace::_exists |
Definition at line 84 of file pathReplace.h.
bool PathReplace::_noabs |
Definition at line 80 of file pathReplace.h.
DSearchPath PathReplace::_path |
Definition at line 69 of file pathReplace.h.
Filename PathReplace::_path_directory |
Definition at line 73 of file pathReplace.h.
PathStore PathReplace::_path_store |
Definition at line 72 of file pathReplace.h.