00001
00002
00003 #ifndef MiX_ELEMENT_H_
00004 #define MiX_ELEMENT_H_
00005
00006 #include "classes.h"
00007 #include "misc.h"
00008 #include "NodeContainer.h"
00009 #include "extern/noncopyable.hpp"
00010
00011 namespace MiX{
00012
00013 template <class charT,class char_traits,class xml_traits>
00014 class Element
00015 : boost::noncopyable,
00016 public NodeContainer<charT,char_traits,xml_traits>,
00017 public NamedNode<charT,char_traits,xml_traits>{
00018 public:
00019 MiX_Template_Typedef(charT,char_traits,xml_traits);
00020 typedef Element<charT,char_traits,xml_traits> this_type;
00021 typedef typename nodelist_type::iterator nodelist_iter;
00022 private:
00023 const static typename nodelist_type::iterator dmy_it;
00024 protected:
00034 Element(const string_type& name)
00035 : NodeContainer<charT,char_traits,xml_traits>(),
00036 NamedNode<charT,char_traits,xml_traits>(name){ };
00037 public:
00039 virtual ~Element()throw(){ };
00041 virtual NodeType getType()const{ return Node_Element; };
00047 static NodeType type(){ return Node_Element; };
00054 this_type& operator() (const string_type& name,int index=0){
00055 return getElement(name,index);
00056 };
00057 this_type& operator() (const string_type& name,const string_type& ns,int index=0){
00058 return getElement(name,ns,index);
00059 };
00066 attribute_type& operator[] (const string_type& name){
00067 return getAttribute(name);
00068 };
00069 attribute_type& operator[] (std::pair<string_type,string_type> p){
00070 return getAttribute(p.first,p.second);
00071 };
00077 virtual string_type toString(bool is_indent=false,int indent_off=0)const;
00078
00080 string_type getText()const;
00081
00083 void setText(const XMLString<charT,char_traits,xml_traits>& s);
00084
00085 string_type getFullName() const;
00092 node_type& clone(nodecontainer_type& parent,const nodelist_iter& it = dmy_it) const;
00100 static this_type& create(const string_type& name,this_type& parent,const typename nodelist_type::iterator& it = dmy_it)
00101 { return this_type::create(name,string_type(),parent,it); }
00110 static this_type& create(const string_type& name,const string_type& ns,this_type& parent,const typename nodelist_type::iterator& it = dmy_it);
00111
00112 friend class DOM_Parser<charT,char_traits,xml_traits>;
00113 friend class Document<charT,char_traits,xml_traits>;
00114 };
00115 }
00116
00117 #ifndef MiX_ELEMENT_CPP_
00118 #include "Element.cpp"
00119 #endif
00120
00121 #endif