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

#include <UT_Variadic.h>

Public Member Functions

UT_VariadicT< T > & operator<< (const T &val)
 
exint entries () const
 
const Titem (exint arg) const
 
void append (const T &v)
 

Protected Attributes

UT_Array< const T * > myItems
 

Detailed Description

template<typename T>
class UT_VariadicT< T >

Build a list of variadic arguments of the given template type

C-Style variadic arguments are error prone for various reasons:

  • No type checking
  • NULL termination issues

This class provides type-safety and a cleaner interface. For example, to accept a variable length array of strings:

typedef UT_VariadicT<const char *> VariadicStrings;
void
function(const VariadicStrings &strings)
{
for (exint i = 0; i < strings.entries(); ++i)
cerr << i << " " << strings.item(i) << " " strlen(strings.item(i));
}
// Which can be called using
function(VariadicStrings() << "hello" << "world");
Examples:
karma_procedurals/BRAY_HdBox.C.

Definition at line 41 of file UT_Variadic.h.

Member Function Documentation

template<typename T>
void UT_VariadicT< T >::append ( const T v)
inline

Definition at line 54 of file UT_Variadic.h.

template<typename T>
exint UT_VariadicT< T >::entries ( ) const
inline

Definition at line 51 of file UT_Variadic.h.

template<typename T>
const T& UT_VariadicT< T >::item ( exint  arg) const
inline

Definition at line 52 of file UT_Variadic.h.

template<typename T>
UT_VariadicT<T>& UT_VariadicT< T >::operator<< ( const T val)
inline

Definition at line 45 of file UT_Variadic.h.

Member Data Documentation

template<typename T>
UT_Array<const T *> UT_VariadicT< T >::myItems
protected

Definition at line 57 of file UT_Variadic.h.


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