File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,31 @@ enum NodeType {
1515 nodeset = 3 ,
1616};
1717
18+
19+ inline int inherits3 (SEXP x, const char *name) {
20+ SEXP expr = PROTECT (Rf_lang3 (Rf_install (" inherits" ), x, Rf_mkString (name)));
21+ SEXP result = PROTECT (Rf_eval (expr, R_GlobalEnv));
22+
23+ int out = LOGICAL (result)[0 ];
24+ UNPROTECT (2 );
25+ return out;
26+ }
27+
1828inline const NodeType getNodeType (SEXP x) {
29+
30+ // for fhircrackr
31+ if (IS_S4_OBJECT (x)) {
32+ if (inherits3 (x, " xml_node" )) {
33+ return (NodeType::node);
34+ } else if (inherits3 (x, " xml_nodeset" )) {
35+ return (NodeType::nodeset);
36+ } else if (inherits3 (x, " xml_missing" )) {
37+ return (NodeType::missing);
38+ } else {
39+ Rf_error (" Unexpected node type" );
40+ }
41+ }
42+
1943 if (Rf_inherits (x, " xml_node" )) {
2044 return (NodeType::node);
2145 } else if (Rf_inherits (x, " xml_nodeset" )) {
You can’t perform that action at this time.
0 commit comments