From 996703dde6ef6ed9e4e7ef62b562899208202746 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sun, 9 Jun 2019 08:07:51 +0200 Subject: [PATCH] Make everything struct, never use class --- src/App.h | 2 +- src/AsyncSocket.h | 2 +- src/HttpContextData.h | 2 +- src/HttpParser.h | 6 +++--- src/HttpRouter.h | 6 +++--- src/TopicTree.h | 2 +- src/WebSocketContext.h | 2 +- src/WebSocketExtensions.h | 4 ++-- src/WebSocketHandshake.h | 2 +- src/WebSocketProtocol.h | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/App.h b/src/App.h index b2c5be4..98394f0 100644 --- a/src/App.h +++ b/src/App.h @@ -97,7 +97,7 @@ public: fu2::unique_function *, int, std::string_view)> close = nullptr; }; - template + template TemplatedApp &&ws(std::string pattern, WebSocketBehavior &&behavior) { /* Don't compile if alignment rules cannot be satisfied */ static_assert(alignof(UserData) <= LIBUS_EXT_ALIGNMENT, diff --git a/src/AsyncSocket.h b/src/AsyncSocket.h index 9afc157..bb950ed 100644 --- a/src/AsyncSocket.h +++ b/src/AsyncSocket.h @@ -29,7 +29,7 @@ template struct AsyncSocket { template friend struct HttpContext; template friend struct WebSocketContext; - friend class TopicTree; + friend struct TopicTree; /* For now, we don't even compile on GCC without this. FIX! */ /*protected*/public: diff --git a/src/HttpContextData.h b/src/HttpContextData.h index 33d4be5..bfea9c8 100644 --- a/src/HttpContextData.h +++ b/src/HttpContextData.h @@ -25,7 +25,7 @@ namespace uWS { template struct HttpResponse; -class HttpRequest; +struct HttpRequest; template struct alignas(16) HttpContextData { diff --git a/src/HttpParser.h b/src/HttpParser.h index fd3133d..ecb7471 100644 --- a/src/HttpParser.h +++ b/src/HttpParser.h @@ -32,9 +32,9 @@ namespace uWS { /* We require at least this much post padding */ static const int MINIMUM_HTTP_POST_PADDING = 32; -class HttpRequest { +struct HttpRequest { - friend class HttpParser; + friend struct HttpParser; private: const static int MAX_HEADERS = 50; @@ -126,7 +126,7 @@ public: }; -class HttpParser { +struct HttpParser { private: std::string fallback; diff --git a/src/HttpRouter.h b/src/HttpRouter.h index 95024f2..eb83513 100644 --- a/src/HttpRouter.h +++ b/src/HttpRouter.h @@ -35,14 +35,14 @@ namespace uWS { -template -class HttpRouter { +template +struct HttpRouter { private: static const unsigned int MAX_URL_SEGMENTS = 100; /* Basically a pre-allocated stack */ struct RouteParameters { - friend class HttpRouter; + friend struct HttpRouter; private: std::string_view params[MAX_URL_SEGMENTS]; int paramsTop; diff --git a/src/TopicTree.h b/src/TopicTree.h index 1ca3904..2b78e1c 100644 --- a/src/TopicTree.h +++ b/src/TopicTree.h @@ -34,7 +34,7 @@ namespace uWS { // publishing to a node, then another node, then another node should prioritize draining that way // sending and publishing will interleave undefined, they are separate streams -class TopicTree { +struct TopicTree { private: struct Node : std::map { /* Add and/or lookup node from topic */ diff --git a/src/WebSocketContext.h b/src/WebSocketContext.h index 1fb2b3b..66bd338 100644 --- a/src/WebSocketContext.h +++ b/src/WebSocketContext.h @@ -28,7 +28,7 @@ namespace uWS { template struct WebSocketContext { template friend struct TemplatedApp; - template friend class WebSocketProtocol; + template friend struct WebSocketProtocol; private: WebSocketContext() = delete; diff --git a/src/WebSocketExtensions.h b/src/WebSocketExtensions.h index 1d3adf9..51ac984 100644 --- a/src/WebSocketExtensions.h +++ b/src/WebSocketExtensions.h @@ -39,7 +39,7 @@ enum ExtensionTokens { TOK_CLIENT_MAX_WINDOW_BITS = 2348 }; -class ExtensionsParser { +struct ExtensionsParser { private: int *lastInteger = nullptr; @@ -102,7 +102,7 @@ public: }; template -class ExtensionsNegotiator { +struct ExtensionsNegotiator { protected: int options; diff --git a/src/WebSocketHandshake.h b/src/WebSocketHandshake.h index a4f2fb7..453473c 100644 --- a/src/WebSocketHandshake.h +++ b/src/WebSocketHandshake.h @@ -23,7 +23,7 @@ namespace uWS { -class WebSocketHandshake { +struct WebSocketHandshake { template struct static_for { void operator()(uint32_t *a, uint32_t *b) { diff --git a/src/WebSocketProtocol.h b/src/WebSocketProtocol.h index 020bb6d..3ffafd2 100644 --- a/src/WebSocketProtocol.h +++ b/src/WebSocketProtocol.h @@ -237,8 +237,8 @@ static inline size_t formatMessage(char *dst, const char *src, size_t length, Op } // essentially this is only a parser -template -class WIN32_EXPORT WebSocketProtocol { +template +struct WIN32_EXPORT WebSocketProtocol { public: static const unsigned int SHORT_MESSAGE_HEADER = isServer ? 6 : 2; static const unsigned int MEDIUM_MESSAGE_HEADER = isServer ? 8 : 4;