3ds Max C++ API Reference
Loading...
Searching...
No Matches
NameTab Class Reference

This class is used to store a table of names. More...

#include <nametab.h>

+ Inheritance diagram for NameTab:

Public Member Functions

 NameTab ()
 Constructor.
 
UtilExport ~NameTab ()
 Destructor.
 
UtilExport void ZeroCount ()
 removes the items in the Tab by un-allocating memory.
 
UtilExport NameTaboperator= (const NameTab &n)
 Assignment operator.
 
void SetFlag (ULONG f, BOOL b=1)
 Sets the specified flag to the specified value.
 
BOOL TestFlag (ULONG f)
 Checks if a flag is set or not.
 
UtilExport int AddName (const MCHAR *n)
 Appends a copy of the specified name to the end of the list.
 
UtilExport void SetName (int i, const MCHAR *n)
 Sets a name in the list.
 
UtilExport void SetSize (int num)
 Sets the size of the list.
 
UtilExport void RemoveName (int i)
 Removes the 'i-th' name from the list.
 
UtilExport int FindName (const MCHAR *n)
 Finds the index of the name passed in.
 
UtilExport IOResult Load (ILoad *iload)
 Loads this NameTab from disk.
 
UtilExport IOResult Save (ISave *isave)
 Saves this NameTab to disk.
 
- Public Member Functions inherited from Tab< const MCHAR * >
 Tab ()
 Default constructor.
 
 Tab (const Tab &tb)
 Copy constructor.
 
virtual ~Tab ()
 Destructor.
 
void Init ()
 Initializes a Tab instance.
 
int Count () const
 Retrieves the number of items in the Tab.
 
constexpr size_t size () const noexcept
 Retrieves the number of items in the Tab. Standard compliant.
 
void ZeroCount ()
 Resets the number of used items to zero.
 
void SetCount (int n, BOOL resize=TRUE)
 Sets the number of used items.
 
const MCHAR * * Addr (const INT_PTR i) const
 Returns the address of the i-th item.
 
constexpr const MCHAR * * data () noexcept
 Returns a pointer to the data buffer of tab. Standard compliant.
 
constexpr const const MCHAR * * data () const noexcept
 Returns a const pointer to the data buffer of tab. Standard compliant.
 
int Insert (int at, int num, const MCHAR * *el)
 Inserts items in the Tab at a specified position.
 
int Append (int num, const MCHAR * *el, int allocExtra=0)
 Appends items at the end of the Tab.
 
int Delete (int start, int num)
 Deletes items from the Tab.
 
int Resize (int num)
 Changes the number of items allocated in memory.
 
void Shrink ()
 Frees unused Tab items to reduce memory footprint.
 
void Sort (CompareFnc cmp)
 Sorts the array using the compare function.
 
Taboperator= (const Tab &tb)
 Assignment operator.
 
const MCHAR * & operator[] (const INT_PTR i) const
 Accesses the i-th Tab item.
 
const const MCHAR * * begin () const
 Accesses the begin iterator, which is a plain pointer in this case.
 
const MCHAR * * begin ()
 
const const MCHAR * * end () const
 Accesses the end iterator (one past last valid element). Do not dereference.
 
const MCHAR * * end ()
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects.
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned.
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator.
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator.
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary.
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary.
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc.
 

Detailed Description

This class is used to store a table of names.

See also
Class Tab.
For example, this class is used by lights for their "Inclusion" and "Exclusion" lists.
This class maintains an 'include' flag that specifies whether the list of names is things to be included, or things to be excluded. There is no reason the NameTab class can't be used for other things where inclusion/exclusion is not relevant: in that case one can just ignore the 'include' flag. All methods are implemented by the system.

Constructor & Destructor Documentation

◆ NameTab()

NameTab ( )
inline

Constructor.

The 'include' flag is set to FALSE.

#define NT_AFFECT_SHADOWCAST
Definition: ExcludeListConstants.h:13
#define NT_AFFECT_ILLUM
Definition: ExcludeListConstants.h:12

◆ ~NameTab()

Destructor.

Member Function Documentation

◆ ZeroCount()

UtilExport void ZeroCount ( )

removes the items in the Tab by un-allocating memory.

Overrides the base class method. The Tab implementation of ZeroCount only sents the count value to zero and does not free any memory. This behavior basically guarantees a memory leak, especially with strings. To many developers have assumed that NameTab free's it's strings, by using this method, thus it's implementation is getting overridden in this class and altered. This method simply calls SetSize(0)

◆ operator=()

UtilExport NameTab & operator= ( const NameTab n)

Assignment operator.

◆ SetFlag()

void SetFlag ( ULONG  f,
BOOL  b = 1 
)
inline

Sets the specified flag to the specified value.

Parameters
f- The flag(s) to set. One or more of the following values:
  • NT_INCLUDE - This bit is used to indicate "Include" mode.
  • NT_AFFECT_ILLUM - This bit is used to indicate the "Illumination" check box in the exclusion list dialog.
  • NT_AFFECT_SHADOWCAST - This bit is used to indicate the "Shadow Casting" check box in the exclusion list dialog.
b- The value to set.
54{ if (b) flags|=f; else flags &= ~f; }
float float b
Definition: texutil.h:51

◆ TestFlag()

BOOL TestFlag ( ULONG  f)
inline

Checks if a flag is set or not.

Parameters
f- The flag(s) to set. One or more of the following values:
  • NT_INCLUDE - This bit is used to indicate "Include" mode.
  • NT_AFFECT_ILLUM - This bit is used to indicate the "Illumination" check box in the exclusion list dialog.
  • NT_AFFECT_SHADOWCAST - This bit is used to indicate the "Shadow Casting" check box in the exclusion list dialog.
  • Returns
    - Returns TRUE if the specified flag(s) are set; otherwise FALSE.
63{ return (flags&f)?1:0; }

◆ AddName()

UtilExport int AddName ( const MCHAR n)

Appends a copy of the specified name to the end of the list.

Parameters
n- The name to add.
Returns
- Returns the number of items in the list prior to appending.

◆ SetName()

UtilExport void SetName ( int  i,
const MCHAR n 
)

Sets a name in the list.

Stores the specified name at the specified position in the list.

Parameters
i- The position in the list for the name.
n- The name to store. If the name is NULL, the 'i-th' entry is set to NULL.

◆ SetSize()

UtilExport void SetSize ( int  num)

Sets the size of the list.

If the new size is smaller than the current size, the entries are deleted.

Parameters
num- Specifies the size of the list.

◆ RemoveName()

UtilExport void RemoveName ( int  i)

Removes the 'i-th' name from the list.

Parameters
i- Specifies the index of the name to remove.

◆ FindName()

UtilExport int FindName ( const MCHAR n)

Finds the index of the name passed in.

Parameters
n- The name to find.
Returns
- Returns the index of the name passed; otherwise returns -1.

◆ Load()

UtilExport IOResult Load ( ILoad iload)

Loads this NameTab from disk.

Parameters
iload- Provides methods to load data from disk.
See also
I/O Results.

◆ Save()

UtilExport IOResult Save ( ISave isave)

Saves this NameTab to disk.

Parameters
isave- Provides methods to save data to disk.
See also
I/O Results.