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

Method is

inst/include/Rcpp/api/meat/S4.h:24–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23 template <template <class> class StoragePolicy>
24 bool S4_Impl<StoragePolicy>::is( const std::string& clazz) const {
25 CharacterVector cl = AttributeProxyPolicy<S4_Impl>::attr("class");
26
27 // simple test for exact match
28 if( ! clazz.compare( cl[0] ) ) return true ;
29
30 try{
31 SEXP containsSym = Rf_install("contains");
32 Shield<SEXP> classDef( R_getClassDef(CHAR(Rf_asChar(cl))) ) ;
33 CharacterVector res( Rf_getAttrib( R_do_slot( classDef, containsSym), R_NamesSymbol));
34
35 return any( res.begin(), res.end(), clazz.c_str() ) ;
36 } catch( ... ){
37 // we catch eval_error and also not_compatible when
38 // contains is NULL
39 }
40 return false ;
41 }
42
43
44}

Callers 2

S4_is_trackFunction · 0.80
S4_is_trackCurveFunction · 0.80

Calls 3

anyFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected