From ba831957d41f521a060c675b54c6b43d2562110f Mon Sep 17 00:00:00 2001 From: whaffman Date: Wed, 24 Sep 2025 12:04:43 +0200 Subject: [PATCH] clang-format --- webserv/client/Client.cpp | 20 ++++++++++-------- webserv/config/ConfigManager.cpp | 16 ++++++++------- webserv/config/ConfigManager.hpp | 1 + webserv/config/LocationConfig.cpp | 1 + webserv/config/ServerConfig.cpp | 18 ++++++++-------- webserv/config/ServerConfig.hpp | 1 + webserv/config/utils.cpp | 1 + webserv/config/utils.hpp | 5 +++-- webserv/http/HttpHeaders.cpp | 2 +- webserv/http/HttpHeaders.hpp | 9 ++++---- webserv/http/HttpRequest.cpp | 13 ++++++------ webserv/log/Channel.cpp | 19 +++++++++-------- webserv/log/Channel.hpp | 1 + webserv/log/FileChannel.cpp | 11 +++++----- webserv/log/Log.hpp | 19 +++++++++-------- webserv/log/StdoutChannel.cpp | 7 ++++--- webserv/main.cpp | 15 +++++++------- webserv/server/Server.cpp | 34 ++++++++++++++++--------------- webserv/socket/Socket.cpp | 6 ++++-- webserv/socket/Socket.hpp | 9 ++++---- 20 files changed, 116 insertions(+), 92 deletions(-) diff --git a/webserv/client/Client.cpp b/webserv/client/Client.cpp index 68bd50b..9e69fed 100644 --- a/webserv/client/Client.cpp +++ b/webserv/client/Client.cpp @@ -1,13 +1,15 @@ #include -#include // for Log -#include // for uint8_t -#include // for ssize_t -#include // for HttpHeaders -#include // for Server -#include // for Socket -#include // for reference_wrapper, cref, ref -#include // for map -#include // for pair, move +#include // for HttpHeaders +#include // for Log +#include // for Server +#include // for Socket + +#include // for reference_wrapper, cref, ref +#include // for map +#include // for pair, move + +#include // for uint8_t +#include // for ssize_t Client::Client(std::unique_ptr socket, Server &server, const ServerConfig &server_config) : client_socket_(std::move(socket)), server_(std::ref(server)), server_config_(std::cref(server_config)), diff --git a/webserv/config/ConfigManager.cpp b/webserv/config/ConfigManager.cpp index 9209e44..3057e66 100644 --- a/webserv/config/ConfigManager.cpp +++ b/webserv/config/ConfigManager.cpp @@ -1,11 +1,13 @@ #include -#include // for ServerConfig -#include // for trim, findCorrespondingClosingBrace, trimSemi -#include // for Log -#include // for size_t -#include // for basic_ifstream, basic_istream, basic_filebuf, basic_ostream::operator<<, ifstream, istringstream, stringstream -#include // for basic_stringstream, basic_istringstream -#include // for runtime_error +#include // for ServerConfig +#include // for trim, findCorrespondingClosingBrace, trimSemi +#include // for Log + +#include // for basic_ifstream, basic_istream, basic_filebuf, basic_ostream::operator<<, ifstream, istringstream, stringstream +#include // for basic_stringstream, basic_istringstream +#include // for runtime_error + +#include // for size_t ConfigManager::ConfigManager() : initialized_(false) {} diff --git a/webserv/config/ConfigManager.hpp b/webserv/config/ConfigManager.hpp index 9cdab85..4e59515 100644 --- a/webserv/config/ConfigManager.hpp +++ b/webserv/config/ConfigManager.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include #include diff --git a/webserv/config/LocationConfig.cpp b/webserv/config/LocationConfig.cpp index a0e9533..3ad2e59 100644 --- a/webserv/config/LocationConfig.cpp +++ b/webserv/config/LocationConfig.cpp @@ -1,6 +1,7 @@ #include #include #include + #include #include diff --git a/webserv/config/ServerConfig.cpp b/webserv/config/ServerConfig.cpp index e45cd19..fa3e60f 100644 --- a/webserv/config/ServerConfig.cpp +++ b/webserv/config/ServerConfig.cpp @@ -1,12 +1,14 @@ -#include // for LocationConfig +#include // for LocationConfig #include -#include // for findCorrespondingClosingBrace, trim -#include // for Log, LOCATION -#include // for size_t -#include // for basic_istringstream, basic_istream, istringstream -#include // for basic_string, char_traits, operator+, allocator, string, operator==, operator>>, operator<=>, to_string, stoi, getline -#include // for runtime_error -#include // for pair +#include // for findCorrespondingClosingBrace, trim +#include // for Log, LOCATION + +#include // for basic_istringstream, basic_istream, istringstream +#include // for runtime_error +#include // for basic_string, char_traits, operator+, allocator, string, operator==, operator>>, operator<=>, to_string, stoi, getline +#include // for pair + +#include // for size_t ServerConfig::ServerConfig(std::string const &serverBlock) : port_(80) { diff --git a/webserv/config/ServerConfig.hpp b/webserv/config/ServerConfig.hpp index f71c808..51ddedc 100644 --- a/webserv/config/ServerConfig.hpp +++ b/webserv/config/ServerConfig.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include #include #include diff --git a/webserv/config/utils.cpp b/webserv/config/utils.cpp index 70b6615..74e3f82 100644 --- a/webserv/config/utils.cpp +++ b/webserv/config/utils.cpp @@ -1,4 +1,5 @@ #include + #include std::string trim(const std::string &str) diff --git a/webserv/config/utils.hpp b/webserv/config/utils.hpp index 73e35f0..7bf158f 100644 --- a/webserv/config/utils.hpp +++ b/webserv/config/utils.hpp @@ -1,7 +1,8 @@ #pragma once -#include // for size_t -#include // for string +#include // for string + +#include // for size_t std::string trimSemi(const std::string &str); std::string trim(const std::string &str); diff --git a/webserv/http/HttpHeaders.cpp b/webserv/http/HttpHeaders.cpp index a291fce..55f561a 100644 --- a/webserv/http/HttpHeaders.cpp +++ b/webserv/http/HttpHeaders.cpp @@ -1,6 +1,6 @@ #include // for trim #include // for CRLF -#include // for HttpHeaders +#include // for HttpHeaders #include // for __transform_fn, transform #include // for pair diff --git a/webserv/http/HttpHeaders.hpp b/webserv/http/HttpHeaders.hpp index 3648bbe..b9a538a 100644 --- a/webserv/http/HttpHeaders.hpp +++ b/webserv/http/HttpHeaders.hpp @@ -1,9 +1,10 @@ #pragma once -#include // for size_t -#include // for optional -#include // for basic_string, string, hash -#include // for unordered_map +#include // for optional +#include // for basic_string, string, hash +#include // for unordered_map + +#include // for size_t /** * @file HttpHeaders.hpp diff --git a/webserv/http/HttpRequest.cpp b/webserv/http/HttpRequest.cpp index 18fc6b7..f6efb31 100644 --- a/webserv/http/HttpRequest.cpp +++ b/webserv/http/HttpRequest.cpp @@ -1,10 +1,11 @@ -#include // for CRLF, DOUBLE_CRLF +#include // for CRLF, DOUBLE_CRLF #include -#include // for Log, LOCATION -#include // for basic_stringstream, basic_istream, stringstream -#include // for vector -#include // for exception -#include // for optional, operator> +#include // for Log, LOCATION + +#include // for exception +#include // for optional, operator> +#include // for basic_stringstream, basic_istream, stringstream +#include // for vector class ServerConfig; diff --git a/webserv/log/Channel.cpp b/webserv/log/Channel.cpp index b2afc04..9c89028 100644 --- a/webserv/log/Channel.cpp +++ b/webserv/log/Channel.cpp @@ -1,7 +1,8 @@ #include -#include // for operator<<, setfill, setw -#include // for basic_ostream, operator<<, basic_stringstream, basic_istream, basic_istringstream, right, istringstream, stringstream -#include // for get + +#include // for operator<<, setfill, setw +#include // for basic_ostream, operator<<, basic_stringstream, basic_istream, basic_istringstream, right, istringstream, stringstream +#include // for get Log::Level Channel::getLogLevel() const { @@ -24,12 +25,12 @@ std::string Channel::printContext(const std::map &cont { ss << "\t| " << std::right << std::setfill(' ') << "\e[1m" << key << "\e[0m" << " : \n"; - std::istringstream valueStream(value); - std::string line; - while (std::getline(valueStream, line)) - { - ss << std::setw(10) << "\t\t| " << line << "\n"; - } + std::istringstream valueStream(value); + std::string line; + while (std::getline(valueStream, line)) + { + ss << std::setw(10) << "\t\t| " << line << "\n"; + } continue; } ss << "\t| " << std::right << std::setfill(' ') << "\e[1m" << key << "\e[0m" << " : " << value << "\n"; diff --git a/webserv/log/Channel.hpp b/webserv/log/Channel.hpp index 91e7e0c..490de56 100644 --- a/webserv/log/Channel.hpp +++ b/webserv/log/Channel.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include #include diff --git a/webserv/log/FileChannel.cpp b/webserv/log/FileChannel.cpp index 64d81f2..40b85b9 100644 --- a/webserv/log/FileChannel.cpp +++ b/webserv/log/FileChannel.cpp @@ -1,9 +1,10 @@ #include -#include // for Log -#include // for system_clock -#include // for cerr -#include // for operator<<, put_time -#include // for localtime, tm +#include // for Log + +#include // for system_clock +#include // for localtime, tm +#include // for operator<<, put_time +#include // for cerr struct tm; diff --git a/webserv/log/Log.hpp b/webserv/log/Log.hpp index 809d7e8..bbdc871 100644 --- a/webserv/log/Log.hpp +++ b/webserv/log/Log.hpp @@ -1,14 +1,15 @@ #pragma once -#include // for uint8_t -#include // for array -#include // for steady_clock -#include // for map -#include // for unique_ptr -#include // for string, basic_string, hash -#include // for string_view -#include // for unordered_map -#include // for ios_base +#include // for array +#include // for steady_clock +#include // for ios_base +#include // for map +#include // for unique_ptr +#include // for string, basic_string, hash +#include // for string_view +#include // for unordered_map + +#include // for uint8_t class Channel; // Forward declaration diff --git a/webserv/log/StdoutChannel.cpp b/webserv/log/StdoutChannel.cpp index 0a852a5..a2cad0b 100644 --- a/webserv/log/StdoutChannel.cpp +++ b/webserv/log/StdoutChannel.cpp @@ -1,7 +1,8 @@ -#include // for Log +#include // for Log #include -#include // for operator<<, setfill, setw -#include // for basic_ostream, operator<<, basic_ostream::operator<<, cerr, cout, flush, ostream + +#include // for operator<<, setfill, setw +#include // for basic_ostream, operator<<, basic_ostream::operator<<, cerr, cout, flush, ostream StdoutChannel::StdoutChannel(Log::Level logLevel) { diff --git a/webserv/main.cpp b/webserv/main.cpp index 65539b4..ca6d5b3 100644 --- a/webserv/main.cpp +++ b/webserv/main.cpp @@ -1,10 +1,11 @@ -#include // for ConfigManager -#include // for Log, LOCATION -#include // for Server -#include // for basic_ostream, operator<<, cerr, ios_base -#include // for basic_string, char_traits, allocator, operator+, operator<=> -#include // for map -#include // for pair +#include // for ConfigManager +#include // for Log, LOCATION +#include // for Server + +#include // for basic_ostream, operator<<, cerr, ios_base +#include // for map +#include // for basic_string, char_traits, allocator, operator+, operator<=> +#include // for pair int main(int argc, char **argv) { diff --git a/webserv/server/Server.cpp b/webserv/server/Server.cpp index 8827664..841b70f 100644 --- a/webserv/server/Server.cpp +++ b/webserv/server/Server.cpp @@ -1,20 +1,22 @@ -#include // for Log +#include // for Client +#include // for ConfigManager +#include // for Log #include -#include // for Socket -#include // for epoll_event, epoll_ctl, EPOLLIN, EPOLLOUT, epoll_create1, epoll_wait, EPOLLERR, EPOLLHUP, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD -#include // for send, SOMAXCONN -#include // for close -#include // for errno -#include // for ssize_t -#include // for Client -#include // for ConfigManager -#include // for strerror, strlen -#include // for unique_ptr, allocator, make_unique -#include // for vector -#include // for exception -#include // for runtime_error -#include // for operator+, to_string, basic_string, char_traits, string -#include // for move, pair +#include // for Socket + +#include // for strerror, strlen +#include // for exception +#include // for unique_ptr, allocator, make_unique +#include // for runtime_error +#include // for operator+, to_string, basic_string, char_traits, string +#include // for move, pair +#include // for vector + +#include // for errno +#include // for epoll_event, epoll_ctl, EPOLLIN, EPOLLOUT, epoll_create1, epoll_wait, EPOLLERR, EPOLLHUP, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD +#include // for send, SOMAXCONN +#include // for ssize_t +#include // for close Server::Server(const ConfigManager &configManager) : epoll_fd_(epoll_create1(0)), configManager_(configManager) { diff --git a/webserv/socket/Socket.cpp b/webserv/socket/Socket.cpp index a9b27d0..60a584a 100644 --- a/webserv/socket/Socket.cpp +++ b/webserv/socket/Socket.cpp @@ -1,12 +1,14 @@ #include #include + +#include +#include + #include // For inet_addr #include // For fcntl()" #include // For sockaddr_in #include #include // For close() -#include -#include Socket::Socket() : fd_(socket(AF_INET, SOCK_STREAM, 0)) { diff --git a/webserv/socket/Socket.hpp b/webserv/socket/Socket.hpp index fe6b2ae..3accc5e 100644 --- a/webserv/socket/Socket.hpp +++ b/webserv/socket/Socket.hpp @@ -1,9 +1,10 @@ #pragma once -#include // for ssize_t -#include // for size_t -#include // for unique_ptr -#include // for string +#include // for unique_ptr +#include // for string + +#include // for size_t +#include // for ssize_t class Socket {