#include <UT_NameManager.h>
Public Member Functions | |
| UT_NameManager (int suffix_start_number=2) | |
| virtual | ~UT_NameManager () |
| unsigned | entries () const |
| Returns the total number of unique names in the manager. | |
| bool | empty () const |
| Returns true if empty, false otherwise. | |
| bool | deleteSymbol (const char *symbol) |
| void | clear (void) |
| Clears all the entries from this manager. | |
| void | getUniqueName (const char *orig_name_in, UT_String &unique_name_out) const |
| bool | addSymbol (const char *symbol, DATA_TYPE data) |
| const char * | addSymbolUnique (const char *symbol, DATA_TYPE data, bool make_name_copy=false) |
| DATA_TYPE | findSymbol (const char *symbol) const |
Definition at line 159 of file UT_NameManager.h.
| UT_NameManager< DATA_TYPE >::UT_NameManager | ( | int | suffix_start_number = 2 |
) | [inline] |
suffix_start_number determines the starting numerical suffix when unique names are generated. For example: If set to 0, generating unique names for "base" will result in "base0", "base1", "base2", etc. If set to 1, generating unique names for "base" will result in "base", "base1", "base2", etc. If set to 2, generating unique names for "base" will result in "base", "base2", "base3", etc. And so on.
Definition at line 169 of file UT_NameManager.h.
| virtual UT_NameManager< DATA_TYPE >::~UT_NameManager | ( | ) | [inline, virtual] |
Definition at line 170 of file UT_NameManager.h.
| bool UT_NameManager< DATA_TYPE >::addSymbol | ( | const char * | symbol, | |
| DATA_TYPE | data | |||
| ) | [inline] |
Adds a new name to this collection. If the name already exists, the addition will silently fail, so it is the caller's responsibility to assure that the name is unique by calling findSymbol() if needed. This is done to avoid extra uniqueness checks that may be unnecessary in certain situations.
Returns true if symbol added successfully, false otherwise.
Definition at line 284 of file UT_NameManager.h.
| const char* UT_NameManager< DATA_TYPE >::addSymbolUnique | ( | const char * | symbol, | |
| DATA_TYPE | data, | |||
| bool | make_name_copy = false | |||
| ) | [inline] |
Similar to addSymbol(), but does a uniqueness check before adding the item, and if the name already exists, generates a new unique name with which the item is added.
If make_name_copy is true, returns NULL if the original name was unique, or a pointer to a new name if a different name was generated. Note that deallocating the new name is the responsibility of the caller. If make_name_copy is false, always returns NULL.
Definition at line 318 of file UT_NameManager.h.
| void UT_NameManager< DATA_TYPE >::clear | ( | void | ) | [inline] |
| bool UT_NameManager< DATA_TYPE >::deleteSymbol | ( | const char * | symbol | ) | [inline] |
Removes a name, such as "base123", from the manager. If the removed name was the last one in a category and the category is now empty, deletes the category as well. Returns true if removal was successfull, false otherwise.
Definition at line 182 of file UT_NameManager.h.
| bool UT_NameManager< DATA_TYPE >::empty | ( | ) | const [inline] |
| unsigned UT_NameManager< DATA_TYPE >::entries | ( | void | ) | const [inline] |
Returns the total number of unique names in the manager.
Definition at line 173 of file UT_NameManager.h.
| DATA_TYPE UT_NameManager< DATA_TYPE >::findSymbol | ( | const char * | symbol | ) | const [inline] |
Finds the data item associated with a given name. Returns a pointer to the item if found, NULL if the name is not in the collection.
Definition at line 346 of file UT_NameManager.h.
| void UT_NameManager< DATA_TYPE >::getUniqueName | ( | const char * | orig_name_in, | |
| UT_String & | unique_name_out | |||
| ) | const [inline] |
Generates a new name unique relative to the items alraedy in this collection, optionally starting with a given name. Note that it always converts unique_name_out string to be deep.
Definition at line 238 of file UT_NameManager.h.
1.5.9