#ifndef XMLCONFIG_H
#define XMLCONFIG_H

#include "libConfig_global.h"
#include "libConfig.h"

#include <QDomDocument>

namespace Config {

    class LIBCONFIG_EXPORT XMLConfig
            : public Config::Configration
    {
    public:
        XMLConfig(QObject *parent=nullptr);
        virtual ~XMLConfig() = default;

        // Configration interface
    public:
        virtual void loadFile(const QString &path) override;
        virtual QDir currentDir() const override;
        virtual void save() const override;
        virtual void deleteX(const QList<QString> &path) override;
        virtual void setConfig(const QList<QString> &path, const QString &value) override;
        virtual QString getConfig(const QList<QString> &path) const override;
        virtual void setList(const QList<QString> &path, const QList<QString> &list) override;
        virtual QList<QString> getList(const QList<QString> &path) const override;
        virtual void setMap(const QList<QString> &path, const QHash<QString, QString> &map) override;
        virtual QHash<QString, QString> getMap(const QList<QString> &path) const override;

    private:
        QDomDocument doc_ins;
        QString file_path;

        QDomElement local_exists_elm(const QDomElement &elm_base, const QList<QString> &path, int level = 0) const;
        QDomElement rebuild_exists_elms(QDomElement &elm_base, const QList<QString> &path, int level = 0);
    };

}
#endif // XMLCONFIG_H
