fix: apply IWYU suggestions

This commit is contained in:
whaffman 2025-09-26 18:08:32 +02:00
parent c841142e79
commit 143498315b
43 changed files with 138 additions and 136 deletions

View File

@ -1,15 +1,15 @@
#include <webserv/client/Client.hpp>
#include <webserv/http/HttpHeaders.hpp> // for HttpHeaders
#include <webserv/log/Log.hpp> // for Log
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <webserv/server/Server.hpp> // for Server
#include <webserv/socket/Socket.hpp> // for Socket
#include <sys/types.h> // for ssize_t
#include <cstdint> // for uint8_t
#include <functional> // for reference_wrapper, cref, ref
#include <map> // for map
#include <utility> // for pair, move
#include <sys/types.h> // for ssize_t
class ServerConfig;
Client::Client(std::unique_ptr<Socket> socket, Server &server, const ServerConfig &server_config)
: client_socket_(std::move(socket)), server_(std::ref(server)), server_config_(std::cref(server_config)),

View File

@ -4,13 +4,13 @@
#include <webserv/http/HttpRequest.hpp> // for HttpRequest
#include <webserv/server/Server.hpp>
#include <webserv/socket/Socket.hpp>
#include <cstddef> // for size_t
#include <memory> // for unique_ptr
#include <string> // for string
class Server;
class Socket;
class ServerConfig;
class Client
{

View File

@ -3,6 +3,8 @@
#include <webserv/config/directive/DirectiveFactory.hpp> // for DirectiveFactory
#include <webserv/config/utils.hpp> // for trim
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <sstream> // for basic_stringstream, stringstream
#include <utility> // for move, pair
AConfig::AConfig(const AConfig *parent) : parent_(parent) {}

View File

@ -1,12 +1,11 @@
#pragma once
#include "webserv/config/directive/DirectiveValue.hpp"
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <map> // for map
#include <memory> // for unique_ptr
#include <string> // for basic_string, string
#include <map>
#include <memory>
#include <string>
#include "webserv/config/directive/DirectiveValue.hpp"
class AConfig
{

View File

@ -1,13 +1,12 @@
#include <webserv/config/ConfigManager.hpp>
#include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <webserv/config/directive/DirectiveFactory.hpp> // for DirectiveFactory
#include <webserv/config/utils.hpp> // for trim, findCorrespondingClosingBrace, trimSemi
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <fstream> // for basic_ifstream, basic_istream, basic_filebuf, basic_ostream::operator<<, stringstream, ifstream, istringstream
#include <sstream> // for basic_stringstream, basic_istringstream
#include <webserv/config/utils.hpp> // for removeComments
#include <webserv/log/Log.hpp> // for Log
#include <fstream> // for basic_ifstream, basic_filebuf, basic_ostream::operator<<, ifstream, stringstream
#include <sstream> // for basic_stringstream
#include <stdexcept> // for runtime_error
#include <string> // for basic_string, char_traits, string, operator+, to_string, getline, operator<=>
#include <string> // for char_traits, operator+, basic_string, string
#include "webserv/config/GlobalConfig.hpp" // for GlobalConfig
ConfigManager::ConfigManager() : initialized_(false) {}

View File

@ -2,12 +2,12 @@
#include <webserv/config/GlobalConfig.hpp>
#include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <memory> // for unique_ptr
#include <string> // for string
#include <vector> // for vector
class ADirective;
class GlobalConfig;
class ConfigManager
{

View File

@ -1,8 +1,9 @@
#include <webserv/config/GlobalConfig.hpp>
#include <webserv/config/utils.hpp>
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <vector>
#include <webserv/config/utils.hpp> // for findCorrespondingClosingBrace
#include <webserv/log/Log.hpp> // for Log
#include <stddef.h> // for size_t
#include <vector> // for vector
#include <stdexcept> // for runtime_error
GlobalConfig::GlobalConfig(const std::string &block)
{

View File

@ -1,7 +1,10 @@
#pragma once
#include <webserv/config/AConfig.hpp> // for AConfig
#include <webserv/config/ServerConfig.hpp>
#include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <memory> // for unique_ptr
#include <string> // for string
#include <vector> // for vector
class GlobalConfig : public AConfig
{

View File

@ -1,6 +1,7 @@
#pragma once
#include <webserv/config/AConfig.hpp> // for AConfig
#include <string> // for string
class LocationConfig : public AConfig
{

View File

@ -1,7 +1,12 @@
#include <webserv/config/LocationConfig.hpp>
#include <webserv/config/LocationConfig.hpp> // for LocationConfig
#include <webserv/config/ServerConfig.hpp>
#include <webserv/config/utils.hpp>
#include <webserv/config/utils.hpp> // for findCorrespondingClosingBrace, trim
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <stddef.h> // for size_t
#include <stdexcept> // for runtime_error
#include <utility> // for pair
#include "webserv/config/AConfig.hpp" // for AConfig
ServerConfig::ServerConfig(const std::string &block, const AConfig *parent) : AConfig(parent)
{

View File

@ -2,6 +2,10 @@
#include <webserv/config/AConfig.hpp> // for AConfig
#include <webserv/config/LocationConfig.hpp> // for LocationConfig
#include <map> // for map
#include <memory> // for unique_ptr
#include <string> // for basic_string, string
#include <vector> // for vector
class ServerConfig : public AConfig
{

View File

@ -1,7 +1,6 @@
#pragma once
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValue, DirectiveValueType
#include <iostream> // for ostream
#include <string> // for string, basic_string
#include <utility> // for move

View File

@ -1,10 +1,12 @@
#include <webserv/config/directive/BoolDirective.hpp> // for IntDirective
#include <webserv/config/utils.hpp> // for trim
#include <algorithm> // for __transform_fn, transform
#include <cctype> // for tolower
#include <stdexcept> // for invalid_argument
#include "webserv/config/directive/ADirective.hpp" // for ADirective
#include "webserv/config/directive/DirectiveValue.hpp" // for DirectiveValueType
BoolDirective::BoolDirective(const std::string &name, const std::string &value)
: ADirective(name) // NOLINT(bugprone-easily-swappable-parameters)
{

View File

@ -2,7 +2,6 @@
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <string> // for string, basic_string
class BoolDirective : public ADirective

View File

@ -1,5 +1,3 @@
#include "webserv/log/Log.hpp"
#include <webserv/config/directive/BoolDirective.hpp> // for BoolDirective
#include <webserv/config/directive/DirectiveFactory.hpp> // for DirectiveFactory
#include <webserv/config/directive/IntDirective.hpp> // for IntDirective
@ -8,9 +6,11 @@
#include <webserv/config/directive/StringDirective.hpp> // for StringDirective
#include <webserv/config/directive/VectorDirective.hpp> // for VectorDirective
#include <webserv/config/utils.hpp> // for trim, trimSemi
#include <sstream> // for basic_stringstream, stringstream
#include <stdexcept> // for invalid_argument
#include <utility> // for pair
#include "webserv/log/Log.hpp" // for LOCATION, Log
class ADirective;

View File

@ -1,6 +1,5 @@
#pragma once
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <array> // for array
#include <functional> // for function
#include <memory> // for unique_ptr

View File

@ -1,8 +1,6 @@
#include <webserv/config/directive/ADirective.hpp> // for ADirective, operator<<
#include <webserv/config/directive/DirectiveValue.hpp>
#include <cstddef> // for size_t
#include <string> // for string, basic_string, allocator, char_traits, operator+, to_string, operator<<
#include <string> // for string, basic_string, allocator, operator+, char_traits, to_string, operator<<
#include <utility> // for pair
#include <variant> // for visit
#include <vector> // for vector

View File

@ -1,5 +1,8 @@
#include <webserv/config/directive/IntDirective.hpp> // for IntDirective
#include "webserv/config/directive/ADirective.hpp" // for ADirective
#include "webserv/config/directive/DirectiveValue.hpp" // for DirectiveValueType
IntDirective::IntDirective(const std::string &name, const std::string &value)
: ADirective(name) // NOLINT(bugprone-easily-swappable-parameters)
{

View File

@ -2,7 +2,6 @@
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <string> // for string, basic_string
class IntDirective : public ADirective

View File

@ -1,8 +1,10 @@
#include <webserv/config/directive/IntStringDirective.hpp> // for IntDirective
#include <webserv/config/utils.hpp> // for trim
#include <sstream> // for basic_istringstream, basic_istream::operator>>, istringstream
#include "webserv/config/directive/ADirective.hpp" // for ADirective
#include "webserv/config/directive/DirectiveValue.hpp" // for DirectiveValueType
IntStringDirective::IntStringDirective(const std::string &name, const std::string &value)
: ADirective(name) // NOLINT(bugprone-easily-swappable-parameters)
{

View File

@ -1,7 +1,6 @@
#pragma once
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <string> // for basic_string, string
#include <utility> // for pair

View File

@ -1,10 +1,12 @@
#include <webserv/config/directive/SizeDirective.hpp> // for SizeDirective
#include <webserv/config/utils.hpp> // for trim
#include <algorithm> // for __transform_fn, transform
#include <cctype> // for tolower
#include <stdexcept> // for invalid_argument
#include "webserv/config/directive/ADirective.hpp" // for ADirective
#include "webserv/config/directive/DirectiveValue.hpp" // for DirectiveValueType
SizeDirective::SizeDirective(const std::string &name, const std::string &value)
: ADirective(name) // NOLINT(bugprone-easily-swappable-parameters)
{

View File

@ -2,7 +2,6 @@
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <cstddef> // for size_t
#include <string> // for string, basic_string

View File

@ -1,5 +1,8 @@
#include <webserv/config/directive/StringDirective.hpp> // for IntDirective
#include "webserv/config/directive/ADirective.hpp" // for ADirective
#include "webserv/config/directive/DirectiveValue.hpp" // for DirectiveValueType
StringDirective::StringDirective(const std::string &name, const std::string &value)
: ADirective(name) // NOLINT(bugprone-easily-swappable-parameters)
{

View File

@ -2,7 +2,6 @@
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <string> // for string, basic_string
class StringDirective : public ADirective

View File

@ -1,7 +1,9 @@
#include <webserv/config/directive/VectorDirective.hpp> // for IntDirective
#include <sstream> // for basic_stringstream, stringstream
#include "webserv/config/directive/ADirective.hpp" // for ADirective
#include "webserv/config/directive/DirectiveValue.hpp" // for DirectiveValueType
VectorDirective::VectorDirective(const std::string &name, const std::string &value)
: ADirective(name) // NOLINT(bugprone-easily-swappable-parameters)
{

View File

@ -2,7 +2,6 @@
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <string> // for basic_string, string
#include <vector> // for vector

View File

@ -1,6 +1,5 @@
#include <webserv/config/utils.hpp>
#include <sstream>
#include <stdexcept>
#include <string>

View File

@ -2,7 +2,6 @@
#include <webserv/http/HttpConstants.hpp> // for CRLF
#include <webserv/http/HttpHeaders.hpp> // for HttpHeaders
#include <webserv/log/Log.hpp>
#include <algorithm> // for __transform_fn, transform
#include <cctype> // for tolower
#include <utility> // for pair

View File

@ -1,15 +1,14 @@
#include "webserv/config/utils.hpp" // for stoul
#include <webserv/http/HttpConstants.hpp> // for CRLF, DOUBLE_CRLF
#include <webserv/http/HttpRequest.hpp>
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <map> // for map
#include <optional> // for optional
#include <sstream> // for basic_stringstream, basic_istream, stringstream
#include <utility> // for pair
#include <vector> // for vector
#include "webserv/config/utils.hpp" // for stoul
class ServerConfig;
HttpRequest::HttpRequest(const ServerConfig *serverConfig, const Client *client)

View File

@ -2,7 +2,6 @@
#include <webserv/config/ServerConfig.hpp>
#include <webserv/http/HttpHeaders.hpp> // for HttpHeaders
#include <cstddef> // for size_t
#include <cstdint> // for uint8_t
#include <string> // for string, basic_string

View File

@ -1,5 +1,4 @@
#include <webserv/log/Channel.hpp>
#include <iomanip> // for operator<<, setfill, setw
#include <sstream> // for basic_ostream, operator<<, basic_stringstream, basic_istream, basic_istringstream, right, istringstream, stringstream
#include <utility> // for get

View File

@ -1,7 +1,6 @@
#pragma once
#include <webserv/log/Log.hpp>
#include <map>
#include <string>

View File

@ -1,6 +1,5 @@
#include <webserv/log/FileChannel.hpp>
#include <webserv/log/Log.hpp> // for Log
#include <chrono> // for system_clock
#include <ctime> // for localtime, tm
#include <iomanip> // for operator<<, put_time

View File

@ -2,7 +2,6 @@
#include <webserv/log/Channel.hpp> // for Channel
#include <webserv/log/Log.hpp> // for Log
#include <fstream> // for basic_ofstream, ios_base, ofstream
#include <map> // for map
#include <string> // for string, basic_string

View File

@ -2,7 +2,6 @@
#include <webserv/log/FileChannel.hpp> // for FileChannel
#include <webserv/log/Log.hpp>
#include <webserv/log/StdoutChannel.hpp> // for StdoutChannel
#include <chrono> // for duration_cast, operator-, steady_clock, duration, seconds
#include <exception> // for exception
#include <iostream> // for basic_ostream, operator<<, cerr

View File

@ -1,6 +1,5 @@
#include <webserv/log/Log.hpp> // for Log
#include <webserv/log/StdoutChannel.hpp>
#include <iomanip> // for operator<<, setfill, setw
#include <iostream> // for basic_ostream, operator<<, basic_ostream::operator<<, cerr, cout, flush, ostream

View File

@ -2,7 +2,6 @@
#include <webserv/log/Channel.hpp> // for Channel
#include <webserv/log/Log.hpp> // for Log
#include <map> // for map
#include <string> // for string, basic_string

View File

@ -1,7 +1,6 @@
#include <webserv/config/ConfigManager.hpp> // for ConfigManager
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <webserv/server/Server.hpp> // for Server
#include <iostream> // for basic_ostream, operator<<, cerr, ios_base
#include <map> // for map
#include <string> // for basic_string, char_traits, allocator, operator+, operator<=>

View File

@ -3,7 +3,11 @@
#include <webserv/log/Log.hpp> // for Log
#include <webserv/server/Server.hpp>
#include <webserv/socket/Socket.hpp> // for Socket
#include <sys/epoll.h> // for epoll_event, epoll_ctl, EPOLLIN, EPOLLOUT, epoll_create1, epoll_wait, EPOLLERR, EPOLLHUP, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD
#include <sys/socket.h> // for send, SOMAXCONN
#include <sys/types.h> // for ssize_t
#include <unistd.h> // for close
#include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <cerrno> // for errno
#include <cstring> // for strerror, strlen
#include <exception> // for exception
@ -13,11 +17,6 @@
#include <utility> // for move, pair
#include <vector> // for vector
#include <sys/epoll.h> // for epoll_event, epoll_ctl, EPOLLIN, EPOLLOUT, epoll_create1, epoll_wait, EPOLLERR, EPOLLHUP, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD
#include <sys/socket.h> // for send, SOMAXCONN
#include <sys/types.h> // for ssize_t
#include <unistd.h> // for close
Server::Server(const ConfigManager &configManager) : epoll_fd_(epoll_create1(0)), configManager_(configManager)
{
const auto &serverConfigs = configManager.getServerConfigs();

View File

@ -4,7 +4,6 @@
#include <webserv/config/ConfigManager.hpp>
#include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <webserv/socket/Socket.hpp> // for Socket
#include <cstdint> // for uint32_t
#include <functional> // for reference_wrapper
#include <memory> // for unique_ptr
@ -13,6 +12,7 @@
class Client;
class ConfigManager;
class ServerConfig;
class Server
{

View File

@ -1,14 +1,12 @@
#include <webserv/log/Log.hpp>
#include <webserv/socket/Socket.hpp>
#include <memory>
#include <stdexcept>
#include <arpa/inet.h> // For inet_addr
#include <fcntl.h> // For fcntl()"
#include <netinet/in.h> // For sockaddr_in
#include <sys/socket.h>
#include <unistd.h> // For close()
#include <memory>
#include <stdexcept>
Socket::Socket() : fd_(socket(AF_INET, SOCK_STREAM, 0))
{

View File

@ -1,11 +1,10 @@
#pragma once
#include <sys/types.h> // for ssize_t
#include <cstddef> // for size_t
#include <memory> // for unique_ptr
#include <string> // for string
#include <sys/types.h> // for ssize_t
class Socket
{
public: