Panda3D

Loading...
Searching...
No Matches
Public Member Functions | List of all members
NameUniquifier Class Reference

A handy class for converting a list of arbitrary names (strings) so that each name is guaranteed to be unique in the list. More...

`#include "nameUniquifier.h"`

## Public Member Functions
| NameUniquifier (const std::string &separator=std::string(), const std::string &empty=std::string())
| Creates a new NameUniquifier.
std::string | add_name (const std::string &name)
| If name is nonempty and so far unique, returns it unchanged.
std::string | add_name (const std::string &name, const std::string &prefix)
| If name is nonempty and so far unique, returns it unchanged.

## Detailed Description

A handy class for converting a list of arbitrary names (strings) so that each name is guaranteed to be unique in the list.

Useful for writing egg files with unique vertex pool names, or for file converters to file formats that require unique node names, etc.

Definition at line 28 of file nameUniquifier.h.

## Constructor & Destructor Documentation

## ◆ NameUniquifier()

NameUniquifier::NameUniquifier | ( | const std::string & | separator = std::string(),
|  | const std::string & | empty = std::string() )

Creates a new NameUniquifier.

The separator string is used to separate the original name (or supplied prefix) and the generated number when a name must be generated.

If the original name is empty, the empty string is used, followed by the generated number.

Definition at line 32 of file nameUniquifier.cxx.

## ◆ ~NameUniquifier()

NameUniquifier::~NameUniquifier | ( |  | ) |

Definition at line 48 of file nameUniquifier.cxx.

## Member Function Documentation

## ◆ add_name() [1/2]

std::string NameUniquifier::add_name | ( | const std::string & | name | ) |
| inline

If name is nonempty and so far unique, returns it unchanged.

Otherwise, generates and returns a new name according to the following rules:

If the name is empty, the new name is the NameUniquifier's "empty" string followed by a number, or the "separator" string if the "empty" string is empty.

If the name is nonempty, the new name is the original name, followed by the NameUniquifier's "separator" string, followed by a number.

Definition at line 27 of file nameUniquifier.I.

Referenced by EggComponentData::add_name(), EggMaterialCollection::uniquify_mrefs(), and EggTextureCollection::uniquify_trefs().

## ◆ add_name() [2/2]

std::string NameUniquifier::add_name | ( | const std::string & | name,
|  | const std::string & | prefix )
| inline

If name is nonempty and so far unique, returns it unchanged.

Otherwise, generates and returns a new name according to the following rules:

If the prefix is empty, the new name is the NameUniquifier's "empty" string followed by a number, or the "separator" string if the "empty" string is empty.

If the prefix is nonempty, the new name is the prefix, followed by the NameUniquifier's "separator" string, followed by a number.

Definition at line 45 of file nameUniquifier.I.

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

- panda/src/putil/nameUniquifier.h
- panda/src/putil/nameUniquifier.cxx
- panda/src/putil/nameUniquifier.I