Skip to content

Commit

Permalink
Bump spdlog version to v1.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Apr 30, 2024
1 parent b184a6d commit a74be9a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 49 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ else()
message(NOTICE "No data directory found. Set it with CCT_DATA_DIR or if you use Docker mount it at start of the container")
endif()

# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

# openssl for requests
find_package(OpenSSL REQUIRED)

Expand Down Expand Up @@ -139,8 +144,8 @@ find_package(spdlog CONFIG)
if(NOT spdlog_FOUND)
FetchContent_Declare(
spdlog
URL https://github.com/gabime/spdlog/archive/refs/tags/v1.13.0.tar.gz
URL_HASH SHA256=534f2ee1a4dcbeb22249856edfb2be76a1cf4f708a20b0ac2ed090ee24cfdbc9
URL https://github.com/gabime/spdlog/archive/refs/tags/v1.14.0.tar.gz
URL_HASH SHA256=429a6b73ade8285cb21f83bacf89e2821dd1720ea7faa3cb518ffe04b4e00efc
)

list(APPEND fetchContentPackagesToMakeAvailable spdlog)
Expand Down
2 changes: 2 additions & 0 deletions src/tech/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,6 @@ add_unit_test(
add_unit_test(
url-encode_test.cpp
test/url-encode_test.cpp
DEFINITIONS
CCT_DISABLE_SPDLOG
)
48 changes: 15 additions & 33 deletions src/tech/include/fbstring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <type_traits>

#include "cct_config.hpp"
#include "cct_format.hpp"
#include "cct_type_traits.hpp"
#include "unreachable.hpp"

Expand Down Expand Up @@ -2747,39 +2748,7 @@ operator<<(
typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>& os,
const basic_fbstring<E, T, A, S>& str) {
#ifdef _LIBCPP_VERSION
typedef std::basic_ostream<
typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>
_ostream_type;
typename _ostream_type::sentry _s(os);
if (_s) {
typedef std::ostreambuf_iterator<
typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>
_Ip;
size_t __len = str.size();
bool __left =
(os.flags() & _ostream_type::adjustfield) == _ostream_type::left;
if (__pad_and_output(
_Ip(os),
str.data(),
__left ? str.data() + __len : str.data(),
str.data() + __len,
os,
os.fill())
.failed()) {
os.setstate(_ostream_type::badbit | _ostream_type::failbit);
}
}
#elif defined(_MSC_VER)
typedef decltype(os.precision()) streamsize;
// MSVC doesn't define __ostream_insert
os.write(str.data(), static_cast<streamsize>(str.size()));
#else
std::__ostream_insert(os, str.data(), str.size());
#endif
return os;
return os << std::basic_string_view<E, T>(str);
}

template <typename E1, class T, class A, class S>
Expand Down Expand Up @@ -2921,6 +2890,19 @@ FOLLY_POP_WARNING
#undef FOLLY_SANITIZE_ADDRESS
#undef FBSTRING_DISABLE_SSO

#ifndef CCT_DISABLE_SPDLOG

template <class E, class T, class A, class S>
struct fmt::formatter<::folly::basic_fbstring<E, T, A, S>> : fmt::formatter<std::basic_string_view<E, T>> {
template <typename FormatContext>
auto format(const ::folly::basic_fbstring<E, T, A, S> &str, FormatContext &ctx) const -> decltype(ctx.out()) {
using SVType = std::basic_string_view<E, T>;
return fmt::formatter<SVType>::format(SVType(str), ctx);
}
};

#endif

namespace folly {
template <class T>
struct IsSomeString;
Expand Down
16 changes: 2 additions & 14 deletions src/tech/include/simpletable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include <type_traits>
#include <utility>
#include <variant>
#ifdef CCT_MSVC
#include <string>
#endif

#include "cct_smallvector.hpp"
#include "cct_string.hpp"
Expand All @@ -29,6 +26,7 @@ namespace cct {
/// before and after them.
/// Empty rows are legal and will force the print of a divider line.
/// See the unit test to have an overview of its usage and the look and feel of the print.
///
/// Example:
///
/// +---------------+----------+-----------------------+
Expand All @@ -51,28 +49,17 @@ namespace table {
/// Make sure that the lifetime of the data it points to extends the lifetime of this cell.
class CellLine {
public:
#ifdef CCT_MSVC
// folly::string does not support operator<< correctly with alignments with MSVC. Hence we use std::string
// in SimpleTable to guarantee correct alignment of formatted table. Referenced in this issue:
// https://github.com/facebook/folly/issues/1681
using string_type = std::string;
#else
using string_type = string;
#endif
using value_type = std::variant<std::string_view, string_type, int64_t, uint64_t, bool>;
using size_type = uint32_t;

explicit CellLine(std::string_view sv) : _data(sv) {}

explicit CellLine(const char *cstr) : _data(std::string_view(cstr)) {}

#ifdef CCT_MSVC
explicit CellLine(const string &v) : _data(string_type(v.data(), v.size())) {}
#else
explicit CellLine(const string_type &str) : _data(str) {}

explicit CellLine(string_type &&str) : _data(std::move(str)) {}
#endif

explicit CellLine(std::integral auto val) : _data(val) {}

Expand All @@ -92,6 +79,7 @@ class CellLine {
};

class Row;

class Cell {
public:
using value_type = CellLine;
Expand Down

0 comments on commit a74be9a

Please sign in to comment.