/* libxml++
 * Copyright (C) 2000  Ari Johnson
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

/* Modified by Motama GmbH, Copyright (C) 2006-2007 Motama GmbH */


#ifndef NMM_XML_NODE_HPP
#define NMM_XML_NODE_HPP NMM_XML_NODE_HPP

#include "nmm/nmm_prefix.hpp"

#include "XMLProperty.hpp"
#include "XMLNodeForward.hpp"

#include "visibility.hpp"

namespace NMM {
  
  class DLLEXPORT XMLNode {
  private:
    bool _initialized;
    std::string _name;
    std::string _content;
    XMLNodeList _children;
    XMLPropertyList _proplist;
    XMLPropertyHash _prophash;
  
  public:
    /** constructor.
     */ 
    XMLNode(const std::string &);
    XMLNode(const std::string &, const std::string &);

    /**
     */
    XMLNode(const XMLNode&);

    ~XMLNode();

    inline bool  initialized(void)      const { return _initialized; };
    inline bool  is_content(void)       const { return !_content.empty(); };

    inline const std::string & name(void)    const { return _name; };
    inline const std::string & content(void) const { return _content; };

    const std::string & set_content(const std::string &);
    std::string getData();

    XMLNodeList children(const std::string & ) const;

    inline const XMLNodeList& children() const { return _children; }
    inline       XMLNodeList& children()       { return _children; }
    XMLNode *add_child(const std::string &);
    XMLNode *add_child(XMLNode *);
    XMLNode *add_child(const std::string &, int pos);
    XMLNode *add_content(const std::string & = std::string());
    void remove_child(XMLNode *);

    inline const XMLPropertyList & properties(void) const { return _proplist; };
    XMLProperty *property(const std::string &);
    const XMLProperty *property(const std::string &n) const
    { return ((XMLNode *) this)->property(n); };
    XMLProperty *add_property(const std::string &, const std::string & = std::string());
    void remove_property(const std::string &);

    const XMLNode& operator=(const XMLNode& );
    bool operator==(const XMLNode& );
    
  private:
    void erase();
  };
  
}

#include "nmm/nmm_suffix.hpp"

#endif
