VTK  9.4.20241113
Public Types | Public Member Functions | Friends | List of all members
vtkVariant Class Reference

A type representing the union of many types. More...

#include <vtkVariant.h>

Collaboration diagram for vtkVariant:
[legend]

Public Types

enum  StringFormatting { DEFAULT_FORMATTING = 0 , FIXED_FORMATTING = 1 , SCIENTIFIC_FORMATTING = 2 }
 

Public Member Functions

 vtkVariant ()
 Create an invalid variant.
 
 ~vtkVariant ()
 Destruct the variant.
 
 vtkVariant (const vtkVariant &other)
 Copy constructor.
 
 vtkVariant (bool value)
 Create a bool variant.
 
 vtkVariant (char value)
 Create a char variant.
 
 vtkVariant (unsigned char value)
 Create an unsigned char variant.
 
 vtkVariant (signed char value)
 Create a signed char variant.
 
 vtkVariant (short value)
 Create a short variant.
 
 vtkVariant (unsigned short value)
 Create an unsigned short variant.
 
 vtkVariant (int value)
 Create an integer variant.
 
 vtkVariant (unsigned int value)
 Create an unsigned integer variant.
 
 vtkVariant (long value)
 Create an long variant.
 
 vtkVariant (unsigned long value)
 Create an unsigned long variant.
 
 vtkVariant (long long value)
 Create a long long variant.
 
 vtkVariant (unsigned long long value)
 Create an unsigned long long variant.
 
 vtkVariant (float value)
 Create a float variant.
 
 vtkVariant (double value)
 Create a double variant.
 
 vtkVariant (const char *value)
 Create a string variant from a const char*.
 
 vtkVariant (vtkStdString value)
 Create a string variant from a std string.
 
 vtkVariant (vtkObjectBase *value)
 Create a vtkObjectBase variant.
 
 vtkVariant (const vtkVariant &other, unsigned int type)
 Create a new variant by copying the given variant but converting it to the given type.
 
vtkVariantoperator= (const vtkVariant &other)
 Copy the value of one variant into another.
 
bool IsValid () const
 Get whether the variant value is valid.
 
bool IsString () const
 Get whether the variant is a string.
 
bool IsNumeric () const
 Get whether the variant is any numeric type.
 
bool IsFloat () const
 Get whether the variant is a float.
 
bool IsDouble () const
 Get whether the variant is a double.
 
bool IsChar () const
 Get whether the variant is an char.
 
bool IsUnsignedChar () const
 Get whether the variant is an unsigned char.
 
bool IsSignedChar () const
 Get whether the variant is an signed char.
 
bool IsShort () const
 Get whether the variant is an short.
 
bool IsUnsignedShort () const
 Get whether the variant is an unsigned short.
 
bool IsInt () const
 Get whether the variant is an int.
 
bool IsUnsignedInt () const
 Get whether the variant is an unsigned int.
 
bool IsLong () const
 Get whether the variant is an long.
 
bool IsUnsignedLong () const
 Get whether the variant is an unsigned long.
 
bool IsLongLong () const
 Get whether the variant is long long.
 
bool IsUnsignedLongLong () const
 Get whether the variant is unsigned long long.
 
bool IsVTKObject () const
 Get whether the variant is a VTK object pointer (i.e.
 
bool IsArray () const
 Get whether the variant is a VTK array (i.e.
 
unsigned int GetType () const
 Get the type of the variant.
 
const char * GetTypeAsString () const
 Get the type of the variant as a string.
 
vtkStdString ToString (int formatting=DEFAULT_FORMATTING, int precision=6) const
 Convert the variant to a string.
 
vtkObjectBaseToVTKObject () const
 Return the VTK object, or nullptr if not of that type.
 
vtkAbstractArrayToArray () const
 Return the array, or nullptr if not of that type.
 
bool IsEqual (const vtkVariant &other) const
 Determines whether two variants have the same value.
 
float ToFloat (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
float ToFloat () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
double ToDouble (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
double ToDouble () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
char ToChar (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
char ToChar () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned char ToUnsignedChar (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned char ToUnsignedChar () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
signed char ToSignedChar (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
signed char ToSignedChar () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
short ToShort (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
short ToShort () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned short ToUnsignedShort (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned short ToUnsignedShort () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
int ToInt (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
int ToInt () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned int ToUnsignedInt (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned int ToUnsignedInt () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
long ToLong (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
long ToLong () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned long ToUnsignedLong (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned long ToUnsignedLong () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
long long ToLongLong (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
long long ToLongLong () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned long long ToUnsignedLongLong (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
unsigned long long ToUnsignedLongLong () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
vtkTypeInt64 ToTypeInt64 (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
vtkTypeInt64 ToTypeInt64 () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
vtkTypeUInt64 ToTypeUInt64 (bool *valid) const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
vtkTypeUInt64 ToTypeUInt64 () const
 Convert the variant to a numeric type: If it holds a numeric, cast to the appropriate type.
 
bool operator== (const vtkVariant &other) const
 Compare two variants for equality, greater than, and less than.
 
bool operator!= (const vtkVariant &other) const
 Compare two variants for equality, greater than, and less than.
 
bool operator< (const vtkVariant &other) const
 Compare two variants for equality, greater than, and less than.
 
bool operator> (const vtkVariant &other) const
 Compare two variants for equality, greater than, and less than.
 
bool operator<= (const vtkVariant &other) const
 Compare two variants for equality, greater than, and less than.
 
bool operator>= (const vtkVariant &other) const
 Compare two variants for equality, greater than, and less than.
 

Friends

struct vtkVariantLessThan
 
struct vtkVariantEqual
 
struct vtkVariantStrictWeakOrder
 
struct vtkVariantStrictEquality
 
VTKCOMMONCORE_EXPORT ostream & operator<< (ostream &os, const vtkVariant &val)
 

Detailed Description

A 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.
Examples:
vtkVariant (Examples)
Online Examples:

Tests:
vtkVariant (Tests)

Definition at line 161 of file vtkVariant.h.

Member Enumeration Documentation

◆ StringFormatting

Enumerator
DEFAULT_FORMATTING 
FIXED_FORMATTING 
SCIENTIFIC_FORMATTING 

Definition at line 391 of file vtkVariant.h.

Constructor & Destructor Documentation

◆ vtkVariant() [1/20]

vtkVariant::vtkVariant ( )

Create an invalid variant.

The type will be VTK_VOID and IsValid will return false.

◆ ~vtkVariant()

vtkVariant::~vtkVariant ( )

Destruct the variant.

For the VTK_STRING case, invokes delete on the string. For the VTK_OBJECT case, invokes Delete() on the object.

◆ vtkVariant() [2/20]

vtkVariant::vtkVariant ( const vtkVariant other)

Copy constructor.

◆ vtkVariant() [3/20]

vtkVariant::vtkVariant ( bool  value)

Create a bool variant.

Internally store it as char. The type will be VTK_CHAR and IsValid will return true.

◆ vtkVariant() [4/20]

vtkVariant::vtkVariant ( char  value)

Create a char variant.

The type will be VTK_CHAR and IsValid will return true.

◆ vtkVariant() [5/20]

vtkVariant::vtkVariant ( unsigned char  value)

Create an unsigned char variant.

The type will be VTK_UNSIGNED_CHAR and IsValid will return true.

◆ vtkVariant() [6/20]

vtkVariant::vtkVariant ( signed char  value)

Create a signed char variant.

The type will be VTK_SIGNED_CHAR and IsValid will return true.

◆ vtkVariant() [7/20]

vtkVariant::vtkVariant ( short  value)

Create a short variant.

The type will be VTK_SHORT and IsValid will return true.

◆ vtkVariant() [8/20]

vtkVariant::vtkVariant ( unsigned short  value)

Create an unsigned short variant.

The type will be VTK_UNSIGNED_SHORT and IsValid will return true.

◆ vtkVariant() [9/20]

vtkVariant::vtkVariant ( int  value)

Create an integer variant.

The type will be VTK_INT and IsValid will return true.

◆ vtkVariant() [10/20]

vtkVariant::vtkVariant ( unsigned int  value)

Create an unsigned integer variant.

The type will be VTK_UNSIGNED_INT and IsValid will return true.

◆ vtkVariant() [11/20]

vtkVariant::vtkVariant ( long  value)

Create an long variant.

The type will be VTK_LONG and IsValid will return true.

◆ vtkVariant() [12/20]

vtkVariant::vtkVariant ( unsigned long  value)

Create an unsigned long variant.

The type will be VTK_UNSIGNED_LONG and IsValid will return true.

◆ vtkVariant() [13/20]

vtkVariant::vtkVariant ( long long  value)

Create a long long variant.

The type will be VTK_LONG_LONG and IsValid will return true.

◆ vtkVariant() [14/20]

vtkVariant::vtkVariant ( unsigned long long  value)

Create an unsigned long long variant.

The type will be VTK_UNSIGNED_LONG_LONG and IsValid will return true.

◆ vtkVariant() [15/20]

vtkVariant::vtkVariant ( float  value)

Create a float variant.

The type will be VTK_FLOAT and IsValid will return true.

◆ vtkVariant() [16/20]

vtkVariant::vtkVariant ( double  value)

Create a double variant.

The type will be VTK_DOUBLE and IsValid will return true.

◆ vtkVariant() [17/20]

vtkVariant::vtkVariant ( const char *  value)

Create a string variant from a const char*.

If nullptr is passed, the type will be VTK_VOID and IsValid will return false; else the type will be VTK_STRING and IsValid will return true.

◆ vtkVariant() [18/20]

vtkVariant::vtkVariant ( vtkStdString  value)

Create a string variant from a std string.

The type will be VTK_STRING and IsValid will return true.

◆ vtkVariant() [19/20]

vtkVariant::vtkVariant ( vtkObjectBase value)

Create a vtkObjectBase variant.

If nullptr is passed, the type will be VTK_VOID and IsValid will return false; else the type will be VTK_OBJECT and IsValid will return true.

◆ vtkVariant() [20/20]

vtkVariant::vtkVariant ( const vtkVariant other,
unsigned int  type 
)

Create a new variant by copying the given variant but converting it to the given type.

type must be one of: VTK_STRING, VTK_OBJECT, VTK_CHAR, VTK_SIGNED_CHAR, VTK_UNSIGNED_CHAR, VTK_SHORT, VTK_UNSIGNED_SHORT, VTK_INT, VTK_UNSIGNED_INT, VTK_LONG, VTK_UNSIGNED_LONG, VTK_LONG_LONG, VTK_UNSIGNED_LONG_LONG, VTK_FLOAT, VTK_DOUBLE.

Member Function Documentation

◆ operator=()

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

Copy the value of one variant into another.

◆ IsValid()

bool vtkVariant::IsValid ( ) const

Get whether the variant value is valid.

Simple scalar types are always considered valid. Strings and pointers are considered valid only if non-nullptr.

◆ IsString()

bool vtkVariant::IsString ( ) const

Get whether the variant is a string.

◆ IsNumeric()

bool vtkVariant::IsNumeric ( ) const

Get whether the variant is any numeric type.

◆ IsFloat()

bool vtkVariant::IsFloat ( ) const

Get whether the variant is a float.

◆ IsDouble()

bool vtkVariant::IsDouble ( ) const

Get whether the variant is a double.

◆ IsChar()

bool vtkVariant::IsChar ( ) const

Get whether the variant is an char.

◆ IsUnsignedChar()

bool vtkVariant::IsUnsignedChar ( ) const

Get whether the variant is an unsigned char.

◆ IsSignedChar()

bool vtkVariant::IsSignedChar ( ) const

Get whether the variant is an signed char.

◆ IsShort()

bool vtkVariant::IsShort ( ) const

Get whether the variant is an short.

◆ IsUnsignedShort()

bool vtkVariant::IsUnsignedShort ( ) const

Get whether the variant is an unsigned short.

◆ IsInt()

bool vtkVariant::IsInt ( ) const

Get whether the variant is an int.

◆ IsUnsignedInt()

bool vtkVariant::IsUnsignedInt ( ) const

Get whether the variant is an unsigned int.

◆ IsLong()

bool vtkVariant::IsLong ( ) const

Get whether the variant is an long.

◆ IsUnsignedLong()

bool vtkVariant::IsUnsignedLong ( ) const

Get whether the variant is an unsigned long.

◆ IsLongLong()

bool vtkVariant::IsLongLong ( ) const

Get whether the variant is long long.

◆ IsUnsignedLongLong()

bool vtkVariant::IsUnsignedLongLong ( ) const

Get whether the variant is unsigned long long.

◆ IsVTKObject()

bool vtkVariant::IsVTKObject ( ) const

Get whether the variant is a VTK object pointer (i.e.

vtkObjectBase or a subclass thereof).

◆ IsArray()

bool vtkVariant::IsArray ( ) const

Get whether the variant is a VTK array (i.e.

vtkAbstractArray or a subclass thereof).

◆ GetType()

unsigned int vtkVariant::GetType ( ) const

Get the type of the variant.

◆ GetTypeAsString()

const char * vtkVariant::GetTypeAsString ( ) const

Get the type of the variant as a string.

◆ ToString()

vtkStdString vtkVariant::ToString ( int  formatting = DEFAULT_FORMATTING,
int  precision = 6 
) const

Convert the variant to a string.

Set the formatting argument to either DEFAULT_FORMATTING, FIXED_FORMATTING, SCIENTIFIC_FORMATTING to control the formatting. Set the precision argument to control the precision of the output. These two parameters have no effect when the variant is not a floating-point value or an array of floating-point values. See the std doc for more information.

◆ ToFloat() [1/2]

float vtkVariant::ToFloat ( bool *  valid) 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.

◆ ToFloat() [2/2]

float vtkVariant::ToFloat ( ) 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 419 of file vtkVariant.h.

◆ ToDouble() [1/2]

double vtkVariant::ToDouble ( bool *  valid) 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.

◆ ToDouble() [2/2]

double vtkVariant::ToDouble ( ) 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 421 of file vtkVariant.h.

◆ ToChar() [1/2]

char vtkVariant::ToChar ( bool *  valid) 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.

◆ ToChar() [2/2]

char vtkVariant::ToChar ( ) 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 423 of file vtkVariant.h.

◆ ToUnsignedChar() [1/2]

unsigned char vtkVariant::ToUnsignedChar ( bool *  valid) 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.

◆ ToUnsignedChar() [2/2]

unsigned char vtkVariant::ToUnsignedChar ( ) 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 425 of file vtkVariant.h.

◆ ToSignedChar() [1/2]

signed char vtkVariant::ToSignedChar ( bool *  valid) 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.

◆ ToSignedChar() [2/2]

signed char vtkVariant::ToSignedChar ( ) 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 427 of file vtkVariant.h.

◆ ToShort() [1/2]

short vtkVariant::ToShort ( bool *  valid) 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.

◆ ToShort() [2/2]

short vtkVariant::ToShort ( ) 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 429 of file vtkVariant.h.

◆ ToUnsignedShort() [1/2]

unsigned short vtkVariant::ToUnsignedShort ( bool *  valid) 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.

◆ ToUnsignedShort() [2/2]

unsigned short vtkVariant::ToUnsignedShort ( ) 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 431 of file vtkVariant.h.

◆ ToInt() [1/2]

int vtkVariant::ToInt ( bool *  valid) 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.

◆ ToInt() [2/2]

int vtkVariant::ToInt ( ) 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 433 of file vtkVariant.h.

◆ ToUnsignedInt() [1/2]

unsigned int vtkVariant::ToUnsignedInt ( bool *  valid) 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.

◆ ToUnsignedInt() [2/2]

unsigned int vtkVariant::ToUnsignedInt ( ) 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 435 of file vtkVariant.h.

◆ ToLong() [1/2]

long vtkVariant::ToLong ( bool *  valid) 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.

◆ ToLong() [2/2]

long vtkVariant::ToLong ( ) 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 437 of file vtkVariant.h.

◆ ToUnsignedLong() [1/2]

unsigned long vtkVariant::ToUnsignedLong ( bool *  valid) 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.

◆ ToUnsignedLong() [2/2]

unsigned long vtkVariant::ToUnsignedLong ( ) 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 439 of file vtkVariant.h.

◆ ToLongLong() [1/2]

long long vtkVariant::ToLongLong ( bool *  valid) 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.

◆ ToLongLong() [2/2]

long long vtkVariant::ToLongLong ( ) 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 441 of file vtkVariant.h.

◆ ToUnsignedLongLong() [1/2]

unsigned long long vtkVariant::ToUnsignedLongLong ( bool *  valid) 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.

◆ ToUnsignedLongLong() [2/2]

unsigned long long vtkVariant::ToUnsignedLongLong ( ) 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 443 of file vtkVariant.h.

◆ ToTypeInt64() [1/2]

vtkTypeInt64 vtkVariant::ToTypeInt64 ( bool *  valid) 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.

◆ ToTypeInt64() [2/2]

vtkTypeInt64 vtkVariant::ToTypeInt64 ( ) 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 445 of file vtkVariant.h.

◆ ToTypeUInt64() [1/2]

vtkTypeUInt64 vtkVariant::ToTypeUInt64 ( bool *  valid) 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.

◆ ToTypeUInt64() [2/2]

vtkTypeUInt64 vtkVariant::ToTypeUInt64 ( ) 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 447 of file vtkVariant.h.

◆ ToVTKObject()

vtkObjectBase * vtkVariant::ToVTKObject ( ) const

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

◆ ToArray()

vtkAbstractArray * vtkVariant::ToArray ( ) const

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

◆ IsEqual()

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);

◆ operator==()

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 94 of file vtkVariantInlineOperators.h.

◆ operator!=()

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 238 of file vtkVariantInlineOperators.h.

◆ operator<()

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 162 of file vtkVariantInlineOperators.h.

◆ operator>()

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 243 of file vtkVariantInlineOperators.h.

◆ operator<=()

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 248 of file vtkVariantInlineOperators.h.

◆ operator>=()

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 253 of file vtkVariantInlineOperators.h.

Friends And Related Symbol Documentation

◆ vtkVariantLessThan

friend struct vtkVariantLessThan
friend

Definition at line 539 of file vtkVariant.h.

◆ vtkVariantEqual

friend struct vtkVariantEqual
friend

Definition at line 540 of file vtkVariant.h.

◆ vtkVariantStrictWeakOrder

friend struct vtkVariantStrictWeakOrder
friend

Definition at line 541 of file vtkVariant.h.

◆ vtkVariantStrictEquality

friend struct vtkVariantStrictEquality
friend

Definition at line 542 of file vtkVariant.h.

◆ operator<<

VTKCOMMONCORE_EXPORT ostream & operator<< ( ostream &  os,
const vtkVariant val 
)
friend

Member Data Documentation

◆ String

vtkStdString* vtkVariant::String

Definition at line 519 of file vtkVariant.h.

◆ Float

float vtkVariant::Float

Definition at line 520 of file vtkVariant.h.

◆ Double

double vtkVariant::Double

Definition at line 521 of file vtkVariant.h.

◆ Char

char vtkVariant::Char

Definition at line 522 of file vtkVariant.h.

◆ UnsignedChar

unsigned char vtkVariant::UnsignedChar

Definition at line 523 of file vtkVariant.h.

◆ SignedChar

signed char vtkVariant::SignedChar

Definition at line 524 of file vtkVariant.h.

◆ Short

short vtkVariant::Short

Definition at line 525 of file vtkVariant.h.

◆ UnsignedShort

unsigned short vtkVariant::UnsignedShort

Definition at line 526 of file vtkVariant.h.

◆ Int

int vtkVariant::Int

Definition at line 527 of file vtkVariant.h.

◆ UnsignedInt

unsigned int vtkVariant::UnsignedInt

Definition at line 528 of file vtkVariant.h.

◆ Long

long vtkVariant::Long

Definition at line 529 of file vtkVariant.h.

◆ UnsignedLong

unsigned long vtkVariant::UnsignedLong

Definition at line 530 of file vtkVariant.h.

◆ LongLong

long long vtkVariant::LongLong

Definition at line 531 of file vtkVariant.h.

◆ UnsignedLongLong

unsigned long long vtkVariant::UnsignedLongLong

Definition at line 532 of file vtkVariant.h.

◆ VTKObject

vtkObjectBase* vtkVariant::VTKObject

Definition at line 533 of file vtkVariant.h.


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