VTK
dox/Common/vtkVariantCreate.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkVariantCreate.h
00005   
00006 -------------------------------------------------------------------------
00007   Copyright 2008 Sandia Corporation.
00008   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009   the U.S. Government retains certain rights in this software.
00010 -------------------------------------------------------------------------
00011 
00012   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00013   All rights reserved.
00014   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00015 
00016      This software is distributed WITHOUT ANY WARRANTY; without even
00017      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00018      PURPOSE.  See the above copyright notice for more information.
00019 
00020 =========================================================================*/
00021 
00022 #ifndef __vtkVariantCreate_h
00023 #define __vtkVariantCreate_h
00024 
00025 
00026 // .SECTION Thanks
00027 // Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National Laboratories.
00028 
00029 // Description:
00030 // Performs an explicit conversion from an arbitrary type to a vtkVariant.  Provides
00031 // callers with a "hook" for defining conversions from user-defined types to vtkVariant.
00032 template<typename T>
00033 vtkVariant vtkVariantCreate(const T&)
00034 {
00035   vtkGenericWarningMacro(
00036     << "Cannot convert unsupported type [" << typeid(T).name() << "] to vtkVariant.  "
00037     << "Create a vtkVariantCreate<> specialization to eliminate this warning."
00038     );
00039 
00040   return vtkVariant();
00041 }
00042 
00043 template<>
00044 inline vtkVariant vtkVariantCreate<char>(const char& value)
00045 {
00046   return value;
00047 }
00048 
00049 template<>
00050 inline vtkVariant vtkVariantCreate<unsigned char>(const unsigned char& value)
00051 {
00052   return value;
00053 }
00054 
00055 template<>
00056 inline vtkVariant vtkVariantCreate<short>(const short& value)
00057 {
00058   return value;
00059 }
00060 
00061 template<>
00062 inline vtkVariant vtkVariantCreate<unsigned short>(const unsigned short& value)
00063 {
00064   return value;
00065 }
00066 
00067 template<>
00068 inline vtkVariant vtkVariantCreate<int>(const int& value)
00069 {
00070   return value;
00071 }
00072 
00073 template<>
00074 inline vtkVariant vtkVariantCreate<unsigned int>(const unsigned int& value)
00075 {
00076   return value;
00077 }
00078 
00079 template<>
00080 inline vtkVariant vtkVariantCreate<long>(const long& value)
00081 {
00082   return value;
00083 }
00084 
00085 template<>
00086 inline vtkVariant vtkVariantCreate<unsigned long>(const unsigned long& value)
00087 {
00088   return value;
00089 }
00090 
00091 #ifdef VTK_TYPE_USE___INT64
00092 
00093 template<>
00094 inline vtkVariant vtkVariantCreate<__int64>(const __int64& value)
00095 {
00096   return value;
00097 }
00098 
00099 template<>
00100 inline vtkVariant vtkVariantCreate<unsigned __int64>(const unsigned __int64& value)
00101 {
00102   return value;
00103 }
00104 
00105 #endif
00106 
00107 
00108 #ifdef VTK_TYPE_USE_LONG_LONG
00109 
00110 template<>
00111 inline vtkVariant vtkVariantCreate<long long>(const long long& value)
00112 {
00113   return value;
00114 }
00115 
00116 template<>
00117 inline vtkVariant vtkVariantCreate<unsigned long long>(const unsigned long long& value)
00118 {
00119   return value;
00120 }
00121 
00122 #endif
00123 
00124 template<>
00125 inline vtkVariant vtkVariantCreate<float>(const float& value)
00126 {
00127   return value;
00128 }
00129 
00130 template<>
00131 inline vtkVariant vtkVariantCreate<double>(const double& value)
00132 {
00133   return value;
00134 }
00135 
00136 template<>
00137 inline vtkVariant vtkVariantCreate<vtkStdString>(const vtkStdString& value)
00138 {
00139   return value;
00140 }
00141 
00142 template<>
00143 inline vtkVariant vtkVariantCreate<vtkUnicodeString>(const vtkUnicodeString& value)
00144 {
00145   return value;
00146 }
00147 
00148 template<>
00149 inline vtkVariant vtkVariantCreate<vtkVariant>(const vtkVariant& value)
00150 {
00151   return value;
00152 }
00153 
00154 #endif
00155