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10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef toolx_raxml
  5 #define toolx_raxml
  6 
  7 #include <tools/xml/aidas>
  8 
  9 #include "xml/loader"
 10 
 11 namespace toolx {
 12 
 13 class raxml : public tools::xml::aidas, public xml::loader {
 14   typedef tools::xml::aidas parent_aidas;
 15   typedef xml::loader parent;
 16 public:
 17   raxml(tools::xml::factory& a_fac,std::ostream& a_out,bool a_verbose = false)
 18   :parent_aidas()
 19   ,parent(a_fac,a_out,a_verbose)
 20   ,m_read_tag(0)
 21   {
 22     set_default_tags(parent::m_tags);
 23   }
 24   virtual ~raxml() {}
 25 public:
 26   void set_read_tag(void* a_tag) {m_read_tag = a_tag;}
 27 protected:
 28   raxml(const raxml& a_from)
 29   :parent_aidas(a_from)
 30   ,parent(a_from)
 31   {}
 32   raxml& operator=(const raxml& a_from){
 33     parent_aidas::operator=(a_from);
 34     parent::operator=(a_from);
 35     return *this;
 36   }
 37 public:
 38   bool load_file(const std::string& a_file,bool a_compressed){
 39     m_objects.clear();
 40     if(!parent::load_file(a_file,a_compressed)) return false;
 41     tools::xml::tree* top = top_item();
 42     if(!top) return false;
 43     const std::string& tag_name = top->tag_name();
 44     if(tag_name!=s_aida()) return false;
 45 
 46    {tools::xml::looper _for(*top);
 47     while(tools::xml::tree* _tree = _for.next_tree()) {
 48 
 49       const std::string& _tag_name = _tree->tag_name();
 50       reader rder = find_reader(_tag_name);
 51       if(!rder) {
 52         m_out << "toolx::raxml::load_file :"
 53               << " reader not found for " << tools::sout(_tag_name)
 54               << std::endl;
 55         //m_objects.clear(); //keep already loaded objects.
 56         return false;
 57       } else {
 58         tools::raxml_out ro = rder(*_tree,m_out,m_verbose,m_read_tag);
 59         if(ro.object()) m_objects.push_back(ro);
 60       }
 61 
 62     }}
 63 
 64     return true;
 65   }
 66 protected:
 67   void* m_read_tag;
 68 };
 69 
 70 }
 71 
 72 #endif