mirror of https://github.com/gabime/spdlog.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
900 B
C++
44 lines
900 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <concepts>
|
|
|
|
namespace spdlog {
|
|
namespace details {
|
|
|
|
//template<typename T>
|
|
//concept composable = std::same_as<T, bool> || std::integral<T> || std::floating_point<T> || std::convertible_to<T, std::string_view>;
|
|
|
|
struct attr
|
|
{
|
|
std::string key;
|
|
std::string value;
|
|
|
|
public:
|
|
attr(std::initializer_list<std::string_view> l) {
|
|
if (l.size() != 2) return; // throw exception if not kv pair?
|
|
|
|
key = *l.begin();
|
|
value = *(l.begin()+1);
|
|
}
|
|
|
|
attr(std::string_view k, bool v)
|
|
: key{k}
|
|
, value{v ? "true" : "false"}
|
|
{}
|
|
|
|
attr(std::string_view k, std::string_view v)
|
|
: key{k}
|
|
, value{v}
|
|
{}
|
|
|
|
template <typename T>
|
|
attr(std::string_view k, T const &v)
|
|
: key{k}
|
|
, value{std::to_string(v)}
|
|
{}
|
|
};
|
|
|
|
} // namespace details
|
|
} // namespace spdlog
|