A atomic type representing the union of many types.
More...
#include <vtkVariant.h>
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.
- Examples:
- vtkVariant (Examples)
- Tests:
- vtkVariant (Tests)
Definition at line 78 of file vtkVariant.h.
vtkVariant::vtkVariant |
( |
| ) |
|
Create an invalid variant.
vtkVariant::~vtkVariant |
( |
| ) |
|
vtkVariant::vtkVariant |
( |
const vtkVariant & |
other | ) |
|
vtkVariant::vtkVariant |
( |
bool |
value | ) |
|
Create a bool variant. Internally store it as char.
vtkVariant::vtkVariant |
( |
char |
value | ) |
|
vtkVariant::vtkVariant |
( |
unsigned char |
value | ) |
|
Create an unsigned char variant.
vtkVariant::vtkVariant |
( |
signed char |
value | ) |
|
Create a signed char variant.
vtkVariant::vtkVariant |
( |
short |
value | ) |
|
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 | ) |
|
vtkVariant::vtkVariant |
( |
unsigned long |
value | ) |
|
Create an unsigned long variant.
vtkVariant::vtkVariant |
( |
float |
value | ) |
|
vtkVariant::vtkVariant |
( |
double |
value | ) |
|
vtkVariant::vtkVariant |
( |
const char * |
value | ) |
|
Create a string variant from a const char*.
Create a string variant from a std string.
Create a Unicode string variant
vtkVariant::vtkVariant |
( |
const vtkVariant & |
other, |
|
|
unsigned int |
type |
|
) |
| |
Create a variant of a specific type.
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::IsUnicodeString |
( |
| ) |
const |
Get whether the variant is a Unicode 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 |
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.
Convert the variant to a string.
convert the variant to a Unicode string.
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.
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 248 of file vtkVariant.h.
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.
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 251 of file vtkVariant.h.
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.
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 254 of file vtkVariant.h.
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.
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 257 of file vtkVariant.h.
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.
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 260 of file vtkVariant.h.
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.
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 263 of file vtkVariant.h.
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.
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 266 of file vtkVariant.h.
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.
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 269 of file vtkVariant.h.
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.
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 272 of file vtkVariant.h.
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.
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 275 of file vtkVariant.h.
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.
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 278 of file vtkVariant.h.
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.
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 297 of file vtkVariant.h.
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.
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 300 of file vtkVariant.h.
Return the VTK object, or NULL if not of that type.
Return the array, or NULL if not of that type.
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 |
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 282 of file vtkVariantInlineOperators.h.
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 194 of file vtkVariantInlineOperators.h.
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 288 of file vtkVariantInlineOperators.h.
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 295 of file vtkVariantInlineOperators.h.
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 302 of file vtkVariantInlineOperators.h.
unsigned char vtkVariant::UnsignedChar |
signed char vtkVariant::SignedChar |
unsigned short vtkVariant::UnsignedShort |
unsigned int vtkVariant::UnsignedInt |
unsigned long vtkVariant::UnsignedLong |
The documentation for this class was generated from the following files:
- /home/boeckb/code/depot/group-kitware/vtk/build-release/Utilities/Doxygen/dox/Common/Core/vtkVariant.h
- /home/boeckb/code/depot/group-kitware/vtk/build-release/Utilities/Doxygen/dox/Common/Core/vtkVariantInlineOperators.h