11 #ifndef __NODAMUSHI_SVD_BOOST_HPP__ 12 #define __NODAMUSHI_SVD_BOOST_HPP__ 16 # include <boost/property_tree/ptree.hpp> 17 # include <boost/property_tree/xml_parser.hpp> 18 # include <boost/algorithm/string/trim.hpp> 40 using ptree = boost::property_tree::ptree;
41 using itr = ptree::iterator;
46 tree(t.get_child(
"")),name(
"root"),
value(
""),
47 it(tree.begin()),end(tree.end()),attr(false),_ok(true)
53 tree(t.get_child(
"")),name(n),
value(v),
54 it(tree.begin()),end(tree.end()),attr(a),_ok(true)
56 boost::algorithm::trim(
value);
67 tree(),name(
""),
value(
""),
68 it(),end(it),attr(false),_ok(false)
72 boost::property_tree::read_xml(file_name,tree);
74 }
catch(boost::property_tree::xml_parser::xml_parser_error& e){
76 std::string m = e.message();
97 tree(),name(
""),
value(
""),
98 it(),end(it),attr(false),_ok(false)
101 boost::property_tree::xml_parser::read_xml(file,tree);
103 }
catch(boost::property_tree::xml_parser::xml_parser_error& e){
105 std::string m = e.message();
120 bool ok()const noexcept{
return _ok;}
137 auto& name = v.first;
138 auto& subtree = v.second;
139 auto&
value = v.second.data();
140 bool a= attr || name ==
"<xmlattr>";
144 operator bool()
const{
return it != end;}
149 while(it != end && it->first ==
"<xmlcomment>"){
163 #endif // __NODAMUSHI_SVD_BOOST_HPP__ boost_svd_reader()=default
static bool check(const std::string &file_name, bool throw_exception)
boost_svd_reader next_child() noexcept
svd_reader interface function
const std::string & string_ref
boost_svd_reader(ptree &t, string_ref n, string_ref v, bool a)
SVD reader with Boost property tree.
string_ref get_value() const noexcept
svd_reader interface function
boost_svd_reader(ptree &t)
string_ref get_name() const noexcept
svd_reader interface function
boost_svd_reader(const std::string &file_name, bool throw_error=false)
constructor with file name
This class reperesents SVD(xml) element / attribute.
boost_svd_reader(std::istream &file, bool throw_error=false)
constructor with std::istream
boost::property_tree::ptree ptree
bool is_attribute() const noexcept
svd_reader interface function
bool ok() const noexcept
file open / xml parse status