VTK  9.4.20250206
vtkVariantCreate.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4
18#ifndef vtkVariantCreate_h
19#define vtkVariantCreate_h
20
21#include "vtkVariant.h"
22#include <typeinfo> // for warnings
23
24VTK_ABI_NAMESPACE_BEGIN
25template <typename T>
27{
28 vtkGenericWarningMacro(
29 << "Cannot convert unsupported type [" << typeid(T).name() << "] to vtkVariant. "
30 << "Create a vtkVariantCreate<> specialization to eliminate this warning.");
31
32 return vtkVariant();
33}
34
35template <>
36inline vtkVariant vtkVariantCreate<char>(const char& value)
37{
38 return value;
39}
40
41template <>
42inline vtkVariant vtkVariantCreate<unsigned char>(const unsigned char& value)
43{
44 return value;
45}
46
47template <>
48inline vtkVariant vtkVariantCreate<short>(const short& value)
49{
50 return value;
51}
52
53template <>
54inline vtkVariant vtkVariantCreate<unsigned short>(const unsigned short& value)
55{
56 return value;
57}
58
59template <>
60inline vtkVariant vtkVariantCreate<int>(const int& value)
61{
62 return value;
63}
64
65template <>
66inline vtkVariant vtkVariantCreate<unsigned int>(const unsigned int& value)
67{
68 return value;
69}
70
71template <>
72inline vtkVariant vtkVariantCreate<long>(const long& value)
73{
74 return value;
75}
76
77template <>
78inline vtkVariant vtkVariantCreate<unsigned long>(const unsigned long& value)
79{
80 return value;
81}
82
83template <>
84inline vtkVariant vtkVariantCreate<long long>(const long long& value)
85{
86 return value;
87}
88
89template <>
90inline vtkVariant vtkVariantCreate<unsigned long long>(const unsigned long long& value)
91{
92 return value;
93}
94
95template <>
96inline vtkVariant vtkVariantCreate<float>(const float& value)
97{
98 return value;
99}
100
101template <>
102inline vtkVariant vtkVariantCreate<double>(const double& value)
103{
104 return value;
105}
106
107template <>
109{
110 return value;
111}
112
113template <>
115{
116 return value;
117}
118
119VTK_ABI_NAMESPACE_END
120#endif
121
122// VTK-HeaderTest-Exclude: vtkVariantCreate.h
Wrapper around std::string to keep symbols short.
Performs an explicit conversion from an arbitrary type to a vtkVariant.
A type representing the union of many types.
Definition vtkVariant.h:162
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< vtkVariant >(const vtkVariant &value)
vtkVariant vtkVariantCreate< long long >(const long long &value)
vtkVariant vtkVariantCreate< char >(const char &value)