Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 3 4 #ifndef toolx_xml_style 5 #define toolx_xml_style 6 7 #include <tools/xml/styles> 8 9 #include "loader" 10 11 namespace toolx { 12 namespace xml { 13 14 inline bool load_style_file(std::ostream&,const std::string& a_file,tools::xml::styles& a_styles) { 15 tools::xml::default_factory factory; 16 toolx::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; 23 tools::xml::tree* top = ml.top_item(); 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) { 29 tools::xml::default_factory factory; 30 toolx::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; 37 tools::xml::tree* top = ml.top_item(); 38 if(!top) return true; 39 return scan_style_tree(a_styles,*top); 40 } 41 42 }} 43 44 #endif