Skip to content

Use Ostream in the Errors Formatter #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions components/format/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
cpmaddpackage("gh:fmtlib/fmt#10.2.0")

add_library(errors_format src/format.cpp)
add_library(errors_format INTERFACE)
target_sources(
errors_format PUBLIC
FILE_SET HEADERS
BASE_DIRS include
FILES include/errors/format.hpp
)
target_link_libraries(errors_format PUBLIC errors fmt)
target_link_libraries(errors_format INTERFACE errors fmt)

if(NOT_SUBPROJECT)
if (BUILD_TESTING)
# Append the main library properties instead of linking the library.
get_target_property(errors_format_SOURCES errors_format SOURCES)
get_target_property(errors_format_HEADER_DIRS errors_format HEADER_DIRS)
get_target_property(errors_format_LIBRARIES errors_format LINK_LIBRARIES)
get_target_property(errors_format_LIBRARIES errors_format INTERFACE_LINK_LIBRARIES)

# Build tests for the main library
add_executable(errors_format_test test/format_test.cpp ${errors_format_SOURCES})
add_executable(errors_format_test test/format_test.cpp)
target_include_directories(errors_format_test PRIVATE ${errors_format_HEADER_DIRS})
target_link_libraries(errors_format_test PRIVATE Catch2::Catch2WithMain ${errors_format_LIBRARIES})

Expand Down
12 changes: 2 additions & 10 deletions components/format/include/errors/format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <errors/error.hpp>
#include <fmt/core.h>
#include <fmt/ostream.h>

namespace errors {

Expand All @@ -17,15 +18,6 @@ Error format(fmt::format_string<T...> fmt, T&&... args);

} // namespace errors

namespace fmt {

template <>
struct formatter<errors::Error> {
format_parse_context::iterator parse(format_parse_context& ctx) const;
format_context::iterator format(const errors::Error& err,
format_context& ctx) const;
};

} // namespace fmt
template <> struct fmt::formatter<errors::Error> : ostream_formatter {};

#include "format.ipp"
15 changes: 0 additions & 15 deletions components/format/src/format.cpp

This file was deleted.