55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <map>
|
|
#include <sp/common/Templates.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace sp {
|
|
|
|
template <typename T, std::enable_if_t<details::is_general_t<T>::value, bool> = true>
|
|
inline std::string PrintData(const T& a_Data);
|
|
|
|
template <typename T, std::enable_if_t<details::is_primitive<T>::value, bool> = true>
|
|
inline std::string PrintData(T a_Data) {
|
|
return std::to_string(a_Data);
|
|
}
|
|
|
|
template <>
|
|
inline std::string PrintData(const std::string& a_Data) {
|
|
return "\"" + a_Data + "\"";
|
|
}
|
|
|
|
template <typename K, typename V>
|
|
std::string PrintData(const std::pair<K, V>& a_Data);
|
|
|
|
template <typename K, typename V>
|
|
std::string PrintData(const std::map<K, V>& a_Data);
|
|
|
|
template <typename T>
|
|
std::string PrintData(const std::vector<T>& a_Data);
|
|
|
|
template <typename K, typename V>
|
|
std::string PrintData(const std::pair<K, V>& a_Data) {
|
|
return "{" + PrintData(a_Data.first) + " => " + PrintData(a_Data.second) + "}";
|
|
}
|
|
|
|
template <typename K, typename V>
|
|
std::string PrintData(const std::map<K, V>& a_Data) {
|
|
std::string result = "{";
|
|
for (const auto& pair : a_Data) {
|
|
result += PrintData(pair) + ", ";
|
|
}
|
|
return result.substr(0, result.size() - 2) + "}";
|
|
}
|
|
|
|
template <typename T>
|
|
std::string PrintData(const std::vector<T>& a_Data) {
|
|
std::string result = "{";
|
|
for (const T& value : a_Data) {
|
|
result += PrintData(value) + ", ";
|
|
}
|
|
return result.substr(0, result.size() - 2) + "}";
|
|
}
|
|
|
|
} // namespace sp
|