Rcpp Version 1.0.9
grow.h
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2 //
3 // grow.h: Rcpp R/C++ interface class library -- grow a pairlist
4 //
5 // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
6 //
7 // This file is part of Rcpp.
8 //
9 // Rcpp is free software: you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // Rcpp is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21 
22 #ifndef Rcpp_grow_h
23 #define Rcpp_grow_h
24 
25 #include <RcppCommon.h>
26 #include <Rcpp/Named.h>
27 
28 namespace Rcpp {
29 
30  inline SEXP pairlist() {
31  return R_NilValue ;
32  }
33 
34  inline SEXP grow( SEXP head, SEXP tail ) {
35  Shield<SEXP> x( head ) ;
36  Shield<SEXP> res( Rf_cons( x, tail ) ) ;
37  return res ;
38  }
39 
40  namespace internal{
41 
42  template <typename T>
43  inline SEXP grow__dispatch( ::Rcpp::traits::false_type, const T& head, SEXP tail ){
44  return grow( wrap(head), tail ) ;
45  }
46 
47  template <typename T>
48  inline SEXP grow__dispatch( ::Rcpp::traits::true_type, const T& head, SEXP tail ){
49  Shield<SEXP> y( wrap( head.object) ) ;
50  Shield<SEXP> x( Rf_cons( y , tail) ) ;
51  SEXP headNameSym = ::Rf_install( head.name.c_str() );
52  SET_TAG( x, headNameSym );
53  return x;
54  }
55 
56  } // internal
57 
62  template <typename T>
63  SEXP grow(const T& head, SEXP tail) {
64  Shield<SEXP> y(tail);
66  }
67 
68  inline SEXP grow( const char* head, SEXP tail ) {
69  Shield<SEXP> y(tail);
70  return grow(Rf_mkString(head), y);
71  }
72 
73  #include <Rcpp/generated/grow__pairlist.h>
74 
75 } // namespace Rcpp
76 
77 #endif
SEXP grow__dispatch(::Rcpp::traits::false_type, const T &head, SEXP tail)
Definition: grow.h:43
Rcpp API.
Definition: algo.h:28
SEXP pairlist()
Definition: grow.h:30
sugar::Tail< RTYPE, NA, T > tail(const VectorBase< RTYPE, NA, T > &t, R_xlen_t n)
Definition: tail.h:56
sugar::Head< RTYPE, NA, T > head(const VectorBase< RTYPE, NA, T > &t, R_xlen_t n)
Definition: head.h:53
SEXP grow(SEXP head, SEXP tail)
Definition: grow.h:34
SEXP wrap(const Date &date)
Definition: Date.h:38