|
Rcpp Version 0.9.10
|
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 00002 /* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */ 00003 // 00004 // r_type_traits.h: Rcpp R/C++ interface class library -- traits to help wrap 00005 // 00006 // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois 00007 // 00008 // This file is part of Rcpp. 00009 // 00010 // Rcpp is free software: you can redistribute it and/or modify it 00011 // under the terms of the GNU General Public License as published by 00012 // the Free Software Foundation, either version 2 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // Rcpp is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU General Public License 00021 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>. 00022 00023 #ifndef Rcpp__traits__r_type_traits__h 00024 #define Rcpp__traits__r_type_traits__h 00025 00026 namespace Rcpp{ 00027 namespace traits{ 00028 00033 struct r_type_primitive_tag{} ; 00034 00039 struct r_type_string_tag{} ; 00040 00044 struct r_type_generic_tag{} ; 00045 00050 struct r_type_pairstring_primitive_tag{} ; 00051 00055 struct r_type_pairstring_string_tag{} ; 00056 00060 struct r_type_pairstring_generic_tag{} ; 00061 00065 template <typename T> struct r_type_traits { typedef r_type_generic_tag r_category ; } ; 00066 00070 template <typename T> struct r_type_traits< std::pair<const std::string,T> > { typedef r_type_pairstring_generic_tag r_category ; } ; 00071 template<> struct r_type_traits< std::pair<const std::string,int> >{ typedef r_type_pairstring_primitive_tag r_category ; } ; 00072 template<> struct r_type_traits< std::pair<const std::string,const int> >{ typedef r_type_pairstring_primitive_tag r_category ; } ; 00073 template<> struct r_type_traits< std::pair<const std::string,double> >{ typedef r_type_pairstring_primitive_tag r_category ; } ; 00074 template<> struct r_type_traits< std::pair<const std::string,Rbyte> >{ typedef r_type_pairstring_primitive_tag r_category ; } ; 00075 template<> struct r_type_traits< std::pair<const std::string,Rcomplex> >{ typedef r_type_pairstring_primitive_tag r_category ; } ; 00076 template<> struct r_type_traits< std::pair<const std::string,bool> >{ typedef r_type_pairstring_primitive_tag r_category ; } ; 00077 template<> struct r_type_traits< std::pair<const std::string,std::string> >{ typedef r_type_pairstring_string_tag r_category ; } ; 00078 template<> struct r_type_traits< std::pair<const std::string,char> >{ typedef r_type_pairstring_string_tag r_category ; } ; 00079 00080 template<> struct r_type_traits< std::pair<const std::string,unsigned int> >{ typedef r_type_pairstring_primitive_tag r_category ; } ; 00081 template<> struct r_type_traits< std::pair<const std::string,float> >{ typedef r_type_pairstring_primitive_tag r_category ; } ; 00082 00083 template<> struct r_type_traits<int>{ typedef r_type_primitive_tag r_category ; } ; 00084 template<> struct r_type_traits<const int>{ typedef r_type_primitive_tag r_category ; } ; 00085 template<> struct r_type_traits<double>{ typedef r_type_primitive_tag r_category ; } ; 00086 template<> struct r_type_traits<Rbyte>{ typedef r_type_primitive_tag r_category ; } ; 00087 template<> struct r_type_traits<Rcomplex>{ typedef r_type_primitive_tag r_category ; } ; 00088 template<> struct r_type_traits<bool>{ typedef r_type_primitive_tag r_category ; } ; 00089 template<> struct r_type_traits<std::string>{ typedef r_type_string_tag r_category ; } ; 00090 template<> struct r_type_traits<char>{ typedef r_type_string_tag r_category ; } ; 00091 00092 template<> struct r_type_traits<unsigned int>{ typedef r_type_primitive_tag r_category ; } ; 00093 template<> struct r_type_traits<float>{ typedef r_type_primitive_tag r_category ; } ; 00094 template<> struct r_type_traits<const char*>{ typedef r_type_string_tag r_category ; } ; 00095 00096 /* long */ 00097 template<> struct r_type_traits<long>{ typedef r_type_primitive_tag r_category ; } ; 00098 template<> struct r_type_traits< std::pair<const std::string,long> >{ typedef r_type_primitive_tag r_category ; } ; 00099 00100 /* unsigned long */ 00101 template<> struct r_type_traits<unsigned long>{ typedef r_type_primitive_tag r_category ; } ; 00102 template<> struct r_type_traits< std::pair<const std::string,unsigned long> >{ typedef r_type_primitive_tag r_category ; } ; 00103 00104 /* long double */ 00105 template<> struct r_type_traits<long double>{ typedef r_type_primitive_tag r_category ; } ; 00106 template<> struct r_type_traits< std::pair<const std::string,long double> >{ typedef r_type_primitive_tag r_category ; } ; 00107 00108 /* short */ 00109 template<> struct r_type_traits<short>{ typedef r_type_primitive_tag r_category ; } ; 00110 template<> struct r_type_traits< std::pair<const std::string,short> >{ typedef r_type_primitive_tag r_category ; } ; 00111 00112 /* unsigned short */ 00113 template<> struct r_type_traits<unsigned short>{ typedef r_type_primitive_tag r_category ; } ; 00114 template<> struct r_type_traits< std::pair<const std::string,unsigned short> >{ typedef r_type_primitive_tag r_category ; } ; 00115 00116 /* std::complex<double> */ 00117 template<> struct r_type_traits< std::complex<double> >{ typedef r_type_primitive_tag r_category ; } ; 00118 template<> struct r_type_traits< std::pair<const std::string,std::complex<double> > >{ typedef r_type_primitive_tag r_category ; } ; 00119 00120 /* std::complex<float> */ 00121 template<> struct r_type_traits< std::complex<float> >{ typedef r_type_primitive_tag r_category ; } ; 00122 template<> struct r_type_traits< std::pair<const std::string,std::complex<float> > >{ typedef r_type_primitive_tag r_category ; } ; 00123 00124 /* long long int */ 00125 #ifdef RCPP_HAS_LONG_LONG_TYPES 00126 template<> struct r_type_traits<rcpp_long_long_type>{ typedef r_type_primitive_tag r_category ; } ; 00127 template<> struct r_type_traits< std::pair<const std::string,rcpp_long_long_type> >{ typedef r_type_primitive_tag r_category ; } ; 00128 template<> struct r_type_traits<rcpp_ulong_long_type>{ typedef r_type_primitive_tag r_category ; } ; 00129 template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ; 00130 #endif 00131 00132 } // traits 00133 } // Rcpp 00134 00135 #endif