mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 08:30:41 +00:00
Use fmt instead of boost.
This commit is contained in:
parent
eebb545b40
commit
6ae1d6885f
@ -7,7 +7,7 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <fmt/format.h>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
@ -260,8 +260,7 @@ void ParamPackage::Set(const std::string& key, std::string value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, std::vector<std::string> value) {
|
void ParamPackage::Set(const std::string& key, std::vector<std::string> value) {
|
||||||
data.insert_or_assign(key,
|
data.insert_or_assign(key, fmt::format("[{}]", fmt::join(value, std::string{LIST_SEPARATOR})));
|
||||||
"[" + boost::algorithm::join(value, std::string{LIST_SEPARATOR}) + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, int value) {
|
void ParamPackage::Set(const std::string& key, int value) {
|
||||||
@ -269,11 +268,7 @@ void ParamPackage::Set(const std::string& key, int value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, std::vector<int> value) {
|
void ParamPackage::Set(const std::string& key, std::vector<int> value) {
|
||||||
std::vector<std::string> vec{};
|
data.insert_or_assign(key, fmt::format("[{}]", fmt::join(value, std::string{LIST_SEPARATOR})));
|
||||||
std::transform(value.begin(), value.end(), std::back_inserter(vec),
|
|
||||||
[](float a) -> std::string const { return std::to_string(a); });
|
|
||||||
data.insert_or_assign(key,
|
|
||||||
"[" + boost::algorithm::join(vec, std::string{LIST_SEPARATOR}) + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, float value) {
|
void ParamPackage::Set(const std::string& key, float value) {
|
||||||
@ -281,11 +276,7 @@ void ParamPackage::Set(const std::string& key, float value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, std::vector<float> value) {
|
void ParamPackage::Set(const std::string& key, std::vector<float> value) {
|
||||||
std::vector<std::string> vec{};
|
data.insert_or_assign(key, fmt::format("[{}]", fmt::join(value, std::string{LIST_SEPARATOR})));
|
||||||
std::transform(value.begin(), value.end(), std::back_inserter(vec),
|
|
||||||
[](float a) -> std::string { return std::to_string(a); });
|
|
||||||
data.insert_or_assign(key,
|
|
||||||
"[" + boost::algorithm::join(vec, std::string{LIST_SEPARATOR}) + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, ParamPackage value) {
|
void ParamPackage::Set(const std::string& key, ParamPackage value) {
|
||||||
@ -293,15 +284,15 @@ void ParamPackage::Set(const std::string& key, ParamPackage value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, std::vector<ParamPackage> value) {
|
void ParamPackage::Set(const std::string& key, std::vector<ParamPackage> value) {
|
||||||
std::vector<std::string> vec{};
|
data.insert_or_assign(key, fmt::format("[{}]", fmt::join(value, std::string{LIST_SEPARATOR})));
|
||||||
std::transform(value.begin(), value.end(), std::back_inserter(vec),
|
|
||||||
[](ParamPackage& a) -> std::string { return a.Serialize(); });
|
|
||||||
data.insert_or_assign(key,
|
|
||||||
"[" + boost::algorithm::join(vec, std::string{LIST_SEPARATOR}) + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other methods
|
// Other methods
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const ParamPackage& p) {
|
||||||
|
return os << p.Serialize();
|
||||||
|
}
|
||||||
|
|
||||||
bool ParamPackage::Has(const std::string& key) const {
|
bool ParamPackage::Has(const std::string& key) const {
|
||||||
return data.find(key) != data.end();
|
return data.find(key) != data.end();
|
||||||
}
|
}
|
||||||
@ -362,3 +353,15 @@ std::string ParamPackage::ReplacePlaceholders(const std::string& str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct fmt::formatter<Common::ParamPackage> {
|
||||||
|
constexpr auto parse(fmt::format_parse_context& ctx) {
|
||||||
|
return ctx.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FormatContext>
|
||||||
|
auto format(const Common::ParamPackage& p, FormatContext& ctx) {
|
||||||
|
return format_to(ctx.out(), "{}", p.Serialize());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -26,6 +26,7 @@ public:
|
|||||||
ParamPackage& operator=(ParamPackage&& other) = default;
|
ParamPackage& operator=(ParamPackage&& other) = default;
|
||||||
|
|
||||||
std::string Serialize() const;
|
std::string Serialize() const;
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const ParamPackage& p);
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
std::string Get(const std::string& key, const std::string& default_value) const;
|
std::string Get(const std::string& key, const std::string& default_value) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user