Skip to content

Commit 6b5a88c

Browse files
authored
feat: Add wrapped_facade_headers library for resolving IWYU violations; Add header wrappers for sys/types.h; Resolve off_t IWYU violations. (#52)
1 parent 3ac60d1 commit 6b5a88c

File tree

8 files changed

+35
-12
lines changed

8 files changed

+35
-12
lines changed

src/ystdlib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
add_subdirectory(containers)
22
add_subdirectory(error_handling)
33
add_subdirectory(io_interface)
4+
add_subdirectory(wrapped_facade_headers)

src/ystdlib/io_interface/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ cpp_library(
77
WriterInterface.hpp
88
PRIVATE_SOURCES
99
ReaderInterface.cpp
10+
PUBLIC_LINK_LIBRARIES
11+
ystdlib::wrapped_facade_headers
1012
TESTS_SOURCES
1113
test/test_ReaderInterface.cpp
1214
test/test_WriterInterface.cpp

src/ystdlib/io_interface/ReaderInterface.hpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#ifndef YSTDLIB_IO_INTERFACE_READERINTERFACE_HPP
22
#define YSTDLIB_IO_INTERFACE_READERINTERFACE_HPP
33

4-
// TODO: https://github.com/y-scope/ystdlib-cpp/issues/50
5-
// NOLINTNEXTLINE(misc-include-cleaner)
6-
#include <sys/types.h>
7-
84
#include <cstddef>
95
#include <string>
106

7+
#include <ystdlib/wrapped_facade_headers/sys/types.h>
8+
119
#include "ErrorCode.hpp"
1210

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

8480
/**

src/ystdlib/io_interface/WriterInterface.hpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#ifndef YSTDLIB_IO_INTERFACE_WRITERINTERFACE_HPP
22
#define YSTDLIB_IO_INTERFACE_WRITERINTERFACE_HPP
33

4-
// TODO: https://github.com/y-scope/ystdlib-cpp/issues/50
5-
// NOLINTNEXTLINE(misc-include-cleaner)
6-
#include <sys/types.h>
7-
84
#include <cstddef>
95
#include <string>
106

7+
#include <ystdlib/wrapped_facade_headers/sys/types.h>
8+
119
#include "ErrorCode.hpp"
1210

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

7874
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cpp_library(
2+
NAME wrapped_facade_headers
3+
NAMESPACE ystdlib
4+
PUBLIC_HEADERS
5+
sys/types.h
6+
TESTS_SOURCES
7+
test/test_off_t.cpp
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// clang-format off
2+
// IWYU pragma: begin_exports
3+
#include <sys/types.h>
4+
5+
#if defined(__APPLE__)
6+
#include <sys/_types/_off_t.h>
7+
#endif
8+
// IWYU pragma: end_exports
9+
// clang-format on
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <ystdlib/wrapped_facade_headers/sys/types.h>
2+
3+
#include <catch2/catch_test_macros.hpp>
4+
5+
namespace ystdlib::wrapped_facade_headers::test {
6+
TEST_CASE("test_off_t", "[wrapped_facade_headers][off_t]") {
7+
off_t const i{0};
8+
REQUIRE((0 == i));
9+
}
10+
} // namespace ystdlib::wrapped_facade_headers::test

taskfile.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ vars:
2020
- "all"
2121
- "containers"
2222
- "error_handling"
23+
- "wrapped_facade_headers"
2324

2425
tasks:
2526
clean:

0 commit comments

Comments
 (0)