HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_NameManager< DATA_TYPE > Class Template Reference

#include <UT_NameManager.h>

Public Member Functions

 UT_NameManager (int suffix_start_number=2)
 
 ~UT_NameManager ()
 
int64 getMemoryUsage (bool inclusive) const
 Returns the amount of memory owned by this UT_NameManger. More...
 
unsigned entries () const
 Returns the total number of unique names in the manager. More...
 
bool empty () const
 Returns true if empty, false otherwise. More...
 
bool deleteSymbol (const UT_StringRef &symbol, bool set_to_null)
 
void clear (bool set_to_null)
 
bool getUniqueName (const UT_StringRef &orig_name_in, UT_WorkBuffer &unique_name_out) const
 
bool addSymbol (const UT_StringRef &symbol, DATA_TYPE data)
 
DATA_TYPE findSymbol (const UT_StringRef &symbol) const
 

Detailed Description

template<class DATA_TYPE>
class UT_NameManager< DATA_TYPE >

Definition at line 45 of file UT_NameManager.h.

Constructor & Destructor Documentation

template<class DATA_TYPE>
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 55 of file UT_NameManager.h.

template<class DATA_TYPE>
UT_NameManager< DATA_TYPE >::~UT_NameManager ( )
inline

Definition at line 60 of file UT_NameManager.h.

Member Function Documentation

template<class DATA_TYPE>
bool UT_NameManager< DATA_TYPE >::addSymbol ( const UT_StringRef 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 160 of file UT_NameManager.h.

template<class DATA_TYPE>
void UT_NameManager< DATA_TYPE >::clear ( bool  set_to_null)
inline

Clears all the entries from this manager. if set_to_null is true the map entries values will be set to null instead of erasing all the entries.

Definition at line 105 of file UT_NameManager.h.

template<class DATA_TYPE>
bool UT_NameManager< DATA_TYPE >::deleteSymbol ( const UT_StringRef symbol,
bool  set_to_null 
)
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 82 of file UT_NameManager.h.

template<class DATA_TYPE>
bool UT_NameManager< DATA_TYPE >::empty ( void  ) const
inline

Returns true if empty, false otherwise.

Definition at line 76 of file UT_NameManager.h.

template<class DATA_TYPE>
unsigned UT_NameManager< DATA_TYPE >::entries ( ) const
inline

Returns the total number of unique names in the manager.

Definition at line 73 of file UT_NameManager.h.

template<class DATA_TYPE>
DATA_TYPE UT_NameManager< DATA_TYPE >::findSymbol ( const UT_StringRef symbol) const
inline

Finds the data item associated with a given name. Returns a pointer to the item if found, nullptr if the name is not in the collection.

Definition at line 187 of file UT_NameManager.h.

template<class DATA_TYPE>
int64 UT_NameManager< DATA_TYPE >::getMemoryUsage ( bool  inclusive) const
inline

Returns the amount of memory owned by this UT_NameManger.

Definition at line 63 of file UT_NameManager.h.

template<class DATA_TYPE>
bool UT_NameManager< DATA_TYPE >::getUniqueName ( const UT_StringRef orig_name_in,
UT_WorkBuffer unique_name_out 
) const
inline

Generates a new name unique relative to the items alraedy in this collection, optionally starting with a given name.

Definition at line 120 of file UT_NameManager.h.


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