#pragma once

#include "XmlAttribute.h"

#include <memory>
#include <vector>
#include <string>

class XmlElement
{
public:
    XmlElement(const std::string& tagName);
    virtual ~XmlElement() = default;

    static std::unique_ptr<XmlElement> Create(const std::string& tagName);

    void AddAttribute(XmlAttributeUPtr attribute);
    void AddChild(std::unique_ptr<XmlElement> child);

    std::string GetTagName() const;
    std::string GetText() const;
    XmlAttribute* GetAttribute(const std::string& attribute) const;
    XmlAttribute* GetAttribute(std::size_t index) const;
    std::size_t GetNumAttributes() const;

    std::size_t GetNumChildren() const;
    XmlElement* GetChild(std::size_t index) const;

    void SetText(const std::string& text);
    void SetTagName(const std::string& tagName);

protected:
    std::string mTagName;
    std::vector<XmlAttributeUPtr> mAttributes;
    std::vector<std::unique_ptr<XmlElement> > mChildren;
    std::string mText;
};

using XmlElementPtr = std::shared_ptr<XmlElement>;
using XmlElementUPtr = std::unique_ptr<XmlElement>;
