From 880e8c45c5621ed8432b74a0cf4f212b9c14aade Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 13 Jun 2026 19:23:10 +0200 Subject: finally, perfect .clang-format settings? --- server/lexer/details/parse.cpp | 17 +++++++++++------ server/lexer/token.cpp | 5 +++-- server/lexer/token_type.cpp | 10 ++++++---- server/main/server.cpp | 8 +++++--- server/main/session.cpp | 8 ++++++-- server/main/settings.hpp | 6 ++++-- 6 files changed, 35 insertions(+), 19 deletions(-) (limited to 'server') diff --git a/server/lexer/details/parse.cpp b/server/lexer/details/parse.cpp index 75072a4..5df6254 100644 --- a/server/lexer/details/parse.cpp +++ b/server/lexer/details/parse.cpp @@ -63,7 +63,8 @@ protected: // numbers using a regex (the tests seem to pass though). // A proper NFA would be better, I guess. static constexpr std::string_view NUMBER_REGEX{ - R"REGEX(^(?:\d+(?:\.\d*)?|\.\d+)(e[+-]?(\d*))?)REGEX"}; + R"REGEX(^(?:\d+(?:\.\d*)?|\.\d+)(e[+-]?(\d*))?)REGEX" + }; private: bool matched_e() const { @@ -108,9 +109,11 @@ private: }; template -std::optional parse_number(std::string_view input, - RegexNumberMatcher&& matcher, - std::string_view& token) { +std::optional parse_number( + std::string_view input, + RegexNumberMatcher&& matcher, + std::string_view& token +) { if (!matcher.match(input)) { return {}; } @@ -162,8 +165,10 @@ private: }; template -std::string_view parse_whitespace(std::string_view input, - RegexWhitespaceMatcher&& matcher) { +std::string_view parse_whitespace( + std::string_view input, + RegexWhitespaceMatcher&& matcher +) { if (matcher.match_regex(input)) { return matcher.to_view(); } diff --git a/server/lexer/token.cpp b/server/lexer/token.cpp index 61ab1e7..e2d0a3f 100644 --- a/server/lexer/token.cpp +++ b/server/lexer/token.cpp @@ -49,8 +49,9 @@ bool Token::operator==(const Token& other) const { if (m_type == Type::NUMBER) { return numbers_equal(as_number(), other.as_number()); } - throw LexerError{"internal: can't compare tokens of type: " + - token::type_to_int_string(m_type)}; + throw LexerError{ + "internal: can't compare tokens of type: " + token::type_to_int_string(m_type) + }; } double Token::as_number() const { diff --git a/server/lexer/token_type.cpp b/server/lexer/token_type.cpp index b0ab9e0..d26e6a4 100644 --- a/server/lexer/token_type.cpp +++ b/server/lexer/token_type.cpp @@ -54,8 +54,9 @@ private: for (const auto& [type, str] : m_map) { const auto [_, inserted] = strings.emplace(str); if (!inserted) { - throw std::logic_error{"multiple tokens have the same string representation: " + - str}; + throw std::logic_error{ + "multiple tokens have the same string representation: " + str + }; } } } @@ -82,8 +83,9 @@ private: for (const auto& [type, str] : to_string) { const auto [_, inserted] = from_string.emplace(str, type); if (!inserted) { - throw std::logic_error{"multiple tokens have the same string representation: " + - str}; + throw std::logic_error{ + "multiple tokens have the same string representation: " + str + }; } } return from_string; diff --git a/server/main/server.cpp b/server/main/server.cpp index b27c551..4c0ab83 100644 --- a/server/main/server.cpp +++ b/server/main/server.cpp @@ -68,8 +68,9 @@ void Server::wait_for_signal() { m_signals.add(SIGINT); m_signals.add(SIGTERM); - m_signals.async_wait( - [this](const boost::system::error_code& ec, int signo) { handle_signal(ec, signo); }); + m_signals.async_wait([this](const boost::system::error_code& ec, int signo) { + handle_signal(ec, signo); + }); } catch (const boost::system::system_error& e) { throw Error{e.what()}; } @@ -94,7 +95,8 @@ void Server::accept() { const auto session = m_session_mgr.make_session(m_io_context); m_acceptor.async_accept( session->socket(), - [session, this](const boost::system::error_code& ec) { handle_accept(session, ec); }); + [session, this](const boost::system::error_code& ec) { handle_accept(session, ec); } + ); } void Server::handle_accept(SessionPtr session, const boost::system::error_code& ec) { diff --git a/server/main/session.cpp b/server/main/session.cpp index 31f37fc..b4b9fc5 100644 --- a/server/main/session.cpp +++ b/server/main/session.cpp @@ -75,7 +75,9 @@ void Session::read() { boost::asio::bind_executor( m_strand, [this, self](const boost::system::error_code& ec, std::size_t bytes) { handle_read(ec, bytes); - })); + } + ) + ); } void Session::handle_read(const boost::system::error_code& ec, std::size_t bytes) { @@ -108,7 +110,9 @@ void Session::write(const std::string& output) { boost::asio::bind_executor( m_strand, [this, self](const boost::system::error_code& ec, std::size_t bytes) { handle_write(ec, bytes); - })); + } + ) + ); } void Session::handle_write(const boost::system::error_code& ec, std::size_t) { diff --git a/server/main/settings.hpp b/server/main/settings.hpp index 16d9ecb..afe2f01 100644 --- a/server/main/settings.hpp +++ b/server/main/settings.hpp @@ -43,11 +43,13 @@ public: m_visible.add_options()( "port,p", po::value(&m_settings.m_port)->default_value(Settings::DEFAULT_PORT), - "server port number"); + "server port number" + ); m_visible.add_options()( "threads,n", po::value(&m_settings.m_threads)->default_value(Settings::default_threads()), - "number of threads"); + "number of threads" + ); } static const char* get_short_description() { -- cgit v1.3