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 ()
 
 UT_VariadicT (const UT_VariadicT< T > &src)
 
 ~UT_VariadicT ()
 
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");

Definition at line 41 of file UT_Variadic.h.

Constructor & Destructor Documentation

template<typename T>
UT_VariadicT< T >::UT_VariadicT ( )
inline

Definition at line 44 of file UT_Variadic.h.

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

Definition at line 47 of file UT_Variadic.h.

template<typename T>
UT_VariadicT< T >::~UT_VariadicT ( )
inline

Definition at line 51 of file UT_Variadic.h.

Member Function Documentation

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

Definition at line 64 of file UT_Variadic.h.

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

Definition at line 61 of file UT_Variadic.h.

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

Definition at line 62 of file UT_Variadic.h.

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

Definition at line 55 of file UT_Variadic.h.

Member Data Documentation

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

Definition at line 67 of file UT_Variadic.h.


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