00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 00002 // 00003 // RcppSexp.h: Rcpp R/C++ interface class library -- SEXP support 00004 // 00005 // Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois 00006 // 00007 // This file is part of Rcpp. 00008 // 00009 // Rcpp is free software: you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation, either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // Rcpp is distributed in the hope that it will be useful, but 00015 // WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>. 00021 00022 #ifndef RcppSexp_h 00023 #define RcppSexp_h 00024 00025 #include <RcppCommon.h> 00026 #include <set> 00027 00035 class RcppSexp { 00036 public: 00037 00044 RcppSexp(SEXP m_sexp = R_NilValue) : object( Rcpp::wrap(m_sexp) ) { 00045 DEPRECATED() ; 00046 }; 00047 00048 ~RcppSexp() ; 00049 00050 RcppSexp(const double & v) : object( Rcpp::wrap( v ) ) { DEPRECATED() ; } ; 00051 RcppSexp(const int & v): object( Rcpp::wrap(v) ){ DEPRECATED() ; } ; 00052 RcppSexp(const Rbyte & v) : object( Rcpp::wrap(v) ){ DEPRECATED() ;} ; 00053 RcppSexp(const std::string & v) : object( Rcpp::wrap(v) ){ DEPRECATED() ;} ; 00054 RcppSexp(const bool & v) : object( Rcpp::wrap(v) ){ DEPRECATED() ; }; 00055 00056 RcppSexp(const std::vector<int> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ; }; 00057 RcppSexp(const std::vector<double> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ; }; 00058 RcppSexp(const std::vector<std::string> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ;}; 00059 RcppSexp(const std::vector<Rbyte> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ;}; 00060 RcppSexp(const std::vector<bool> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ;}; 00061 00062 RcppSexp(const std::set<int> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ;}; 00063 RcppSexp(const std::set<double> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ; }; 00064 RcppSexp(const std::set<std::string> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ; }; 00065 RcppSexp(const std::set<Rbyte> & v): object( Rcpp::wrap(v) ){ DEPRECATED() ; }; 00066 00067 00068 /* we don't provide implicit converters because 00069 of Item 5 in More Effective C++ */ 00070 inline bool asBool() const {return object.asBool() ; } ; 00071 inline double asDouble() const { return object.asDouble() ; } 00072 inline int asInt() const { return object.asInt() ; } 00073 inline Rbyte asRaw() const { return object.asRaw() ; } 00074 inline std::string asStdString() const { return object.asStdString() ; } 00075 inline std::vector<int> asStdVectorInt() const { return object.asStdVectorInt() ; } 00076 inline std::vector<double> asStdVectorDouble() const { return object.asStdVectorDouble(); } 00077 inline std::vector<std::string> asStdVectorString() const { return object.asStdVectorString(); } 00078 inline std::vector<Rbyte> asStdVectorRaw() const { return object.asStdVectorRaw() ;} 00079 inline std::vector<bool> asStdVectorBool() const { return object.asStdVectorBool() ; } 00080 00081 00086 inline void protect(){ object.preserve() ; } 00087 00092 inline void release() { object.release() }; 00093 00097 inline operator SEXP() const { return object.asSexp() ; } 00098 00099 00100 /* attributes */ 00101 00105 inline std::vector<std::string> attributeNames() const { return object.attributeNames() }; 00106 00110 inline bool hasAttribute( const std::string& attr) const { return object.hasAttribute( attr ) }; 00111 00115 inline SEXP attr( const std::string& name) const { return object.attr( name) ; } ; 00116 00120 inline bool isNULL() const{ return object.isNULL() ; } 00121 00125 inline int sexp_type() const { return object.sexp_type() ; } 00126 00130 inline SEXP asSexp() const { return object.asSexp() ; } 00131 00132 protected: 00133 00137 Rcpp::RObject object ; 00138 00139 void DEPRECATED(){ Rf_warning( "The class RcppSexp is deprecated, and will eventually be removed, please consider using Rcpp::RObject instead" ) ; } 00140 }; 00141 00142 #endif