14 #ifndef __NODAMUSHI_SVD_TINYXML_HPP__ 15 #define __NODAMUSHI_SVD_TINYXML_HPP__ 18 # include <tinyxml2.h> 44 doc(),child(nullptr),_ok(false)
47 if(doc.LoadFile(filename.data()) == tinyxml2::XML_SUCCESS){
48 child = doc.FirstChildElement();
50 }
else if(throw_error){
59 bool ok()
const {
return _ok;}
62 using node = ::tinyxml2::XMLNode;
63 using text = ::tinyxml2::XMLText;
72 attr(false),name(e->Name()),
value(),
73 attrs(e->FirstAttribute()),child(e->FirstChildElement())
75 for(
const node* n = e->FirstChild();n!=
nullptr;n = n->NextSibling()){
76 const text* t = n->ToText();
84 attr(true),name(a->Name()),
value(a->Value()),
85 attrs(nullptr),child(nullptr)
102 child = c->NextSiblingElement();
105 operator bool()
const{
106 return attrs !=
nullptr || child !=
nullptr;
111 # if __cplusplus >= 201703 112 std::string_view name;
113 std::string_view
value;
127 # if __cplusplus >= 201703 128 std::string_view
get_name()
const{
return std::string_view{};}
129 std::string_view
get_value()
const{
return std::string_view{};}
137 child = child->NextSiblingElement();
140 operator bool()
const{
return child !=
nullptr;}
sub_reader(const attribute *a)
std::string get_name() const
static bool check(const std::string &file_name, bool throw_exception)
string_ref get_name() const
::tinyxml2::XMLElement element
::tinyxml2::XMLDocument document
const std::string & string_ref
std::string get_value() const
string_ref get_value() const
tinyxml_svd_reader(const std::string &filename, bool throw_error=false)
bool is_attribute() const
This class reperesents SVD(xml) element / attribute.
sub_reader(const element *e)
bool is_attribute() const
::tinyxml2::XMLAttribute attribute
static xml_parse_exception make(const std::string &file, size_t file_line=UNKNOWN_FILE_LINE)
static void trim(std::string &str)
remove white spaces