g4tools  5.4.0
xml_style
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_xml_style
5 #define tools_xml_style
6 
7 #include <tools/xml/styles>
8 
9 #include "loader"
10 
11 namespace tools {
12 namespace xml {
13 
14 inline bool load_style_file(std::ostream&,const std::string& a_file,tools::xml::styles& a_styles) {
16  tools::xml::loader ml(factory,a_styles.out(),false);
17  std::vector<std::string> tags;
18  tags.push_back("styles");
19  tags.push_back("style");
20  tags.push_back("plotter_style");
21  ml.set_tags(tags);
22  if(!ml.load_file(a_file,false)) return false;
24  if(!top) return true; //File could be empty.
25  return scan_style_tree(a_styles,*top);
26 }
27 
28 inline bool load_style_string(tools::xml::styles& a_styles,const std::string& a_string) {
30  tools::xml::loader ml(factory,a_styles.out(),false);
31  std::vector<std::string> tags;
32  tags.push_back("styles");
33  tags.push_back("style");
34  tags.push_back("plotter_style");
35  ml.set_tags(tags);
36  if(!ml.load_string(a_string)) return false;
38  if(!top) return true;
39  return scan_style_tree(a_styles,*top);
40 }
41 
42 }}
43 
44 #endif
tools::xml::load_style_file
bool load_style_file(std::ostream &, const std::string &a_file, tools::xml::styles &a_styles)
Definition: xml_style:14
styles
tools::xml::styles
Definition: styles:17
tools::xml::styles::out
std::ostream & out() const
Definition: styles:35
tools::xml::default_factory
Definition: tree:989
tools::xml::load_style_string
bool load_style_string(tools::xml::styles &a_styles, const std::string &a_string)
Definition: xml_style:28
tools::sg::top
@ top
Definition: enums:82
tools::xml::factory
Definition: tree:38
tools::xml::loader::load_file
bool load_file(const std::string &a_file, bool a_compressed)
Definition: loader:128
tools::xml::loader::set_tags
void set_tags(const std::vector< std::string > &a_tags)
Definition: loader:125
tools::xml::tree
Definition: tree:47
tools::xml::loader::load_string
bool load_string(const std::string &a_string)
Definition: loader:141
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::xml::loader::top_item
const tools::xml::tree * top_item() const
Definition: loader:165
tools::xml::scan_style_tree
bool scan_style_tree(styles &a_styles, const tree &a_tree)
Definition: styles:535
loader
tools::xml::loader
Definition: loader:42