Skip to content

Commit

Permalink
Updated automatic formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
KazDragon committed Mar 24, 2024
1 parent 071c31d commit b96f5e3
Show file tree
Hide file tree
Showing 107 changed files with 4,144 additions and 3,881 deletions.
41 changes: 28 additions & 13 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: Left
AlignOperands: AlignAfterOperator
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
Expand All @@ -18,29 +24,38 @@ BraceWrapping:
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
ColumnLimit: "80"
Cpp11BracedListStyle: true
DerivePointerAlignment: "false"
IncludeBlocks: Preserve
IndentWidth: 4
IndentAccessModifiers: false
PointerAlignment: Right
ConstructorInitializerIndentWidth: 2
SortIncludes: "true"
QualifierAlignment: Right
IncludeBlocks: Regroup
IncludeCategories:
- Regex: ^<.*\.h.*>
- Regex: ^"[^/]+"
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: ^<.*
- Regex: ^".*"
Priority: 2
SortPriority: 3
CaseSensitive: false
- Regex: ^<.*\.h.*>
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: .*
Priority: 1
SortPriority: 0
- Regex: ^<(cassert|cctype|cerrno|cfenv|cfloat|cinttypes|climits|clocale|cmath|csetjmp|csignal|cstdarg|cstddef|cstdint|cstdio|cstdlib|cstring|ctime|cuchar|cwchar|cwctype)>$
Priority: 4
SortPriority: 5
CaseSensitive: false
- Regex: ^<.*
Priority: 4
SortPriority: 4
CaseSensitive: false
PointerAlignment: Right
ConstructorInitializerIndentWidth: 2
SortIncludes: "true"
QualifierAlignment: Right
5 changes: 3 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Checks: >
-google-readability-todo,
-misc-no-recursion,
-misc-unused-parameters,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-readability-convert-member-functions-to-static,
Expand All @@ -25,8 +26,6 @@ Checks: >
WarningsAsErrors: "*"

CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: true
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: true
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
Expand All @@ -51,6 +50,8 @@ CheckOptions:
value: lower_case
- key: readability-identifier-naming.PrivateMemberCase
value: lower_case
- key: readability-identifier-naming.PublicMemberSuffix
value: _
- key: readability-identifier-naming.ProtectedMemberSuffix
value: _
- key: readability-identifier-naming.PrivateMemberSuffix
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ target_sources(telnetpp_tester
PRIVATE
test/fakes/fake_channel.hpp
test/fakes/fake_client_option.hpp
test/fakes/fake_compressor.hpp
test/fakes/fake_decompressor.hpp
test/telnet_option_fixture.hpp

test/client_option_test.cpp
Expand Down Expand Up @@ -360,7 +358,7 @@ target_link_libraries(telnetpp_tester
GTest::Main
)

add_test(telnetpp_test telnetpp_tester)
gtest_discover_tests(telnetpp_tester)
endif()

# Add customizations for packaging
Expand Down
12 changes: 6 additions & 6 deletions include/telnetpp/client_option.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class TELNETPP_EXPORT client_option
: public telnetpp::
option<telnetpp::do_, telnetpp::dont, telnetpp::will, telnetpp::wont>
{
public:
constexpr explicit client_option(
telnetpp::session &sess, telnetpp::option_type code) noexcept
: option{sess, code}
{
}
public:
constexpr explicit client_option(
telnetpp::session &sess, telnetpp::option_type code) noexcept
: option{sess, code}
{
}
};

} // namespace telnetpp
41 changes: 21 additions & 20 deletions include/telnetpp/command.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "telnetpp/core.hpp"

#include <iosfwd>

namespace telnetpp {
Expand All @@ -10,40 +11,40 @@ namespace telnetpp {
//* =========================================================================
class TELNETPP_EXPORT command
{
public:
//* =====================================================================
/// \brief Constructor
//* =====================================================================
explicit constexpr command(command_type cmnd) noexcept : command_(cmnd)
{
}

//* =====================================================================
/// \brief Returns the value of the command.
//* =====================================================================
[[nodiscard]] constexpr command_type value() const noexcept
{
return command_;
}

private:
command_type command_;
public:
//* =====================================================================
/// \brief Constructor
//* =====================================================================
explicit constexpr command(command_type cmnd) noexcept : command_(cmnd)
{
}

//* =====================================================================
/// \brief Returns the value of the command.
//* =====================================================================
[[nodiscard]] constexpr command_type value() const noexcept
{
return command_;
}

private:
command_type command_;
};

//* =========================================================================
/// \brief Comparison function for commands
//* =========================================================================
constexpr bool operator==(command const &lhs, command const &rhs) noexcept
{
return lhs.value() == rhs.value();
return lhs.value() == rhs.value();
}

//* =========================================================================
/// \brief Comparison function for commands
//* =========================================================================
constexpr bool operator<(command const &lhs, command const &rhs) noexcept
{
return lhs.value() < rhs.value();
return lhs.value() < rhs.value();
}

//* =========================================================================
Expand Down
18 changes: 10 additions & 8 deletions include/telnetpp/core.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once

#include "telnetpp/detail/export.hpp" // IWYU pragma: export

#include <gsl/gsl-lite.hpp>
#include <cstdint>

#include <string>
#include <cstdint>

namespace telnetpp {

Expand Down Expand Up @@ -47,15 +49,15 @@ namespace literals {
// A simple function to convert from string literals to stored bytes.
inline byte_storage operator""_tb(char const *text, size_t length)
{
byte_storage result;
result.reserve(length);
byte_storage result;
result.reserve(length);

for (auto ch : gsl::span<char const>{text, length})
{
result.push_back(static_cast<telnetpp::byte>(ch));
}
for (auto ch : gsl::span<char const>{text, length})
{
result.push_back(static_cast<telnetpp::byte>(ch));
}

return result;
return result;
}

} // namespace literals
Expand Down
8 changes: 4 additions & 4 deletions include/telnetpp/detail/command_router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace telnetpp::detail {

struct command_router_key_from_message_policy
{
static command_type key_from_message(command const &cmd)
{
return cmd.value();
}
static command_type key_from_message(command const &cmd)
{
return cmd.value();
}
};

class command_router : public router<
Expand Down
59 changes: 30 additions & 29 deletions include/telnetpp/detail/generate_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ namespace telnetpp::detail {
template <class Continuation>
constexpr void generate_escaped(telnetpp::bytes data, Continuation &&cont)
{
telnetpp::bytes::iterator begin = data.begin();
telnetpp::bytes::iterator current = data.begin();
telnetpp::bytes::iterator end = data.end();
telnetpp::bytes::iterator begin = data.begin();
telnetpp::bytes::iterator current = data.begin();
telnetpp::bytes::iterator end = data.end();

// If we come across an 0xFF byte in the data, then it must be repeated.
// We do this by splitting the span into two, one of which ends with the
// 0xFF byte and the second that begins with it. In this way, the byte is
// duplicated without requiring any extra allocations.
while (current != end)
{
if (*current == telnetpp::iac)
// If we come across an 0xFF byte in the data, then it must be repeated.
// We do this by splitting the span into two, one of which ends with the
// 0xFF byte and the second that begins with it. In this way, the byte is
// duplicated without requiring any extra allocations.
while (current != end)
{
cont({begin, current + 1});
begin = current;
}
if (*current == telnetpp::iac)
{
cont({begin, current + 1});
begin = current;
}

++current;
}
++current;
}

if (begin != end)
{
cont({begin, end});
}
if (begin != end)
{
cont({begin, end});
}
}

//* =========================================================================
Expand All @@ -41,9 +41,9 @@ constexpr void generate_escaped(telnetpp::bytes data, Continuation &&cont)
template <class Continuation>
constexpr void generate_command(telnetpp::command cmd, Continuation &&cont)
{
telnetpp::byte const data[] = {telnetpp::iac, cmd.value()};
telnetpp::byte const data[] = {telnetpp::iac, cmd.value()};

cont(data);
cont(data);
}

//* =========================================================================
Expand All @@ -53,10 +53,10 @@ template <class Continuation>
constexpr void generate_negotiation(
telnetpp::negotiation neg, Continuation &&cont)
{
telnetpp::byte const data[] = {
telnetpp::iac, neg.request(), neg.option_code()};
telnetpp::byte const data[] = {
telnetpp::iac, neg.request(), neg.option_code()};

cont(data);
cont(data);
}

//* =========================================================================
Expand All @@ -66,13 +66,14 @@ template <class Continuation>
constexpr void generate_subnegotiation(
telnetpp::subnegotiation sub, Continuation &&cont)
{
telnetpp::byte const preamble[] = {telnetpp::iac, telnetpp::sb, sub.option()};
telnetpp::byte const preamble[] = {
telnetpp::iac, telnetpp::sb, sub.option()};

constexpr telnetpp::byte const postamble[] = {telnetpp::iac, telnetpp::se};
constexpr telnetpp::byte const postamble[] = {telnetpp::iac, telnetpp::se};

cont(preamble);
generate_escaped(sub.content(), cont);
cont(postamble);
cont(preamble);
generate_escaped(sub.content(), cont);
cont(postamble);
}

} // namespace telnetpp::detail
Loading

0 comments on commit b96f5e3

Please sign in to comment.