#define MiX_COMMENT_CPP_

#include "Comment.h"
#include "Element.h"

namespace MiX{
  //dmy_itはcreateで第三引数を省略するためのトリック
  template <class charT,class char_traits,class xml_traits>
  const typename NodeList<charT,char_traits,xml_traits>::iterator Comment<charT,char_traits,xml_traits>::dmy_it=nodelist_type::iterator();
  
  template <class charT,class char_traits,class xml_traits>
  XMLString<charT,char_traits,xml_traits> Comment<charT,char_traits,xml_traits>::toString(bool is_indent,int indent_off)const{
    string_type s;
    if(is_indent) insertIndent(indent_off,s,xml_traits::tab());
    s += xml_traits::lt(); s += xml_traits::exclamation();
    s += xml_traits::hyphen(); s += xml_traits::hyphen(); 
    s += getValue(); s += xml_traits::hyphen(); 
    s += xml_traits::hyphen(); s += xml_traits::gt();
    if(is_indent) s+=xml_traits::crlf();
    return s;
  }
 
  template <class charT,class char_traits,class xml_traits>
  Comment<charT,char_traits,xml_traits>& Comment<charT,char_traits,xml_traits>::create(const string_type& str,element_type& parent,const typename nodelist_type::iterator& it){
    comment_type* newcom = new comment_type(str);
    if(&it==&dmy_it) parent.getChildren().insert(parent.getChildren().end(),newcom);
    else parent.getChildren().insert(it,newcom);
    newcom->setParent(parent);
    return *newcom;
  }
}
