14 #ifndef __INLUCDED__SCOPIRA_TOOL_XML_H_ 15 #define __INLUCDED__SCOPIRA_TOOL_XML_H_ 17 #include <libxml/parser.h> 21 #include <scopira/tool/object.h> 22 #include <scopira/tool/export.h> 67 xmlDocPtr
get_ptr(
void)
const {
return dm_doc; }
73 bool is_null(
void)
const {
return dm_doc == 0; }
78 bool is_valid(
void)
const {
return dm_doc != 0; }
84 const char *
get_c_name(
void)
const {
return dm_doc->name; }
90 {
return std::string(reinterpret_cast<const char*>(dm_doc->name)); }
96 SCOPIRA_EXPORT
void clear(
void);
102 SCOPIRA_EXPORT
void init(
const std::string &rootnodename);
109 SCOPIRA_EXPORT
void add_pi(
const std::string &name,
const std::string &content =
"");
119 SCOPIRA_EXPORT
void load_ptr(xmlDocPtr newdoc);
128 SCOPIRA_EXPORT
bool load_file(
const std::string &filename);
136 SCOPIRA_EXPORT
bool load_string(
const std::string &data);
144 SCOPIRA_EXPORT
bool load_c_str(
const char *str);
166 SCOPIRA_EXPORT
bool save_file(
const std::string &filename,
bool compress =
false)
const;
174 SCOPIRA_EXPORT
bool save_string(std::string &out)
const;
200 element_c = XML_ELEMENT_NODE,
202 text_c = XML_TEXT_NODE,
218 explicit xml_node(xmlNodePtr ptr) : dm_node(ptr) { }
221 xmlNodePtr
get_ptr(
void)
const {
return dm_node; }
234 {
return reinterpret_cast<const char*
>(dm_node->name); }
240 {
return std::string(reinterpret_cast<const char*>(dm_node->name)); }
249 {
return reinterpret_cast<const char *
>(dm_node->content); }
255 bool is_null(
void)
const {
return dm_node == 0; }
266 void next(
void) { dm_node = dm_node->next; }
272 SCOPIRA_EXPORT
void next_type(
int typ);
278 SCOPIRA_EXPORT
void next_name(
const std::string &name);
284 SCOPIRA_EXPORT
int count_children(
const std::string &name)
const;
292 {
return xml_node(dm_node->children); }
298 SCOPIRA_EXPORT
xml_node get_first_child_type(
int typ)
const;
304 SCOPIRA_EXPORT
xml_node get_first_child_name(
const std::string &name)
const;
310 SCOPIRA_EXPORT
xml_attrib get_first_attrib(
void)
const;
319 SCOPIRA_EXPORT
const char * get_attrib_c_text(
const std::string &aname)
const;
328 SCOPIRA_EXPORT
const char * get_child_c_text(
const std::string &nname)
const;
334 SCOPIRA_EXPORT
bool has_attrib(
const std::string &aname)
const;
340 SCOPIRA_EXPORT
xml_node add_child(
const std::string &name);
346 SCOPIRA_EXPORT
xml_node add_comment(
const std::string &comment_contents);
353 SCOPIRA_EXPORT
void clear_this(
void);
358 SCOPIRA_EXPORT
void add_attrib(
const std::string &key,
const std::string &val);
363 SCOPIRA_EXPORT
xml_node add_content_child(
const std::string &content);
369 SCOPIRA_EXPORT
void clear_content_children(
void);
379 SCOPIRA_EXPORT
const char * get_text_c_content(
void)
const;
393 SCOPIRA_EXPORT
const char * get_leaf_text_content(
const std::string &pathnodespec)
const;
402 SCOPIRA_EXPORT
void load_string_attrib(
const std::string &name, std::string &outval);
409 for (
xml_node sub = get_first_child_name(elementname);
410 sub.
is_valid(); sub.next_name(elementname), ++iter)
411 (*iter).load_xml(sub);
419 const std::string &attribname, I iter)
const {
420 for (
xml_node sub = get_first_child_name(elementname);
421 sub.
is_valid(); sub.next_name(elementname), ++iter)
422 sub.load_string_attrib(attribname, *iter);
430 for (
xml_node sub = get_first_child_name(elementname);
431 sub.
is_valid(); sub.next_name(elementname), ++iter)
432 *iter = sub.get_text_c_content();
459 xmlAttrPtr
get_ptr(
void)
const {
return dm_attr; }
466 {
return reinterpret_cast<const char*
>(dm_attr->name); }
472 {
return std::string(reinterpret_cast<const char*>(dm_attr->name)); }
478 bool is_null(
void)
const {
return dm_attr == 0; }
489 void next(
void) { dm_attr = dm_attr->next; }
496 SCOPIRA_EXPORT
const char * get_text_c_content(
void)
const;
Definition: archiveflow.h:20