| 78 | } |
| 79 | |
| 80 | std::vector<std::string> attributeNames() const { |
| 81 | std::vector<std::string> v; |
| 82 | #if R_VERSION >= R_Version(4, 6, 0) |
| 83 | auto visitor = [](SEXP name, SEXP attr, void* data) -> SEXP { |
| 84 | std::vector<std::string>* ptr = static_cast<std::vector<std::string>*>(data); |
| 85 | std::string s{CHAR(Rf_asChar(name))}; |
| 86 | ptr->push_back(s); |
| 87 | return NULL; |
| 88 | }; |
| 89 | R_mapAttrib(static_cast<const CLASS&>(*this).get__(), visitor, static_cast<void*>(&v)); |
| 90 | #else |
| 91 | SEXP attrs = ATTRIB( static_cast<const CLASS&>(*this).get__()); |
| 92 | while( attrs != R_NilValue ){ |
| 93 | v.push_back( std::string(CHAR(PRINTNAME(TAG(attrs)))) ) ; |
| 94 | attrs = CDR( attrs ) ; |
| 95 | } |
| 96 | #endif |
| 97 | return v; |
| 98 | } |
| 99 | |
| 100 | bool hasAttribute(const std::string& attr) const { |
| 101 | return static_cast<const CLASS&>(*this).attr(attr) != R_NilValue; |
no test coverage detected