#ifndef MIGRAPHX_GUARD_RTGLIB_ENV_HPP
#define MIGRAPHX_GUARD_RTGLIB_ENV_HPP

#include <vector>
#include <string>
#include <migraphx/config.hpp>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {

// Declare a cached environment variable
#define MIGRAPHX_DECLARE_ENV_VAR(x)               \
    struct x                                      \
    {                                             \
        static const char* value() { return #x; } \
    }; // NOLINT

bool enabled(const char* name);
bool disabled(const char* name);
std::vector<std::string> env(const char* name);

int value_of(const char* name, int fallback = 0);

std::string string_value_of(const char* name, std::string fallback = "");

template <class T>
bool enabled(T)
{
    static const bool result = enabled(T::value());
    return result;
}

template <class T>
bool disabled(T)
{
    static const bool result = disabled(T::value());
    return result;
}

template <class T>
int value_of(T, int fallback = 0)
{
    static const int result = value_of(T::value(), fallback);
    return result;
}

template <class T>
std::string string_value_of(T, std::string fallback = "")
{
    static const std::string result = string_value_of(T::value(), fallback);
    return result;
}

} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx

#endif
