Skip to content

Commit ff71ce9

Browse files
ArthapzMorganCaron
authored andcommitted
run clang-format on whole project
1 parent dd8285f commit ff71ce9

13 files changed

Lines changed: 196 additions & 175 deletions

File tree

modules/Container/BidirectionalMap.mpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export namespace CppUtils::Container
4343
{
4444
return std::begin(values);
4545
}
46-
[[nodiscard]] constexpr inline auto begin() -> decltype(auto)
46+
[[nodiscard]] inline constexpr auto begin() -> decltype(auto)
4747
{
4848
return std::begin(values);
4949
}
@@ -62,7 +62,7 @@ export namespace CppUtils::Container
6262
{
6363
return std::end(values);
6464
}
65-
[[nodiscard]] constexpr inline auto end() -> decltype(auto)
65+
[[nodiscard]] inline constexpr auto end() -> decltype(auto)
6666
{
6767
return std::end(values);
6868
}
@@ -72,12 +72,12 @@ export namespace CppUtils::Container
7272
return std::cend(values);
7373
}
7474

75-
[[nodiscard]] constexpr inline auto empty() const noexcept -> bool
75+
[[nodiscard]] inline constexpr auto empty() const noexcept -> bool
7676
{
7777
return std::empty(values);
7878
}
7979

80-
[[nodiscard]] constexpr inline auto size() const noexcept -> std::size_t
80+
[[nodiscard]] inline constexpr auto size() const noexcept -> std::size_t
8181
{
8282
return std::size(values);
8383
}

modules/Container/MeshNetwork.mpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export namespace CppUtils::Container
3030
auto& childs = branches[key1];
3131
if (auto it = std::find_if(std::cbegin(childs), std::cend(childs), [&](const auto& child) -> bool {
3232
return std::shared_ptr{child} == node1;
33-
}); it != std::cend(childs))
33+
});
34+
it != std::cend(childs))
3435
childs.erase(it);
3536
if (std::empty(childs))
3637
branches.erase(key1);

modules/Container/Pair.mpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import std;
55
export namespace CppUtils::Container
66
{
77
template<class Lhs, class Rhs>
8-
[[nodiscard]] constexpr inline auto swapPair(std::pair<Lhs, Rhs>&& pair) noexcept -> std::pair<Rhs, Lhs>
8+
[[nodiscard]] inline constexpr auto swapPair(std::pair<Lhs, Rhs>&& pair) noexcept -> std::pair<Rhs, Lhs>
99
{
1010
return std::pair<Rhs, Lhs>{std::move(pair.second), std::move(pair.first)};
1111
}
1212

1313
template<class Lhs, class Rhs>
14-
[[nodiscard]] constexpr inline auto swapPair(const std::pair<Lhs, Rhs>& pair) noexcept -> std::pair<Rhs, Lhs>
14+
[[nodiscard]] inline constexpr auto swapPair(const std::pair<Lhs, Rhs>& pair) noexcept -> std::pair<Rhs, Lhs>
1515
{
1616
return std::pair<Rhs, Lhs>{pair.second, pair.first};
1717
}

modules/Log/TreeNodeLogger.mpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export namespace CppUtils::Log
88
class TreeNodeLogger final
99
{
1010
public:
11-
[[nodiscard]] inline static constexpr char getDifferenceChar(Container::Sequence::Difference difference) noexcept
11+
[[nodiscard]] static inline constexpr char getDifferenceChar(Container::Sequence::Difference difference) noexcept
1212
{
1313
switch (difference)
1414
{
@@ -23,7 +23,7 @@ export namespace CppUtils::Log
2323
}
2424
}
2525

26-
[[nodiscard]] inline static constexpr Terminal::TextColor::TextColorEnum getDifferenceColor(Container::Sequence::Difference difference) noexcept
26+
[[nodiscard]] static inline constexpr Terminal::TextColor::TextColorEnum getDifferenceColor(Container::Sequence::Difference difference) noexcept
2727
{
2828
switch (difference)
2929
{

modules/Network/Socket.mpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module;
44

55
#if defined(OS_WINDOWS)
66
# include <winsock2.h>
7-
# include <ws2tcpip.h> // for socklen_t
7+
# include <ws2tcpip.h> // for socklen_t
88
#elif defined(OS_LINUX)
99
# include <sys/socket.h>
1010
# include <netinet/in.h>
@@ -69,13 +69,12 @@ export namespace CppUtils::Network
6969
class Socket
7070
{
7171
public:
72+
#if defined(OS_WINDOWS)
73+
using NativeSocket = SOCKET;
74+
#elif defined(OS_LINUX)
75+
using NativeSocket = int;
76+
#endif
7277

73-
#if defined(OS_WINDOWS)
74-
using NativeSocket = SOCKET;
75-
#elif defined(OS_LINUX)
76-
using NativeSocket = int;
77-
#endif
78-
7978
enum class Domain : int
8079
{
8180
IPV4 = AF_INET,
@@ -183,7 +182,7 @@ export namespace CppUtils::Network
183182
int flags = ::fcntl(m_socket, F_GETFL, 0);
184183
if (flags == -1)
185184
throw std::runtime_error{"CppUtils::Network::Socket::isBlocking: Failed to get socket flags"};
186-
return not (flags & O_NONBLOCK);
185+
return not(flags & O_NONBLOCK);
187186
#endif
188187
}
189188

@@ -199,9 +198,9 @@ export namespace CppUtils::Network
199198
timeValue.tv_usec = std::chrono::duration_cast<std::chrono::microseconds>(timeout % 1s).count();
200199

201200
#ifdef OS_WINDOWS
202-
// TODO make implementation for windows
203-
// @see https://stackoverflow.com/questions/72759272/how-to-deal-with-socket-in-select-method
204-
auto result = -1;
201+
// TODO make implementation for windows
202+
// @see https://stackoverflow.com/questions/72759272/how-to-deal-with-socket-in-select-method
203+
auto result = -1;
205204
#else
206205
auto result = select(m_socket + 1, &readSet, nullptr, nullptr, &timeValue);
207206
#endif
@@ -214,9 +213,9 @@ export namespace CppUtils::Network
214213
inline auto setSocketOption(NativeSocket socket, int level, int option, const void* value, std::size_t valueSize) const noexcept -> bool
215214
{
216215
#if defined(OS_WINDOWS)
217-
return not ::setsockopt(socket, level, option, reinterpret_cast<const char*>(value), static_cast<int>(valueSize));
216+
return not::setsockopt(socket, level, option, reinterpret_cast<const char*>(value), static_cast<int>(valueSize));
218217
#else
219-
return not ::setsockopt(socket, level, option, value, static_cast<socklen_t>(valueSize));
218+
return not::setsockopt(socket, level, option, value, static_cast<socklen_t>(valueSize));
220219
#endif
221220
}
222221

@@ -281,7 +280,7 @@ export namespace CppUtils::Network
281280
{
282281
for (auto totalSent = 0uz; totalSent < std::size(data);)
283282
#ifdef OS_WINDOWS
284-
if (auto bytesSent = ::send(m_socket, std::bit_cast<const char *>(std::data(data)) + totalSent, static_cast<int>(std::size(data) - totalSent), 0);
283+
if (auto bytesSent = ::send(m_socket, std::bit_cast<const char*>(std::data(data)) + totalSent, static_cast<int>(std::size(data) - totalSent), 0);
285284
#else
286285
if (auto bytesSent = ::send(m_socket, std::data(data) + totalSent, std::size(data) - totalSent, 0);
287286
#endif
@@ -358,7 +357,7 @@ export namespace CppUtils::Network
358357
for (auto totalBytesReceived = 0uz; totalBytesReceived < bufferSize;)
359358
{
360359
#if defined(OS_WINDOWS)
361-
auto bytesReceived = ::recv(m_socket, std::bit_cast<char *>(std::data(buffer)) + totalBytesReceived, static_cast<int>(bufferSize - totalBytesReceived), 0);
360+
auto bytesReceived = ::recv(m_socket, std::bit_cast<char*>(std::data(buffer)) + totalBytesReceived, static_cast<int>(bufferSize - totalBytesReceived), 0);
362361
#else
363362
auto bytesReceived = ::recv(m_socket, std::data(buffer) + totalBytesReceived, bufferSize - totalBytesReceived, 0);
364363
#endif

modules/System/Error.mpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export namespace CppUtils::System
4949
{
5050
if (value == 0) [[likely]]
5151
return value;
52-
52+
5353
return std::unexpected(std::runtime_error{
5454
std::empty(message) ?
5555
std::format("{}", GetLastError()) :

modules/System/SharedLibrary.mpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export namespace CppUtils::System
8181
#endif
8282
}
8383

84-
template<Type::Function Function = void(*)()>
84+
template<Type::Function Function = void (*)()>
8585
[[nodiscard]] inline auto getFunction(std::string_view signature) -> Function
8686
{
8787
using namespace std::literals;

modules/Terminal/TextModifier.mpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export namespace CppUtils::Terminal
7070
return info.wAttributes;
7171
}
7272

73-
[[nodiscard]] inline static auto getTextColor(std::ostream& stream) -> std::uint16_t
73+
[[nodiscard]] static inline auto getTextColor(std::ostream& stream) -> std::uint16_t
7474
{
7575
CONSOLE_SCREEN_BUFFER_INFO info;
7676
if (!GetConsoleScreenBufferInfo(getTerminalHandle(stream), &info))

modules/Thread/ThreadPool.mpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export namespace CppUtils::Thread
2929
worker.stop();
3030
}
3131

32-
template<typename Func, typename ... Args>
32+
template<typename Func, typename... Args>
3333
inline auto call(Func&& function, Args&&... args) -> std::future<std::invoke_result_t<Func, Args...>>
3434
{
3535
using ReturnType = std::invoke_result_t<Func, Args...>;

modules/Thread/TryAsync.mpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,25 @@ import std;
44

55
export namespace CppUtils::Thread
66
{
7-
[[nodiscard]] inline auto tryAsync(auto&& function, auto&&... args) -> decltype(auto)
8-
{
9-
return std::async(std::launch::async, [function = std::forward<decltype(function)>(function), ...args = std::forward<decltype(args)>(args)]() mutable
10-
-> std::expected<std::invoke_result_t<decltype(function), decltype(args)...>, std::runtime_error> {
11-
try
12-
{
13-
if constexpr (std::is_void_v<std::invoke_result_t<decltype(function), decltype(args)...>>)
14-
function(std::forward<decltype(args)>(args)...);
15-
else
16-
return function(std::forward<decltype(args)>(args)...);
17-
}
18-
catch (const std::exception& exception)
19-
{
20-
return std::unexpected{std::runtime_error{exception.what()}};
21-
}
22-
catch (...)
23-
{
24-
return std::unexpected{std::runtime_error{"Unknown exception occurred"}};
25-
}
26-
return {};
27-
});
28-
}
7+
[[nodiscard]] inline auto tryAsync(auto&& function, auto&&... args) -> decltype(auto)
8+
{
9+
return std::async(std::launch::async, [function = std::forward<decltype(function)>(function), ... args = std::forward<decltype(args)>(args)]() mutable -> std::expected<std::invoke_result_t<decltype(function), decltype(args)...>, std::runtime_error> {
10+
try
11+
{
12+
if constexpr (std::is_void_v<std::invoke_result_t<decltype(function), decltype(args)...>>)
13+
function(std::forward<decltype(args)>(args)...);
14+
else
15+
return function(std::forward<decltype(args)>(args)...);
16+
}
17+
catch (const std::exception& exception)
18+
{
19+
return std::unexpected{std::runtime_error{exception.what()}};
20+
}
21+
catch (...)
22+
{
23+
return std::unexpected{std::runtime_error{"Unknown exception occurred"}};
24+
}
25+
return {};
26+
});
27+
}
2928
}

0 commit comments

Comments
 (0)