Coding Standard

Spacing
    Self-Sufficient Headers
This commit is contained in:
Clement 2018-05-18 15:02:57 -07:00
parent e096ff91f6
commit 19100c9550
3 changed files with 18 additions and 16 deletions

View file

@ -9,11 +9,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "Application.h"
#include "SecondaryCamera.h" #include "SecondaryCamera.h"
#include <TextureCache.h>
#include <gpu/Context.h>
#include <glm/gtx/transform.hpp> #include <glm/gtx/transform.hpp>
#include <gpu/Context.h>
#include <TextureCache.h>
#include "Application.h"
using RenderArgsPointer = std::shared_ptr<RenderArgs>; using RenderArgsPointer = std::shared_ptr<RenderArgs>;

View file

@ -29,7 +29,7 @@ const char* HTTPConnection::StatusCode404 = "404 Not Found";
const char* HTTPConnection::StatusCode500 = "500 Internal server error"; const char* HTTPConnection::StatusCode500 = "500 Internal server error";
const char* HTTPConnection::DefaultContentType = "text/plain; charset=ISO-8859-1"; const char* HTTPConnection::DefaultContentType = "text/plain; charset=ISO-8859-1";
HTTPConnection::HTTPConnection (QTcpSocket* socket, HTTPManager* parentManager) : HTTPConnection::HTTPConnection(QTcpSocket* socket, HTTPManager* parentManager) :
QObject(parentManager), QObject(parentManager),
_parentManager(parentManager), _parentManager(parentManager),
_socket(socket), _socket(socket),

View file

@ -58,51 +58,51 @@ public:
enum ReasonCode { NoReason = 0, NormalClosure = 1000, GoingAway = 1001 }; enum ReasonCode { NoReason = 0, NormalClosure = 1000, GoingAway = 1001 };
/// Initializes the connection. /// Initializes the connection.
HTTPConnection (QTcpSocket* socket, HTTPManager* parentManager); HTTPConnection(QTcpSocket* socket, HTTPManager* parentManager);
/// Destroys the connection. /// Destroys the connection.
virtual ~HTTPConnection (); virtual ~HTTPConnection();
/// Returns a pointer to the underlying socket, to which WebSocket message bodies should be written. /// Returns a pointer to the underlying socket, to which WebSocket message bodies should be written.
QTcpSocket* socket () const { return _socket; } QTcpSocket* socket() const { return _socket; }
/// Returns the request operation. /// Returns the request operation.
QNetworkAccessManager::Operation requestOperation () const { return _requestOperation; } QNetworkAccessManager::Operation requestOperation() const { return _requestOperation; }
/// Returns a reference to the request URL. /// Returns a reference to the request URL.
const QUrl& requestUrl () const { return _requestUrl; } const QUrl& requestUrl() const { return _requestUrl; }
/// Returns a copy of the request header value. If it does not exist, it will return a default constructed QByteArray. /// Returns a copy of the request header value. If it does not exist, it will return a default constructed QByteArray.
QByteArray requestHeader(const QString& key) const { return _requestHeaders.value(key.toLower().toLocal8Bit()); } QByteArray requestHeader(const QString& key) const { return _requestHeaders.value(key.toLower().toLocal8Bit()); }
/// Returns a reference to the request content. /// Returns a reference to the request content.
const QByteArray& requestContent () const { return _requestContent; } const QByteArray& requestContent() const { return _requestContent; }
/// Parses the request content as form data, returning a list of header/content pairs. /// Parses the request content as form data, returning a list of header/content pairs.
QList<FormData> parseFormData () const; QList<FormData> parseFormData() const;
/// Parses the request content as a url encoded form, returning a hash of key/value pairs. /// Parses the request content as a url encoded form, returning a hash of key/value pairs.
/// Duplicate keys are not supported. /// Duplicate keys are not supported.
QHash<QString, QString> parseUrlEncodedForm(); QHash<QString, QString> parseUrlEncodedForm();
/// Sends a response and closes the connection. /// Sends a response and closes the connection.
void respond (const char* code, const QByteArray& content = QByteArray(), void respond(const char* code, const QByteArray& content = QByteArray(),
const char* contentType = DefaultContentType, const char* contentType = DefaultContentType,
const Headers& headers = Headers()); const Headers& headers = Headers());
void respond (const char* code, std::unique_ptr<QIODevice> device, void respond(const char* code, std::unique_ptr<QIODevice> device,
const char* contentType = DefaultContentType, const char* contentType = DefaultContentType,
const Headers& headers = Headers()); const Headers& headers = Headers());
protected slots: protected slots:
/// Reads the request line. /// Reads the request line.
void readRequest (); void readRequest();
/// Reads the headers. /// Reads the headers.
void readHeaders (); void readHeaders();
/// Reads the content. /// Reads the content.
void readContent (); void readContent();
protected: protected:
void respondWithStatusAndHeaders(const char* code, const char* contentType, const Headers& headers, qint64 size); void respondWithStatusAndHeaders(const char* code, const char* contentType, const Headers& headers, qint64 size);