//
// Created by Ht on 2022/12/16.
//

#ifndef INC_1_LIBDEVCPP_APPARAMUTIL_H
#define INC_1_LIBDEVCPP_APPARAMUTIL_H

#include "qlibc/qlibc.h"

namespace jedge {

    class JE_API APParamUtil {
    public:
        static qlibc::QData createStringParam(const std::string& paramKey) {
            return qlibc::QData().putString("key", paramKey).putString("type", "string");
        }

        static qlibc::QData createIntParam(const std::string& paramKey, int min, int max) {
            return qlibc::QData().putString("key", paramKey).
                            putString("type", "int").
                            setInt("rangeStart", min).
                            setInt("rangeEnd", max);
        }

        static qlibc::QData createBoolParam(const std::string& paramKey) {
            return qlibc::QData().putString("key", paramKey).putString("type", "bool");
        }

        static qlibc::QData createEnumParam(const std::string& paramKey, const std::string& vals) {
            qlibc::QData paramDef;
            paramDef.putString("key", paramKey).putString("type", "enum");
            QStringList valList;
            StringUtils::QuoteSplit(vals, ",", '\'', valList);
            Json::Value arr; StringUtils::listToJsonArray(valList, arr);
            paramDef.put("values", arr);
            return paramDef;
        }
    };
}

#endif //INC_1_LIBDEVCPP_APPARAMUTIL_H
