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

Method attributeNames

inst/include/Rcpp/proxy/AttributeProxy.h:80–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 1

attributeNamesFunction · 0.80

Calls 2

push_backMethod · 0.45
get__Method · 0.45

Tested by

no test coverage detected