vtkVariant Class Reference

#include <vtkVariant.h>

Collaboration diagram for vtkVariant:

Collaboration graph
[legend]

List of all members.


Detailed Description

A atomic type representing the union of many types.

Thanks:
Thanks to Patricia Crossno, Ken Moreland, Andrew Wilson and Brian Wylie from Sandia National Laboratories for their help in developing this class.
Tests:
vtkVariant (Tests)

Definition at line 60 of file vtkVariant.h.


Public Member Functions

 vtkVariant ()
 ~vtkVariant ()
 vtkVariant (const vtkVariant &other)
 vtkVariant (char value)
 vtkVariant (unsigned char value)
 vtkVariant (signed char value)
 vtkVariant (short value)
 vtkVariant (unsigned short value)
 vtkVariant (int value)
 vtkVariant (unsigned int value)
 vtkVariant (long value)
 vtkVariant (unsigned long value)
 vtkVariant (float value)
 vtkVariant (double value)
 vtkVariant (const char *value)
 vtkVariant (vtkStdString value)
 vtkVariant (vtkObjectBase *value)
const vtkVariantoperator= (const vtkVariant &other)
bool IsValid () const
bool IsString () const
bool IsNumeric () const
bool IsFloat () const
bool IsDouble () const
bool IsChar () const
bool IsUnsignedChar () const
bool IsSignedChar () const
bool IsShort () const
bool IsUnsignedShort () const
bool IsInt () const
bool IsUnsignedInt () const
bool IsLong () const
bool IsUnsignedLong () const
bool Is__Int64 () const
bool IsUnsigned__Int64 () const
bool IsLongLong () const
bool IsUnsignedLongLong () const
bool IsVTKObject () const
bool IsArray () const
unsigned int GetType () const
const char * GetTypeAsString () const
vtkStdString ToString () const
float ToFloat (bool *valid=0) const
double ToDouble (bool *valid=0) const
char ToChar (bool *valid=0) const
unsigned char ToUnsignedChar (bool *valid=0) const
signed char ToSignedChar (bool *valid=0) const
short ToShort (bool *valid=0) const
unsigned short ToUnsignedShort (bool *valid=0) const
int ToInt (bool *valid=0) const
unsigned int ToUnsignedInt (bool *valid=0) const
long ToLong (bool *valid=0) const
unsigned long ToUnsignedLong (bool *valid=0) const
vtkTypeInt64 ToTypeInt64 (bool *valid=0) const
vtkTypeUInt64 ToTypeUInt64 (bool *valid=0) const
vtkObjectBaseToVTKObject () const
vtkAbstractArrayToArray () const
template<typename T>
ToNumeric (bool *valid, T *vtkNotUsed(ignored)) const
bool IsEqual (const vtkVariant &other) const
bool operator== (const vtkVariant &other) const
bool operator!= (const vtkVariant &other) const
bool operator< (const vtkVariant &other) const
bool operator> (const vtkVariant &other) const
bool operator<= (const vtkVariant &other) const
bool operator>= (const vtkVariant &other) const

Friends

struct vtkVariantLessThan
struct vtkVariantEqual
struct vtkVariantStrictWeakOrder
struct vtkVariantStrictEquality

Constructor & Destructor Documentation

vtkVariant::vtkVariant (  ) 

Create an invalid variant.

vtkVariant::~vtkVariant (  ) 

Destruct the variant.

vtkVariant::vtkVariant ( const vtkVariant other  ) 

Copy constructor.

vtkVariant::vtkVariant ( char  value  ) 

Create a char variant.

vtkVariant::vtkVariant ( unsigned char  value  ) 

Create an unsigned char variant.

vtkVariant::vtkVariant ( signed char  value  ) 

Create a signed char variant.

vtkVariant::vtkVariant ( short  value  ) 

Create a short variant.

vtkVariant::vtkVariant ( unsigned short  value  ) 

Create an unsigned short variant.

vtkVariant::vtkVariant ( int  value  ) 

Create an integer variant.

vtkVariant::vtkVariant ( unsigned int  value  ) 

Create an unsigned integer variant.

vtkVariant::vtkVariant ( long  value  ) 

Create an long variant.

vtkVariant::vtkVariant ( unsigned long  value  ) 

Create an unsigned long variant.

vtkVariant::vtkVariant ( float  value  ) 

Create a float variant.

vtkVariant::vtkVariant ( double  value  ) 

Create a double variant.

vtkVariant::vtkVariant ( const char *  value  ) 

Create a string variant from a const char*.

vtkVariant::vtkVariant ( vtkStdString  value  ) 

Create a string variant from a std string.

vtkVariant::vtkVariant ( vtkObjectBase value  ) 

Create a vtkObjectBase variant.


Member Function Documentation

const vtkVariant& vtkVariant::operator= ( const vtkVariant other  ) 

Copy the value of one variant into another.

bool vtkVariant::IsValid (  )  const

Get whether the variant value is valid.

bool vtkVariant::IsString (  )  const

Get whether the variant is a string.

bool vtkVariant::IsNumeric (  )  const

Get whether the variant is any numeric type.

bool vtkVariant::IsFloat (  )  const

Get whether the variant is a float.

bool vtkVariant::IsDouble (  )  const

Get whether the variant is a double.

bool vtkVariant::IsChar (  )  const

Get whether the variant is an char.

bool vtkVariant::IsUnsignedChar (  )  const

Get whether the variant is an unsigned char.

bool vtkVariant::IsSignedChar (  )  const

Get whether the variant is an signed char.

bool vtkVariant::IsShort (  )  const

Get whether the variant is an short.

bool vtkVariant::IsUnsignedShort (  )  const

Get whether the variant is an unsigned short.

bool vtkVariant::IsInt (  )  const

Get whether the variant is an int.

bool vtkVariant::IsUnsignedInt (  )  const

Get whether the variant is an unsigned int.

bool vtkVariant::IsLong (  )  const

Get whether the variant is an long.

bool vtkVariant::IsUnsignedLong (  )  const

Get whether the variant is an unsigned long.

bool vtkVariant::Is__Int64 (  )  const

Get whether the variant is an __int64.

bool vtkVariant::IsUnsigned__Int64 (  )  const

Get whether the variant is an unsigned __int64.

bool vtkVariant::IsLongLong (  )  const

Get whether the variant is long long.

bool vtkVariant::IsUnsignedLongLong (  )  const

Get whether the variant is unsigned long long.

bool vtkVariant::IsVTKObject (  )  const

Get whether the variant is a VTK object pointer.

bool vtkVariant::IsArray (  )  const

Get whether the variant is a VTK array (i.e. a subclass of vtkAbstractArray).

unsigned int vtkVariant::GetType (  )  const

Get the type of the variant.

const char* vtkVariant::GetTypeAsString (  )  const

Get the type of the variant as a string.

vtkStdString vtkVariant::ToString (  )  const

Convert the variant to a string.

float vtkVariant::ToFloat ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

double vtkVariant::ToDouble ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

char vtkVariant::ToChar ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

unsigned char vtkVariant::ToUnsignedChar ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

signed char vtkVariant::ToSignedChar ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

short vtkVariant::ToShort ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

unsigned short vtkVariant::ToUnsignedShort ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

int vtkVariant::ToInt ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

unsigned int vtkVariant::ToUnsignedInt ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

long vtkVariant::ToLong ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

unsigned long vtkVariant::ToUnsignedLong ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

vtkTypeInt64 vtkVariant::ToTypeInt64 ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

vtkTypeUInt64 vtkVariant::ToTypeUInt64 ( bool *  valid = 0  )  const

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

vtkObjectBase* vtkVariant::ToVTKObject (  )  const

Return the VTK object, or NULL if not of that type.

vtkAbstractArray* vtkVariant::ToArray (  )  const

Return the array, or NULL if not of that type.

template<typename T>
T vtkVariant::ToNumeric ( bool *  valid,
T *  vtkNotUsedignored 
) const [inline]

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

bool vtkVariant::IsEqual ( const vtkVariant other  )  const

Determines whether two variants have the same value. They do not need to be storing exactly the same type to have the same value. In practice you don't need to use this method: just use operator== instead. If you want precise equality down to the bit level use the following idiom: vtkVariantStrictEquality comparator; bool variantsEqual = comparator(firstVariant, secondVariant);

bool vtkVariant::operator== ( const vtkVariant other  )  const [inline]

Compare two variants for equality, greater than, and less than. These operators use the value represented by the variant instead of the particular type/bit pattern used to represent it. This behavior is similar to the default behavior in C and C++, including type promotion, with the following caveats: * When comparing type X with a string, type X will first be converted to string, then compared lexically (the usual behavior of string::operator< and company). * vtkObject pointers will be converted to an unsigned integer of appropriate size. If both variants contain vtkObjects then they are comparable directly. * Comparing char values with strings will not work the way you might expect if you're treating a char as a numeric type. Char values are written to strings as literal ASCII characters instead of numbers. This approach follows the principle of least surprise at the expense of speed. Casting integers to floating-point values is relatively slow. Casting numeric types to strings is very slow. If you prefer speed at the expense of counterintuitive behavior -- for example, when using vtkVariants as keys in STL containers -- you can use the functors described at the bottom of this file. The actual definitions of these operators are in vtkVariantInlineOperators.cxx.

Definition at line 114 of file vtkVariantInlineOperators.h.

bool vtkVariant::operator!= ( const vtkVariant other  )  const [inline]

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

Definition at line 245 of file vtkVariantInlineOperators.h.

bool vtkVariant::operator< ( const vtkVariant other  )  const [inline]

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

Definition at line 175 of file vtkVariantInlineOperators.h.

bool vtkVariant::operator> ( const vtkVariant other  )  const [inline]

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

Definition at line 251 of file vtkVariantInlineOperators.h.

bool vtkVariant::operator<= ( const vtkVariant other  )  const [inline]

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

Definition at line 258 of file vtkVariantInlineOperators.h.

bool vtkVariant::operator>= ( const vtkVariant other  )  const [inline]

Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type. If it holds a string, attempt to convert the string to the appropriate type; set the valid flag to false when the conversion fails. If it holds an array type, cast the first value of the array to the appropriate type. Fail if it holds a VTK object which is not an array.

Definition at line 265 of file vtkVariantInlineOperators.h.


Friends And Related Function Documentation

friend struct vtkVariantLessThan [friend]

Definition at line 311 of file vtkVariant.h.

friend struct vtkVariantEqual [friend]

Definition at line 312 of file vtkVariant.h.

friend struct vtkVariantStrictWeakOrder [friend]

Definition at line 313 of file vtkVariant.h.

friend struct vtkVariantStrictEquality [friend]

Definition at line 314 of file vtkVariant.h.


Member Data Documentation

Definition at line 285 of file vtkVariant.h.

Definition at line 286 of file vtkVariant.h.

Definition at line 287 of file vtkVariant.h.

Definition at line 288 of file vtkVariant.h.

unsigned char vtkVariant::UnsignedChar

Definition at line 289 of file vtkVariant.h.

Definition at line 290 of file vtkVariant.h.

Definition at line 291 of file vtkVariant.h.

unsigned short vtkVariant::UnsignedShort

Definition at line 292 of file vtkVariant.h.

Definition at line 293 of file vtkVariant.h.

Definition at line 294 of file vtkVariant.h.

Definition at line 295 of file vtkVariant.h.

unsigned long vtkVariant::UnsignedLong

Definition at line 296 of file vtkVariant.h.

Definition at line 305 of file vtkVariant.h.


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

Generated on Wed Jun 3 19:43:38 2009 for VTK by  doxygen 1.5.6