Skip to content

feat: Add wrapped_facade_headers library for resolving IWYU violations; Add header wrappers for sys/types.h; Resolve off_t IWYU violations. #52

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 3 commits into from
Apr 7, 2025
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
1 change: 1 addition & 0 deletions src/ystdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(containers)
add_subdirectory(error_handling)
add_subdirectory(io_interface)
add_subdirectory(wrapped_facade_headers)
2 changes: 2 additions & 0 deletions src/ystdlib/io_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ cpp_library(
WriterInterface.hpp
PRIVATE_SOURCES
ReaderInterface.cpp
PUBLIC_LINK_LIBRARIES
ystdlib::wrapped_facade_headers
TESTS_SOURCES
test/test_ReaderInterface.cpp
test/test_WriterInterface.cpp
Expand Down
8 changes: 2 additions & 6 deletions src/ystdlib/io_interface/ReaderInterface.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#ifndef YSTDLIB_IO_INTERFACE_READERINTERFACE_HPP
#define YSTDLIB_IO_INTERFACE_READERINTERFACE_HPP

// TODO: https://github.com/y-scope/ystdlib-cpp/issues/50
// NOLINTNEXTLINE(misc-include-cleaner)
#include <sys/types.h>

#include <cstddef>
#include <string>

#include <ystdlib/wrapped_facade_headers/sys/types.h>

#include "ErrorCode.hpp"

namespace ystdlib::io_interface {
Expand Down Expand Up @@ -77,8 +75,6 @@ class ReaderInterface {
* Seeks from the current position to the next position by the given offset amount.
* @param offset
*/
// TODO: https://github.com/y-scope/ystdlib-cpp/issues/50
// NOLINTNEXTLINE(misc-include-cleaner)
[[nodiscard]] virtual auto seek_from_current(off_t offset) -> ErrorCode = 0;

/**
Expand Down
8 changes: 2 additions & 6 deletions src/ystdlib/io_interface/WriterInterface.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#ifndef YSTDLIB_IO_INTERFACE_WRITERINTERFACE_HPP
#define YSTDLIB_IO_INTERFACE_WRITERINTERFACE_HPP

// TODO: https://github.com/y-scope/ystdlib-cpp/issues/50
// NOLINTNEXTLINE(misc-include-cleaner)
#include <sys/types.h>

#include <cstddef>
#include <string>

#include <ystdlib/wrapped_facade_headers/sys/types.h>

#include "ErrorCode.hpp"

namespace ystdlib::io_interface {
Expand Down Expand Up @@ -71,8 +69,6 @@ class WriterInterface {
* Seeks from the current position to the next position by the given offset amount.
* @param offset
*/
// TODO: https://github.com/y-scope/ystdlib-cpp/issues/50
// NOLINTNEXTLINE(misc-include-cleaner)
[[nodiscard]] virtual auto seek_from_current(off_t offset) -> ErrorCode = 0;

/**
Expand Down
8 changes: 8 additions & 0 deletions src/ystdlib/wrapped_facade_headers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cpp_library(
NAME wrapped_facade_headers
NAMESPACE ystdlib
PUBLIC_HEADERS
sys/types.h
TESTS_SOURCES
test/test_off_t.cpp
)
9 changes: 9 additions & 0 deletions src/ystdlib/wrapped_facade_headers/sys/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// clang-format off
// IWYU pragma: begin_exports
#include <sys/types.h>

#if defined(__APPLE__)
#include <sys/_types/_off_t.h>
#endif
// IWYU pragma: end_exports
// clang-format on
10 changes: 10 additions & 0 deletions src/ystdlib/wrapped_facade_headers/test/test_off_t.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <ystdlib/wrapped_facade_headers/sys/types.h>

#include <catch2/catch_test_macros.hpp>

namespace ystdlib::wrapped_facade_headers::test {
TEST_CASE("test_off_t", "[wrapped_facade_headers][off_t]") {
off_t const i{0};
REQUIRE((0 == i));
}
} // namespace ystdlib::wrapped_facade_headers::test
1 change: 1 addition & 0 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ vars:
- "all"
- "containers"
- "error_handling"
- "wrapped_facade_headers"

tasks:
clean:
Expand Down