Panda3D
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all 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 MemoryBase

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
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_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.
 
WeakReferenceListweak_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.
 
- Public Member Functions inherited from MemoryBase
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
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count.
 

Additional Inherited Members

- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

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 36 of file pathReplace.h.

Constructor & Destructor Documentation

◆ PathReplace()

PathReplace::PathReplace ( )

Definition at line 23 of file pathReplace.cxx.

◆ ~PathReplace()

PathReplace::~PathReplace ( )

Definition at line 35 of file pathReplace.cxx.

Member Function Documentation

◆ add_pattern()

void PathReplace::add_pattern ( const std::string & orig_prefix,
const std::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 46 of file pathReplace.I.

◆ clear()

void PathReplace::clear ( )
inline

Removes all the patterns from the specification.

Definition at line 35 of file pathReplace.I.

References clear_error().

◆ clear_error()

void PathReplace::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().

◆ convert_path()

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 90 of file pathReplace.I.

References full_convert_path().

◆ 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().

◆ get_num_patterns()

int PathReplace::get_num_patterns ( ) const
inline

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

Definition at line 54 of file pathReplace.I.

◆ get_orig_prefix()

const std::string & PathReplace::get_orig_prefix ( int n) const
inline

Returns the original prefix associated with the nth pattern.

Definition at line 62 of file pathReplace.I.

◆ get_replacement_prefix()

const std::string & PathReplace::get_replacement_prefix ( int n) const
inline

Returns the replacement prefix associated with the nth pattern.

Definition at line 71 of file pathReplace.I.

◆ had_error()

bool PathReplace::had_error ( ) const
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.

◆ is_empty()

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 81 of file pathReplace.I.

References DSearchPath::is_empty().

◆ match_path()

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().

◆ store_path()

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 148 of file pathReplace.cxx.

References Filename::get_basename(), Filename::is_local(), Filename::make_absolute(), and Filename::make_relative_to().

◆ write()

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

Definition at line 356 of file pathReplace.cxx.

Member Data Documentation

◆ _copy_files

bool PathReplace::_copy_files

Definition at line 74 of file pathReplace.h.

◆ _copy_into_directory

Filename PathReplace::_copy_into_directory

Definition at line 75 of file pathReplace.h.

◆ _exists

bool PathReplace::_exists

Definition at line 84 of file pathReplace.h.

◆ _noabs

bool PathReplace::_noabs

Definition at line 80 of file pathReplace.h.

◆ _path

DSearchPath PathReplace::_path

Definition at line 69 of file pathReplace.h.

◆ _path_directory

Filename PathReplace::_path_directory

Definition at line 73 of file pathReplace.h.

◆ _path_store

PathStore PathReplace::_path_store

Definition at line 72 of file pathReplace.h.


The documentation for this class was generated from the following files: