Panda3D
Public Member Functions
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"

List of all members.

Public Member Functions

 NameUniquifier (const string &separator=string(), const string &empty=string())
 Creates a new NameUniquifier.
string add_name (const string &name)
 If name is nonempty and so far unique, returns it unchanged.
string add_name (const string &name, const 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 31 of file nameUniquifier.h.


Constructor & Destructor Documentation

NameUniquifier::NameUniquifier ( const string &  separator = string(),
const string &  empty = 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 35 of file nameUniquifier.cxx.


Member Function Documentation

string NameUniquifier::add_name ( const 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 35 of file nameUniquifier.I.

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

string NameUniquifier::add_name ( const string &  name,
const 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 58 of file nameUniquifier.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations