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. More... | |
std::string | add_name (const std::string &name) |
If name is nonempty and so far unique, returns it unchanged. More... | |
std::string | add_name (const std::string &name, const std::string &prefix) |
If name is nonempty and so far unique, returns it unchanged. More... | |
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.
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 33 of file nameUniquifier.cxx.
|
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 28 of file nameUniquifier.I.
Referenced by EggComponentData::add_name(), EggMaterialCollection::uniquify_mrefs(), and EggTextureCollection::uniquify_trefs().
|
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 46 of file nameUniquifier.I.