fix build: Don't use libfmt or ranges in win cpp

I can't deal with this anymore. My build is suddenly broken on Windows
(for spark_crypto.prod branch). I assume they updated the compiler
in a way that isn't backwards compatible. Thanks Windows.
This commit is contained in:
John Colvin committed 2023-07-05 11:58:14 -04:00
1 parent 15b1d55ef1
commit 3c97f2552b
3 files changed
+30 -42

No files matched your search

+8 -6
View File
@@ -1,15 +1,17 @@
#include "QueryParams.h"
#include <fmt/format.h>
#include <range/v3/view.hpp>
namespace bts::io {
std::string QueryParams::to_string() const {
std::string rv;
auto query_param_strs = ranges::transform_view(
*this, [](const auto &qp) { return qp.first + "=" + qp.second; });
rv.append(fmt::format(
"{}", fmt::join(query_param_strs.begin(), query_param_strs.end(), "&")));
auto it = begin();
if (it == end()) {
return "";
}
rv.append(it->first + "=" + it->second);
while (++it != end()) {
rv.append("&" + it->first + "=" + it->second);
}
return rv;
}
+2 -12
View File
@@ -1,15 +1,11 @@
#include "URL.h"
#include "lib/api/io/URL.pb.h"
#include <fmt/format.h>
#include <iostream>
#include <range/v3/view.hpp>
#include <range/v3/view/transform.hpp>
#include <string>
namespace bts::io {
// URL:: URL(const api::io::URL &url) : protocol_(url.protocol()),
// host_(url.host()), port_(url.port()), path_(url.path()) {}
URL::URL(const bts::api::io::URL &url)
: protocol_(url.protocol()), host_(url.host()), port_(url.port()),
path_(url.path()) {
@@ -76,13 +72,7 @@ std::string URL::to_string() const {
}
if (!query_params_.empty()) {
rv.append("?");
auto query_param_strs =
ranges::transform_view(query_params_, [](const auto &qp) {
return qp.first + "=" + qp.second;
});
rv.append(fmt::format(
"{}",
fmt::join(query_param_strs.begin(), query_param_strs.end(), "&")));
rv.append(query_params_.to_string());
}
return rv;
}
+20 -24
View File
@@ -1,39 +1,35 @@
#include "HTTPHeaders.h"
#include "lib/utils/StringSplitter.h"
#include <fmt/format.h>
#include <range/v3/view.hpp>
#include <string>
#include <unordered_map>
#include <vector>
namespace bts::io::http {
HTTPHeaders::HTTPHeaders(const std::string &str) {
auto item_strs = utils::StringSplitter::split(str, "\n");
auto items = ranges::transform_view(
item_strs,
[](const std::string &item_str) -> std::pair<std::string, std::string> {
auto kv = utils::StringSplitter::split(item_str, ":");
if (kv.empty()) {
return std::make_pair("", "");
}
if (kv.size() == 1) {
return std::make_pair(kv[0], std::string(""));
}
return std::make_pair(kv[0], kv[1]);
});
for (auto p : items) {
try_emplace(p.first, p.second);
for (const auto &item_str : item_strs) {
auto kv = utils::StringSplitter::split(item_str, ":");
if (kv.empty()) {
try_emplace("", "");
continue;
}
if (kv.size() == 1) {
try_emplace(kv[0], "");
continue;
}
try_emplace(kv[0], kv[1]);
}
}
std::string HTTPHeaders::to_string() const {
std::string rv;
auto query_param_strs = ranges::transform_view(
*this, [](const auto &qp) { return qp.first + ": " + qp.second; });
rv.append(fmt::format(
"{}",
fmt::join(query_param_strs.begin(), query_param_strs.end(), "\n")));
auto it = begin();
if (it == end()) {
return "";
}
std::string rv{it->first + ": " + it->second};
while (++it != end()) {
rv.append("\n" + it->first + ": " + it->second);
}
return rv;
}