VTK  9.1.0
vtkVariantCreate.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkVariantCreate.h
5
6-------------------------------------------------------------------------
7 Copyright 2008 Sandia Corporation.
8 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 the U.S. Government retains certain rights in this software.
10-------------------------------------------------------------------------
11
12 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
13 All rights reserved.
14 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
15
16 This software is distributed WITHOUT ANY WARRANTY; without even
17 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 PURPOSE. See the above copyright notice for more information.
19
20=========================================================================*/
21
32#ifndef vtkVariantCreate_h
33#define vtkVariantCreate_h
34
35#include "vtkVariant.h"
36#include <typeinfo> // for warnings
37
38template <typename T>
40{
41 vtkGenericWarningMacro(
42 << "Cannot convert unsupported type [" << typeid(T).name() << "] to vtkVariant. "
43 << "Create a vtkVariantCreate<> specialization to eliminate this warning.");
44
45 return vtkVariant();
46}
47
48template <>
49inline vtkVariant vtkVariantCreate<char>(const char& value)
50{
51 return value;
52}
53
54template <>
55inline vtkVariant vtkVariantCreate<unsigned char>(const unsigned char& value)
56{
57 return value;
58}
59
60template <>
61inline vtkVariant vtkVariantCreate<short>(const short& value)
62{
63 return value;
64}
65
66template <>
67inline vtkVariant vtkVariantCreate<unsigned short>(const unsigned short& value)
68{
69 return value;
70}
71
72template <>
73inline vtkVariant vtkVariantCreate<int>(const int& value)
74{
75 return value;
76}
77
78template <>
79inline vtkVariant vtkVariantCreate<unsigned int>(const unsigned int& value)
80{
81 return value;
82}
83
84template <>
85inline vtkVariant vtkVariantCreate<long>(const long& value)
86{
87 return value;
88}
89
90template <>
91inline vtkVariant vtkVariantCreate<unsigned long>(const unsigned long& value)
92{
93 return value;
94}
95
96template <>
97inline vtkVariant vtkVariantCreate<long long>(const long long& value)
98{
99 return value;
100}
101
102template <>
103inline vtkVariant vtkVariantCreate<unsigned long long>(const unsigned long long& value)
104{
105 return value;
106}
107
108template <>
109inline vtkVariant vtkVariantCreate<float>(const float& value)
110{
111 return value;
112}
113
114template <>
115inline vtkVariant vtkVariantCreate<double>(const double& value)
116{
117 return value;
118}
119
120template <>
122{
123 return value;
124}
125
126template <>
127VTK_DEPRECATED_IN_9_1_0("Use vtkVariant vtkVariantCreate<vtkStdString>(const vtkStdString& value)")
129
130template <>
132{
133 return value;
134}
135
136#endif
137
138// VTK-HeaderTest-Exclude: vtkVariantCreate.h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
String class that stores Unicode text.
Performs an explicit conversion from an arbitrary type to a vtkVariant.
A atomic type representing the union of many types.
Definition: vtkVariant.h:145
#define VTK_DEPRECATED_IN_9_1_0(reason)
vtkVariant vtkVariantCreate< vtkStdString >(const vtkStdString &value)
vtkVariant vtkVariantCreate< unsigned long >(const unsigned long &value)
vtkVariant vtkVariantCreate< float >(const float &value)
vtkVariant vtkVariantCreate< int >(const int &value)
vtkVariant vtkVariantCreate< unsigned short >(const unsigned short &value)
vtkVariant vtkVariantCreate< unsigned char >(const unsigned char &value)
vtkVariant vtkVariantCreate< unsigned int >(const unsigned int &value)
vtkVariant vtkVariantCreate< long >(const long &value)
vtkVariant vtkVariantCreate< double >(const double &value)
vtkVariant vtkVariantCreate< unsigned long long >(const unsigned long long &value)
vtkVariant vtkVariantCreate< short >(const short &value)
vtkVariant vtkVariantCreate< long long >(const long long &value)
vtkVariant vtkVariantCreate< char >(const char &value)