Skip to content

Commit

Permalink
Move NodeType enum to xml2_types.h
Browse files Browse the repository at this point in the history
  • Loading branch information
mgirlich committed Aug 29, 2023
1 parent 69da196 commit 03445ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 18 additions & 0 deletions inst/include/xml2_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
#define R_NO_REMAP
#include <Rinternals.h>

enum NodeType {
missing = 1,
node = 2,
nodeset = 3,
};

inline const NodeType getNodeType(SEXP x) {
if (Rf_inherits(x, "xml_node")) {
return(NodeType::node);
} else if (Rf_inherits(x, "xml_nodeset")) {
return(NodeType::nodeset);
} else if (Rf_inherits(x, "xml_missing")) {
return(NodeType::missing);
} else {
Rf_error("Unexpected node type");
}
}

template <typename T> class XPtr {
protected:
SEXP data_;
Expand Down
18 changes: 0 additions & 18 deletions src/xml2_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@
#include <map>
#include <string>

enum NodeType {
missing = 1,
node = 2,
nodeset = 3,
};

inline const NodeType getNodeType(SEXP x) {
if (Rf_inherits(x, "xml_node")) {
return(NodeType::node);
} else if (Rf_inherits(x, "xml_nodeset")) {
return(NodeType::nodeset);
} else if (Rf_inherits(x, "xml_missing")) {
return(NodeType::missing);
} else {
Rf_error("Unexpected node type");
}
}

inline const xmlChar* asXmlChar(std::string const& x) {
return (const xmlChar*) x.c_str();
}
Expand Down

0 comments on commit 03445ec

Please sign in to comment.