MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / RCPP_API_CLASS

Function RCPP_API_CLASS

inst/include/Rcpp/S4.h:29–74  ·  view source on GitHub ↗

* S4 object */

Source from the content-addressed store, hash-verified

27 * S4 object
28 */
29 RCPP_API_CLASS(S4_Impl) {
30 public:
31 RCPP_GENERATE_CTOR_ASSIGN(S4_Impl)
32
33 S4_Impl(){} ;
34
35 /**
36 * checks that x is an S4 object and wrap it.
37 *
38 * @param x must be an S4 object
39 */
40 S4_Impl(SEXP x) { // #nocov start
41 if( ! ::Rf_isS4(x) ) throw not_s4() ;
42 Storage::set__(x) ;
43 } // #nocov end
44
45 S4_Impl& operator=( SEXP other ){
46 Storage::set__( other ) ;
47 return *this ;
48 }
49
50 /**
51 * Creates an S4 object of the requested class.
52 *
53 * @param klass name of the target S4 class
54 * @throw S4_creation_error if klass does not map to a known S4 class
55 */
56 S4_Impl( const std::string& klass ){
57 Shield<SEXP> x( R_do_new_object(R_do_MAKE_CLASS(klass.c_str())) );
58 if (!Rf_inherits(x, klass.c_str()))
59 throw S4_creation_error( klass ) ; // #nocov
60 Storage::set__(x) ;
61 }
62
63 /**
64 * Indicates if this object is an instance of the given S4 class
65 */
66 bool is( const std::string& clazz) const ;
67
68 /**
69 * @throw not_s4 if x is not an S4 class
70 */
71 void update(SEXP x){
72 if( ! ::Rf_isS4(x) ) throw not_s4() ;
73 }
74 } ;
75
76 typedef S4_Impl<PreserveStorage> S4 ;
77

Callers 7

Reference.hFile · 0.70
Environment.hFile · 0.70
DottedPair.hFile · 0.70
Language.hFile · 0.70
Formula.hFile · 0.70
Pairlist.hFile · 0.70
StretchyList.hFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected