#pragma once

#include "nlohmann/json.hpp"

#include "GeneralUtils.h"

namespace nsMMF
{
    // !!! Do Not change the order to support MMF use case
    using InputStatus = struct _InputStatus {
        char PtName[80]{};
        bool On{ false };
        // Padding
        bool Padding1{ false };
        bool Padding2{ false };
        bool Padding3{ false };
        bool Padding4{ false };
        bool Padding5{ false };
        bool Padding6{ false };
        bool Padding7{ false };

        // Assignment operator overload
        _InputStatus& operator=(const _InputStatus& rhs)
        {
            //
            strcpy_s(PtName, rhs.PtName);

            On = rhs.On;

            return *this;
        }
    };
}

namespace nsMMF
{
    using namespace nlohmann;
    using namespace nsUtils;

    void from_json(const json& j, InputStatus& x);
    void to_json(json& j, const InputStatus& x);

    inline void from_json(const json& j, InputStatus& x)
    {
        std::string name = j.at("PtName").get<std::string>();
        strcpy_s(x.PtName, name.c_str());

        getValue(j, "On", x.On);
    }

    inline void to_json(json& j, const InputStatus& x)
    {
        j = nlohmann::json{
        { "PtName", x.PtName },
        { "On", x.On }
        };
    }

}