Enhance code formatting and organization:
- Add tasks for code formatting and checking in VSCode - Update .clang-format for consistent style - Clean up includes and formatting in various files
This commit is contained in:
parent
31014705b1
commit
3eb46dba13
@ -36,3 +36,6 @@ AllowShortIfStatementsOnASingleLine: true
|
|||||||
AllowShortLoopsOnASingleLine: true
|
AllowShortLoopsOnASingleLine: true
|
||||||
AllowShortBlocksOnASingleLine: Empty
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
|
||||||
|
# Add empty line between function definitions
|
||||||
|
SeparateDefinitionBlocks: Always
|
||||||
28
.vscode/tasks.json
vendored
28
.vscode/tasks.json
vendored
@ -67,6 +67,34 @@
|
|||||||
"dependsOn": "Build ASAN",
|
"dependsOn": "Build ASAN",
|
||||||
"detail": "Build and run AddressSanitizer version"
|
"detail": "Build and run AddressSanitizer version"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Format Code",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "find webserv -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i",
|
||||||
|
"group": "build",
|
||||||
|
"detail": "Format all C++ source and header files using clang-format",
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": false,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": true,
|
||||||
|
"clear": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Check Format",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "find webserv -name '*.cpp' -o -name '*.hpp' | xargs clang-format --dry-run --Werror",
|
||||||
|
"group": "test",
|
||||||
|
"detail": "Check if all files are properly formatted (without modifying them)",
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": false,
|
||||||
|
"panel": "shared"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Clean",
|
"label": "Clean",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
|
|||||||
@ -3,8 +3,9 @@
|
|||||||
#include "webserv/socket/Socket.hpp"
|
#include "webserv/socket/Socket.hpp"
|
||||||
|
|
||||||
#include <webserv/config/ServerConfig.hpp>
|
#include <webserv/config/ServerConfig.hpp>
|
||||||
#include <webserv/server/Server.hpp>
|
|
||||||
#include <webserv/http/HttpRequest.hpp>
|
#include <webserv/http/HttpRequest.hpp>
|
||||||
|
#include <webserv/server/Server.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class Server;
|
class Server;
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
class ConfigManager
|
class ConfigManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -16,7 +15,8 @@ class ConfigManager
|
|||||||
|
|
||||||
void init(const std::string &filePath);
|
void init(const std::string &filePath);
|
||||||
static ConfigManager &getInstance();
|
static ConfigManager &getInstance();
|
||||||
const std::vector<ServerConfig> &getServerConfigs() const { return serverConfigs_; }
|
|
||||||
|
[[nodiscard]] const std::vector<ServerConfig> &getServerConfigs() const { return serverConfigs_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initialized_;
|
bool initialized_;
|
||||||
|
|||||||
@ -14,6 +14,7 @@ void LocationConfig::parseLocationBlock(const std::string &block)
|
|||||||
{
|
{
|
||||||
parseDirectives(block);
|
parseDirectives(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationConfig::parseDirectives(const std::string &declarations)
|
void LocationConfig::parseDirectives(const std::string &declarations)
|
||||||
{
|
{
|
||||||
std::istringstream stream(declarations);
|
std::istringstream stream(declarations);
|
||||||
|
|||||||
@ -12,16 +12,24 @@ class ServerConfig
|
|||||||
ServerConfig(const std::string &serverBlock);
|
ServerConfig(const std::string &serverBlock);
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getHost() const { return host_; }
|
[[nodiscard]] const std::string &getHost() const { return host_; }
|
||||||
|
|
||||||
[[nodiscard]] int getPort() const { return port_; }
|
[[nodiscard]] int getPort() const { return port_; }
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getRoot() const { return root_; }
|
[[nodiscard]] const std::string &getRoot() const { return root_; }
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getCgiPass() const { return cgi_pass_; }
|
[[nodiscard]] const std::string &getCgiPass() const { return cgi_pass_; }
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getCgiExt() const { return cgi_ext_; }
|
[[nodiscard]] const std::string &getCgiExt() const { return cgi_ext_; }
|
||||||
|
|
||||||
[[nodiscard]] const std::map<int, std::string> &getErrorPages() const { return error_page_; }
|
[[nodiscard]] const std::map<int, std::string> &getErrorPages() const { return error_page_; }
|
||||||
|
|
||||||
[[nodiscard]] const std::vector<std::string> &getIndexFiles() const { return index_files_; }
|
[[nodiscard]] const std::vector<std::string> &getIndexFiles() const { return index_files_; }
|
||||||
|
|
||||||
[[nodiscard]] const LocationConfig &getLocation(const std::string &path) const;
|
[[nodiscard]] const LocationConfig &getLocation(const std::string &path) const;
|
||||||
[[nodiscard]] std::vector<std::string> getLocationPaths() const;
|
[[nodiscard]] std::vector<std::string> getLocationPaths() const;
|
||||||
|
|
||||||
void setServerFD(int fd) { server_fd_ = fd; }
|
void setServerFD(int fd) { server_fd_ = fd; }
|
||||||
|
|
||||||
[[nodiscard]] int getServerFD() const { return server_fd_; }
|
[[nodiscard]] int getServerFD() const { return server_fd_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -1,14 +1,15 @@
|
|||||||
|
#include <webserv/client/Client.hpp>
|
||||||
|
#include <webserv/config/ServerConfig.hpp>
|
||||||
|
#include <webserv/http/HttpConstants.hpp>
|
||||||
#include <webserv/http/HttpRequest.hpp>
|
#include <webserv/http/HttpRequest.hpp>
|
||||||
#include <webserv/log/Log.hpp>
|
#include <webserv/log/Log.hpp>
|
||||||
#include <webserv/config/ServerConfig.hpp>
|
|
||||||
#include <webserv/client/Client.hpp>
|
|
||||||
#include <webserv/http/HttpConstants.hpp>
|
|
||||||
|
|
||||||
HttpRequest::HttpRequest(const ServerConfig *serverConfig, const Client *client)
|
HttpRequest::HttpRequest(const ServerConfig *serverConfig, const Client *client)
|
||||||
: serverConfig_(serverConfig), client_(client)
|
: serverConfig_(serverConfig), client_(client)
|
||||||
{
|
{
|
||||||
Log::trace("HttpRequest constructor called");
|
Log::trace("HttpRequest constructor called");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest::~HttpRequest()
|
HttpRequest::~HttpRequest()
|
||||||
{
|
{
|
||||||
Log::trace("HttpRequest destructor called");
|
Log::trace("HttpRequest destructor called");
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Client;
|
class Client;
|
||||||
|
|
||||||
class HttpRequest
|
class HttpRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
#include <webserv/http/HttpResponse.hpp>
|
#include <webserv/http/HttpResponse.hpp>
|
||||||
|
|
||||||
HttpResponse::HttpResponse()
|
HttpResponse::HttpResponse() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
#include <webserv/router/Router.hpp>
|
#include <webserv/router/Router.hpp>
|
||||||
|
|
||||||
Router::Router()
|
Router::Router() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -7,5 +7,4 @@ class Router
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Router();
|
Router();
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -54,6 +54,7 @@ void Socket::listen(int backlog) const
|
|||||||
throw std::runtime_error("Listen failed");
|
throw std::runtime_error("Listen failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::bind(const std::string &host, const int port) const
|
void Socket::bind(const std::string &host, const int port) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user