1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

Fix fmt 10.0.0 related formatting errors.

Signed-off-by: Philipp Jungkamp <p.jungkamp@gmx.net>
This commit is contained in:
Philipp Jungkamp 2023-09-25 10:52:55 +02:00 committed by Steffen Vogel
parent fe0bed6f3c
commit 32239245e6
8 changed files with 57 additions and 18 deletions

View file

@ -1,5 +1,5 @@
## CMakeLists.txt
#
#
# Author: Steffen Vogel <post@steffenvogel.de>
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
# SPDX-License-Identifier: Apache-2.0
@ -42,13 +42,18 @@ endif()
find_package(OpenSSL 1.0.0 REQUIRED)
find_package(CURL 7.29 REQUIRED)
find_package(spdlog 1.6.0 REQUIRED)
find_package(fmt 5.3.0 REQUIRED)
find_package(fmt 6.0.0 REQUIRED)
find_package(Criterion)
pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson>=2.7)
pkg_check_modules(LIBCONFIG IMPORTED_TARGET libconfig>=1.4.9)
pkg_check_modules(UUID IMPORTED_TARGET REQUIRED uuid>=2.23)
if(fmt_VERSION VERSION_LESS "9.0.0")
message("Using legacy ostream formatting")
set(FMT_LEGACY_OSTREAM_FORMATTER 1)
endif()
add_subdirectory(lib)
if(CRITERION_FOUND AND TOPLEVEL_PROJECT)
add_subdirectory(tests)

View file

@ -47,3 +47,6 @@
#define LOG_HEIGHT 25
#cmakedefine LOG_COLOR_DISABLE
// Library Features
#cmakedefine FMT_LEGACY_OSTREAM_FORMATTER

View file

@ -48,21 +48,17 @@ public:
class JsonError : public std::runtime_error {
protected:
const json_t *setting;
json_error_t error;
public:
template <typename... Args>
JsonError(const json_t *s, const json_error_t &e,
const std::string &what = std::string(), Args &&...args)
: std::runtime_error(fmt::format(what, std::forward<Args>(args)...)),
setting(s), error(e) {}
virtual const char *what() const noexcept {
return fmt::format("{}: {} in {}:{}:{}", std::runtime_error::what(),
error.text, error.source, error.line, error.column)
.c_str();
}
: std::runtime_error(
fmt::format("{}: {} in {}:{}:{}",
fmt::format(what, std::forward<Args>(args)...),
error.text, error.source, error.line, error.column)),
error(e) {}
};
class ConfigError : public std::runtime_error {

View file

@ -7,6 +7,8 @@
#pragma once
#include <fmt/ostream.h>
#include <villas/config.hpp>
#include <villas/graph/vertex.hpp>
namespace villas {
@ -42,3 +44,9 @@ private:
} // namespace graph
} // namespace villas
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<villas::graph::Edge>
: public fmt::ostream_formatter {};
#endif

View file

@ -7,6 +7,11 @@
#pragma once
#include <list>
#include <sstream>
#include <fmt/ostream.h>
#include <villas/config.hpp>
namespace villas {
namespace graph {
@ -40,3 +45,9 @@ private:
} // namespace graph
} // namespace villas
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<villas::graph::Vertex>
: public fmt::ostream_formatter {};
#endif

View file

@ -11,7 +11,6 @@
#include <list>
#include <string>
#include <spdlog/fmt/ostr.h>
#include <spdlog/sinks/dist_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>

View file

@ -12,7 +12,8 @@
#include <stdexcept>
#include <string>
#include <unistd.h>
#include <fmt/ostream.h>
#include <villas/config.hpp>
#include <villas/graph/directed.hpp>
#include <villas/log.hpp>
@ -222,3 +223,15 @@ private:
};
} // namespace villas
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<villas::MemoryTranslation>
: public fmt::ostream_formatter {};
template <>
class fmt::formatter<villas::MemoryManager::Mapping>
: public fmt::ostream_formatter {};
template <>
class fmt::formatter<villas::MemoryManager::AddressSpaceId>
: public fmt::ostream_formatter {};
#endif

View file

@ -11,10 +11,10 @@
#include <iostream>
#include <jansson.h>
#include <list>
#include <spdlog/fmt/ostr.h>
#include <string>
#include <fmt/ostream.h>
#include <villas/common.hpp>
#include <villas/config.hpp>
#include <villas/log.hpp>
namespace villas {
@ -132,9 +132,7 @@ public:
return logger;
}
// Custom formatter for spdlog
template <typename OStream>
friend OStream &operator<<(OStream &os, const class Plugin &p) {
friend std::ostream &operator<<(std::ostream &os, const class Plugin &p) {
return os << p.getName();
}
};
@ -151,3 +149,9 @@ template <typename T> void Registry::dump() {
} // namespace plugin
} // namespace villas
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<villas::plugin::Plugin>
: public fmt::ostream_formatter {};
#endif