| 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 | } |
no test coverage detected