#pragma once /** Sysvars library * Copyright (c) 2018-2024 Pavel Brychta, pablo@xpablo.cz * * Key-value store/load library with JSON file using internal filesystem **/ #include enum { SV_OK = 0, SV_UNSPECIFIED_ERROR = -1, SV_FILE_NOT_FOUND = -2, SV_DESERIALIZE_ERROR = -3, SV_WRONG_DATA_TYPE = -4, SV_FILE_WRITE_ERROR = -5, SV_KEY_NOT_FOUND = -6, }; /** * @brief Get value * * @param[in] name Name of the key * @param deflt Default value * * @tparam T result type * * @return Value for the key given */ template T svGetV(const String & name, const T deflt = {}); /** * @brief Get value * * @param[in] name Name of the key * @param[in] fname Used JSON file name * @param deflt Default value * * @tparam T Result type * * @return Value for the key given */ template T svGetVFile(const String & name, const String & fname, const T deflt = {}); /** * @brief Store value for the key * * @param[in] name Key name * @param[in] value New value * * @tparam T Type of the value * * @return Result (SV_...) */ template int svSetV(const String & name, T value); /** * @brief Store value for the key * * @param[in] name Key name * @param[in] value New value * @param[in] fname JSON file name * * @tparam T Type of the value * * @return Result (SV_...) */ template int svSetVFile(const String & name, T value, const String & fname);