VTK
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 
22 #ifndef __vtkVariantCreate_h
23 #define __vtkVariantCreate_h
24 
25 
26 // .SECTION Thanks
27 // Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National Laboratories.
28 
29 // Description:
30 // Performs an explicit conversion from an arbitrary type to a vtkVariant. Provides
31 // callers with a "hook" for defining conversions from user-defined types to vtkVariant.
32 template<typename T>
34 {
35  vtkGenericWarningMacro(
36  << "Cannot convert unsupported type [" << typeid(T).name() << "] to vtkVariant. "
37  << "Create a vtkVariantCreate<> specialization to eliminate this warning."
38  );
39 
40  return vtkVariant();
41 }
42 
43 template<>
44 inline vtkVariant vtkVariantCreate<char>(const char& value)
45 {
46  return value;
47 }
48 
49 template<>
50 inline vtkVariant vtkVariantCreate<unsigned char>(const unsigned char& value)
51 {
52  return value;
53 }
54 
55 template<>
56 inline vtkVariant vtkVariantCreate<short>(const short& value)
57 {
58  return value;
59 }
60 
61 template<>
62 inline vtkVariant vtkVariantCreate<unsigned short>(const unsigned short& value)
63 {
64  return value;
65 }
66 
67 template<>
68 inline vtkVariant vtkVariantCreate<int>(const int& value)
69 {
70  return value;
71 }
72 
73 template<>
74 inline vtkVariant vtkVariantCreate<unsigned int>(const unsigned int& value)
75 {
76  return value;
77 }
78 
79 template<>
80 inline vtkVariant vtkVariantCreate<long>(const long& value)
81 {
82  return value;
83 }
84 
85 template<>
86 inline vtkVariant vtkVariantCreate<unsigned long>(const unsigned long& value)
87 {
88  return value;
89 }
90 
91 #ifdef VTK_TYPE_USE___INT64
92 
93 template<>
94 inline vtkVariant vtkVariantCreate<__int64>(const __int64& value)
95 {
96  return value;
97 }
98 
99 template<>
100 inline vtkVariant vtkVariantCreate<unsigned __int64>(const unsigned __int64& value)
101 {
102  return value;
103 }
104 
105 #endif
106 
107 
108 #ifdef VTK_TYPE_USE_LONG_LONG
109 
110 template<>
111 inline vtkVariant vtkVariantCreate<long long>(const long long& value)
112 {
113  return value;
114 }
115 
116 template<>
117 inline vtkVariant vtkVariantCreate<unsigned long long>(const unsigned long long& value)
118 {
119  return value;
120 }
121 
122 #endif
123 
124 template<>
125 inline vtkVariant vtkVariantCreate<float>(const float& value)
126 {
127  return value;
128 }
129 
130 template<>
131 inline vtkVariant vtkVariantCreate<double>(const double& value)
132 {
133  return value;
134 }
135 
136 template<>
138 {
139  return value;
140 }
141 
142 template<>
144 {
145  return value;
146 }
147 
148 template<>
150 {
151  return value;
152 }
153 
154 #endif
155 
Wrapper around vtkstd::string to keep symbols short.
Definition: vtkStdString.h:45
vtkVariant vtkVariantCreate< vtkVariant >(const vtkVariant &value)
vtkVariant vtkVariantCreate(const T &)
vtkVariant vtkVariantCreate< short >(const short &value)
vtkVariant vtkVariantCreate< int >(const int &value)
vtkVariant vtkVariantCreate< double >(const double &value)
vtkVariant vtkVariantCreate< vtkUnicodeString >(const vtkUnicodeString &value)
vtkVariant vtkVariantCreate< unsigned int >(const unsigned int &value)
vtkVariant vtkVariantCreate< vtkStdString >(const vtkStdString &value)
A atomic type representing the union of many types.
Definition: vtkVariant.h:72
vtkVariant vtkVariantCreate< unsigned short >(const unsigned short &value)
vtkVariant vtkVariantCreate< char >(const char &value)
vtkVariant vtkVariantCreate< float >(const float &value)
vtkVariant vtkVariantCreate< unsigned long >(const unsigned long &value)
vtkVariant vtkVariantCreate< unsigned char >(const unsigned char &value)
vtkVariant vtkVariantCreate< long >(const long &value)
String class that stores Unicode text.