Files
geant4/source/analysis/g4tools/include/tools/xml/xml_style
T
2016-12-09 12:35:28 +01:00

45 lines
1.2 KiB
Plaintext

// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef tools_xml_style
#define tools_xml_style
#include <tools/xml/styles>
#include "loader"
namespace tools {
namespace xml {
inline bool load_style_file(std::ostream&,const std::string& a_file,tools::xml::styles& a_styles) {
tools::xml::default_factory factory;
tools::xml::loader ml(factory,a_styles.out(),false);
std::vector<std::string> tags;
tags.push_back("styles");
tags.push_back("style");
tags.push_back("plotter_style");
ml.set_tags(tags);
if(!ml.load_file(a_file,false)) return false;
tools::xml::tree* top = ml.top_item();
if(!top) return true; //File could be empty.
return scan_style_tree(a_styles,*top);
}
inline bool load_style_string(tools::xml::styles& a_styles,const std::string& a_string) {
tools::xml::default_factory factory;
tools::xml::loader ml(factory,a_styles.out(),false);
std::vector<std::string> tags;
tags.push_back("styles");
tags.push_back("style");
tags.push_back("plotter_style");
ml.set_tags(tags);
if(!ml.load_string(a_string)) return false;
tools::xml::tree* top = ml.top_item();
if(!top) return true;
return scan_style_tree(a_styles,*top);
}
}}
#endif