HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_VariadicPOD Class Reference

#include <UT_Variadic.h>

+ Inheritance diagram for UT_VariadicPOD:

Public Types

typedef UT_VariadicT
< UT_VariadicPODType
Base
 

Public Member Functions

 UT_VariadicPOD ()
 
 UT_VariadicPOD (const UT_VariadicPOD &src)
 
 ~UT_VariadicPOD ()
 
UT_VariadicPODoperator<< (const UT_VariadicPODType &val)
 
bool import (int arg, int32 &value) const
 
bool import (int arg, int64 &value) const
 
bool import (int arg, fpreal32 &value, bool strict_value=false) const
 
bool import (int arg, fpreal64 &value, bool strict_value=false) const
 
bool import (int arg, const char *&value) const
 
bool import (int arg, const int8 *&value) const
 
bool import (int arg, const uint8 *&value) const
 
bool import (int arg, const int16 *&value) const
 
bool import (int arg, const uint16 *&value) const
 
bool import (int arg, const int32 *&value) const
 
bool import (int arg, const int64 *&value) const
 
bool import (int arg, const fpreal16 *&value) const
 
bool import (int arg, const fpreal32 *&value) const
 
bool import (int arg, const fpreal64 *&value) const
 
bool save (UT_JSONWriter &w) const
 
void dump () const
 
- Public Member Functions inherited from UT_VariadicT< UT_VariadicPODType >
 UT_VariadicT ()
 
 UT_VariadicT (const UT_VariadicT< UT_VariadicPODType > &src)
 
 ~UT_VariadicT ()
 
UT_VariadicT
< UT_VariadicPODType > & 
operator<< (const UT_VariadicPODType &val)
 
exint entries () const
 
const UT_VariadicPODTypeitem (exint arg) const
 
void append (const UT_VariadicPODType &v)
 

Additional Inherited Members

- Protected Attributes inherited from UT_VariadicT< UT_VariadicPODType >
UT_Array< const
UT_VariadicPODType * > 
myItems
 

Detailed Description

Specialization of UT_VariadicT for simple int/float/string types. This class supports implicit casting from integer to float types.

UT_VariadicPOD allows you to easily create a type-safe variadic argument list. For example, a function that takes variadic args might be something like:

// Instead of void function(...)
void function(const UT_Variadic &vargs)
{
fpreal fval;
int64 ival;
const char *sval;
for (exint i = 0; i < vargs.entries()-1; i += 2)
{
// First argument is expected to be a string
if (!vargs.import(i, sval)) return error("Expected keyword");
switch (getType(sval))
{
case 0:
if (!vargs.import(i+1, ival))
return error("Expected integer value");
break;
case 1:
if (!vargs.import(i+1, fval))
return error("Expected real value");
break;
case 2:
if (!vargs.import(i+1, sval))
return error("Expected string value");
break;
}
}
}

To call a function with variadic arguments is fairly straightforward

function(UT_Variadic() << "int" << 3
<< "real << 3.421
<< "string" << "Hello world!");

Of course, in the above example, it might be better to use

typedef UT_VariadicT<VariadicPODPair> VariadicKwPODPairs;

Definition at line 131 of file UT_Variadic.h.

Member Typedef Documentation

Constructor & Destructor Documentation

UT_VariadicPOD::UT_VariadicPOD ( )
inline

Definition at line 136 of file UT_Variadic.h.

UT_VariadicPOD::UT_VariadicPOD ( const UT_VariadicPOD src)
inline

Definition at line 140 of file UT_Variadic.h.

UT_VariadicPOD::~UT_VariadicPOD ( )
inline

Definition at line 144 of file UT_Variadic.h.

Member Function Documentation

void UT_VariadicPOD::dump ( ) const

Save argument list or dump to stdout

bool UT_VariadicPOD::import ( int  arg,
int32 value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
int64 value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
fpreal32 value,
bool  strict_value = false 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
fpreal64 value,
bool  strict_value = false 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const char *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const int8 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const uint8 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const int16 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const uint16 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const int32 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const int64 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const fpreal16 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const fpreal32 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

bool UT_VariadicPOD::import ( int  arg,
const fpreal64 *&  value 
) const

Import the value. This performs type safety checks. When importing real values, integer values will be implicitly cast unless the strict_value option is set.

UT_VariadicPOD& UT_VariadicPOD::operator<< ( const UT_VariadicPODType val)
inline

Definition at line 148 of file UT_Variadic.h.

bool UT_VariadicPOD::save ( UT_JSONWriter w) const

Save argument list or dump to stdout


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