Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
Executable
+1
@@ -0,0 +1 @@
|
||||
nodejs/http-parser/v2.9.4
|
||||
Executable
+2480
File diff suppressed because it is too large.
Load diff
Executable
+380
@@ -0,0 +1,380 @@
|
||||
|
||||
|
||||
#ifndef http_parser_h
|
||||
#define http_parser_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define HTTP_PARSER_VERSION_MAJOR 2
|
||||
#define HTTP_PARSER_VERSION_MINOR 9
|
||||
#define HTTP_PARSER_VERSION_PATCH 4
|
||||
|
||||
#include <stddef.h>
|
||||
#if defined(_WIN32) && !defined(__MINGW32__) && \
|
||||
(!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__)
|
||||
#include <BaseTsd.h>
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef HTTP_PARSER_STRICT
|
||||
# define HTTP_PARSER_STRICT 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef HTTP_MAX_HEADER_SIZE
|
||||
# define HTTP_MAX_HEADER_SIZE (80*1024)
|
||||
#endif
|
||||
|
||||
typedef struct http_parser http_parser;
|
||||
typedef struct http_parser_settings http_parser_settings;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
|
||||
typedef int (*http_cb) (http_parser*);
|
||||
|
||||
|
||||
|
||||
#define HTTP_STATUS_MAP(XX) \
|
||||
XX(100, CONTINUE, Continue) \
|
||||
XX(101, SWITCHING_PROTOCOLS, Switching Protocols) \
|
||||
XX(102, PROCESSING, Processing) \
|
||||
XX(200, OK, OK) \
|
||||
XX(201, CREATED, Created) \
|
||||
XX(202, ACCEPTED, Accepted) \
|
||||
XX(203, NON_AUTHORITATIVE_INFORMATION, Non-Authoritative Information) \
|
||||
XX(204, NO_CONTENT, No Content) \
|
||||
XX(205, RESET_CONTENT, Reset Content) \
|
||||
XX(206, PARTIAL_CONTENT, Partial Content) \
|
||||
XX(207, MULTI_STATUS, Multi-Status) \
|
||||
XX(208, ALREADY_REPORTED, Already Reported) \
|
||||
XX(226, IM_USED, IM Used) \
|
||||
XX(300, MULTIPLE_CHOICES, Multiple Choices) \
|
||||
XX(301, MOVED_PERMANENTLY, Moved Permanently) \
|
||||
XX(302, FOUND, Found) \
|
||||
XX(303, SEE_OTHER, See Other) \
|
||||
XX(304, NOT_MODIFIED, Not Modified) \
|
||||
XX(305, USE_PROXY, Use Proxy) \
|
||||
XX(307, TEMPORARY_REDIRECT, Temporary Redirect) \
|
||||
XX(308, PERMANENT_REDIRECT, Permanent Redirect) \
|
||||
XX(400, BAD_REQUEST, Bad Request) \
|
||||
XX(401, UNAUTHORIZED, Unauthorized) \
|
||||
XX(402, PAYMENT_REQUIRED, Payment Required) \
|
||||
XX(403, FORBIDDEN, Forbidden) \
|
||||
XX(404, NOT_FOUND, Not Found) \
|
||||
XX(405, METHOD_NOT_ALLOWED, Method Not Allowed) \
|
||||
XX(406, NOT_ACCEPTABLE, Not Acceptable) \
|
||||
XX(407, PROXY_AUTHENTICATION_REQUIRED, Proxy Authentication Required) \
|
||||
XX(408, REQUEST_TIMEOUT, Request Timeout) \
|
||||
XX(409, CONFLICT, Conflict) \
|
||||
XX(410, GONE, Gone) \
|
||||
XX(411, LENGTH_REQUIRED, Length Required) \
|
||||
XX(412, PRECONDITION_FAILED, Precondition Failed) \
|
||||
XX(413, PAYLOAD_TOO_LARGE, Payload Too Large) \
|
||||
XX(414, URI_TOO_LONG, URI Too Long) \
|
||||
XX(415, UNSUPPORTED_MEDIA_TYPE, Unsupported Media Type) \
|
||||
XX(416, RANGE_NOT_SATISFIABLE, Range Not Satisfiable) \
|
||||
XX(417, EXPECTATION_FAILED, Expectation Failed) \
|
||||
XX(421, MISDIRECTED_REQUEST, Misdirected Request) \
|
||||
XX(422, UNPROCESSABLE_ENTITY, Unprocessable Entity) \
|
||||
XX(423, LOCKED, Locked) \
|
||||
XX(424, FAILED_DEPENDENCY, Failed Dependency) \
|
||||
XX(426, UPGRADE_REQUIRED, Upgrade Required) \
|
||||
XX(428, PRECONDITION_REQUIRED, Precondition Required) \
|
||||
XX(429, TOO_MANY_REQUESTS, Too Many Requests) \
|
||||
XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, Request Header Fields Too Large) \
|
||||
XX(451, UNAVAILABLE_FOR_LEGAL_REASONS, Unavailable For Legal Reasons) \
|
||||
XX(500, INTERNAL_SERVER_ERROR, Internal Server Error) \
|
||||
XX(501, NOT_IMPLEMENTED, Not Implemented) \
|
||||
XX(502, BAD_GATEWAY, Bad Gateway) \
|
||||
XX(503, SERVICE_UNAVAILABLE, Service Unavailable) \
|
||||
XX(504, GATEWAY_TIMEOUT, Gateway Timeout) \
|
||||
XX(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) \
|
||||
XX(506, VARIANT_ALSO_NEGOTIATES, Variant Also Negotiates) \
|
||||
XX(507, INSUFFICIENT_STORAGE, Insufficient Storage) \
|
||||
XX(508, LOOP_DETECTED, Loop Detected) \
|
||||
XX(510, NOT_EXTENDED, Not Extended) \
|
||||
XX(511, NETWORK_AUTHENTICATION_REQUIRED, Network Authentication Required) \
|
||||
|
||||
enum http_status
|
||||
{
|
||||
#define XX(num, name, string) HTTP_STATUS_##name = num,
|
||||
HTTP_STATUS_MAP(XX)
|
||||
#undef XX
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define HTTP_METHOD_MAP(XX) \
|
||||
XX(0, DELETE, DELETE) \
|
||||
XX(1, GET, GET) \
|
||||
XX(2, HEAD, HEAD) \
|
||||
XX(3, POST, POST) \
|
||||
XX(4, PUT, PUT) \
|
||||
\
|
||||
XX(5, CONNECT, CONNECT) \
|
||||
XX(6, OPTIONS, OPTIONS) \
|
||||
XX(7, TRACE, TRACE) \
|
||||
\
|
||||
XX(8, COPY, COPY) \
|
||||
XX(9, LOCK, LOCK) \
|
||||
XX(10, MKCOL, MKCOL) \
|
||||
XX(11, MOVE, MOVE) \
|
||||
XX(12, PROPFIND, PROPFIND) \
|
||||
XX(13, PROPPATCH, PROPPATCH) \
|
||||
XX(14, SEARCH, SEARCH) \
|
||||
XX(15, UNLOCK, UNLOCK) \
|
||||
XX(16, BIND, BIND) \
|
||||
XX(17, REBIND, REBIND) \
|
||||
XX(18, UNBIND, UNBIND) \
|
||||
XX(19, ACL, ACL) \
|
||||
\
|
||||
XX(20, REPORT, REPORT) \
|
||||
XX(21, MKACTIVITY, MKACTIVITY) \
|
||||
XX(22, CHECKOUT, CHECKOUT) \
|
||||
XX(23, MERGE, MERGE) \
|
||||
\
|
||||
XX(24, MSEARCH, M-SEARCH) \
|
||||
XX(25, NOTIFY, NOTIFY) \
|
||||
XX(26, SUBSCRIBE, SUBSCRIBE) \
|
||||
XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
|
||||
\
|
||||
XX(28, PATCH, PATCH) \
|
||||
XX(29, PURGE, PURGE) \
|
||||
\
|
||||
XX(30, MKCALENDAR, MKCALENDAR) \
|
||||
\
|
||||
XX(31, LINK, LINK) \
|
||||
XX(32, UNLINK, UNLINK) \
|
||||
\
|
||||
XX(33, SOURCE, SOURCE) \
|
||||
|
||||
enum http_method
|
||||
{
|
||||
#define XX(num, name, string) HTTP_##name = num,
|
||||
HTTP_METHOD_MAP(XX)
|
||||
#undef XX
|
||||
};
|
||||
|
||||
|
||||
enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
|
||||
|
||||
|
||||
|
||||
enum flags
|
||||
{ F_CHUNKED = 1 << 0
|
||||
, F_CONNECTION_KEEP_ALIVE = 1 << 1
|
||||
, F_CONNECTION_CLOSE = 1 << 2
|
||||
, F_CONNECTION_UPGRADE = 1 << 3
|
||||
, F_TRAILING = 1 << 4
|
||||
, F_UPGRADE = 1 << 5
|
||||
, F_SKIPBODY = 1 << 6
|
||||
, F_CONTENTLENGTH = 1 << 7
|
||||
, F_TRANSFER_ENCODING = 1 << 8
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#define HTTP_ERRNO_MAP(XX) \
|
||||
\
|
||||
XX(OK, "success") \
|
||||
\
|
||||
\
|
||||
XX(CB_message_begin, "the on_message_begin callback failed") \
|
||||
XX(CB_url, "the on_url callback failed") \
|
||||
XX(CB_header_field, "the on_header_field callback failed") \
|
||||
XX(CB_header_value, "the on_header_value callback failed") \
|
||||
XX(CB_headers_complete, "the on_headers_complete callback failed") \
|
||||
XX(CB_body, "the on_body callback failed") \
|
||||
XX(CB_message_complete, "the on_message_complete callback failed") \
|
||||
XX(CB_status, "the on_status callback failed") \
|
||||
XX(CB_chunk_header, "the on_chunk_header callback failed") \
|
||||
XX(CB_chunk_complete, "the on_chunk_complete callback failed") \
|
||||
\
|
||||
\
|
||||
XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
|
||||
XX(HEADER_OVERFLOW, \
|
||||
"too many header bytes seen; overflow detected") \
|
||||
XX(CLOSED_CONNECTION, \
|
||||
"data received after completed connection: close message") \
|
||||
XX(INVALID_VERSION, "invalid HTTP version") \
|
||||
XX(INVALID_STATUS, "invalid HTTP status code") \
|
||||
XX(INVALID_METHOD, "invalid HTTP method") \
|
||||
XX(INVALID_URL, "invalid URL") \
|
||||
XX(INVALID_HOST, "invalid host") \
|
||||
XX(INVALID_PORT, "invalid port") \
|
||||
XX(INVALID_PATH, "invalid path") \
|
||||
XX(INVALID_QUERY_STRING, "invalid query string") \
|
||||
XX(INVALID_FRAGMENT, "invalid fragment") \
|
||||
XX(LF_EXPECTED, "LF character expected") \
|
||||
XX(INVALID_HEADER_TOKEN, "invalid character in header") \
|
||||
XX(INVALID_CONTENT_LENGTH, \
|
||||
"invalid character in content-length header") \
|
||||
XX(UNEXPECTED_CONTENT_LENGTH, \
|
||||
"unexpected content-length header") \
|
||||
XX(INVALID_CHUNK_SIZE, \
|
||||
"invalid character in chunk size header") \
|
||||
XX(INVALID_CONSTANT, "invalid constant string") \
|
||||
XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
|
||||
XX(STRICT, "strict mode assertion failed") \
|
||||
XX(PAUSED, "parser is paused") \
|
||||
XX(UNKNOWN, "an unknown error occurred") \
|
||||
XX(INVALID_TRANSFER_ENCODING, \
|
||||
"request has invalid transfer-encoding") \
|
||||
|
||||
|
||||
|
||||
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
|
||||
enum http_errno {
|
||||
HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
|
||||
};
|
||||
#undef HTTP_ERRNO_GEN
|
||||
|
||||
|
||||
|
||||
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
|
||||
|
||||
|
||||
struct http_parser {
|
||||
|
||||
unsigned int type : 2;
|
||||
unsigned int flags : 8;
|
||||
unsigned int state : 7;
|
||||
unsigned int header_state : 7;
|
||||
unsigned int index : 5;
|
||||
unsigned int extra_flags : 2;
|
||||
unsigned int lenient_http_headers : 1;
|
||||
|
||||
uint32_t nread;
|
||||
uint64_t content_length;
|
||||
|
||||
|
||||
unsigned short http_major;
|
||||
unsigned short http_minor;
|
||||
unsigned int status_code : 16;
|
||||
unsigned int method : 8;
|
||||
unsigned int http_errno : 7;
|
||||
|
||||
|
||||
|
||||
unsigned int upgrade : 1;
|
||||
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
||||
|
||||
struct http_parser_settings {
|
||||
http_cb on_message_begin;
|
||||
http_data_cb on_url;
|
||||
http_data_cb on_status;
|
||||
http_data_cb on_header_field;
|
||||
http_data_cb on_header_value;
|
||||
http_cb on_headers_complete;
|
||||
http_data_cb on_body;
|
||||
http_cb on_message_complete;
|
||||
|
||||
|
||||
http_cb on_chunk_header;
|
||||
http_cb on_chunk_complete;
|
||||
};
|
||||
|
||||
|
||||
enum http_parser_url_fields
|
||||
{ UF_SCHEMA = 0
|
||||
, UF_HOST = 1
|
||||
, UF_PORT = 2
|
||||
, UF_PATH = 3
|
||||
, UF_QUERY = 4
|
||||
, UF_FRAGMENT = 5
|
||||
, UF_USERINFO = 6
|
||||
, UF_MAX = 7
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct http_parser_url {
|
||||
uint16_t field_set;
|
||||
uint16_t port;
|
||||
|
||||
struct {
|
||||
uint16_t off;
|
||||
uint16_t len;
|
||||
} field_data[UF_MAX];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned long http_parser_version(void);
|
||||
|
||||
void http_parser_init(http_parser *parser, enum http_parser_type type);
|
||||
|
||||
|
||||
|
||||
|
||||
void http_parser_settings_init(http_parser_settings *settings);
|
||||
|
||||
|
||||
|
||||
|
||||
size_t http_parser_execute(http_parser *parser,
|
||||
const http_parser_settings *settings,
|
||||
const char *data,
|
||||
size_t len);
|
||||
|
||||
|
||||
|
||||
|
||||
int http_should_keep_alive(const http_parser *parser);
|
||||
|
||||
|
||||
const char *http_method_str(enum http_method m);
|
||||
|
||||
|
||||
const char *http_status_str(enum http_status s);
|
||||
|
||||
|
||||
const char *http_errno_name(enum http_errno err);
|
||||
|
||||
|
||||
const char *http_errno_description(enum http_errno err);
|
||||
|
||||
|
||||
void http_parser_url_init(struct http_parser_url *u);
|
||||
|
||||
|
||||
int http_parser_parse_url(const char *buf, size_t buflen,
|
||||
int is_connect,
|
||||
struct http_parser_url *u);
|
||||
|
||||
|
||||
void http_parser_pause(http_parser *parser, int paused);
|
||||
|
||||
|
||||
int http_body_is_final(const http_parser *parser);
|
||||
|
||||
|
||||
void http_parser_set_max_header_size(uint32_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <httq/httq_export.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QHostAddress>
|
||||
|
||||
|
||||
class QTcpServer;
|
||||
class QWebSocketServer;
|
||||
|
||||
|
||||
namespace httq
|
||||
{
|
||||
class HttpRequest;
|
||||
class LoggerFactory;
|
||||
class Logger;
|
||||
|
||||
|
||||
class HTTQ_EXPORT AbstractServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractServer(QObject *parent = nullptr);
|
||||
|
||||
virtual bool newHttpConnection(HttpRequest *request) = 0;
|
||||
virtual QWebSocketServer *webSocketServer() const { return nullptr; }
|
||||
virtual LoggerFactory *createLoggerFactory();
|
||||
LoggerFactory *getLoggerFactory();
|
||||
bool listen(qint16 port, const QHostAddress &host = QHostAddress::Any);
|
||||
|
||||
private slots:
|
||||
void slotNewConnection();
|
||||
|
||||
private:
|
||||
QTcpServer *mSvr;
|
||||
LoggerFactory *mLoggerFactory { nullptr };
|
||||
Logger *mLogger;
|
||||
};
|
||||
}
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <httq/httq_export.h>
|
||||
#include <httq/Logger.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
|
||||
|
||||
class QIODevice;
|
||||
|
||||
|
||||
namespace httq
|
||||
{
|
||||
class HttpRequest;
|
||||
|
||||
class HTTQ_EXPORT DataStream : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
explicit DataStream(QIODevice *from, QIODevice *to, const QByteArray &bodyPartial,
|
||||
qint64 fileLength, size_t bufferSize, LoggerFactory *loggerFactory,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
~DataStream();
|
||||
|
||||
private:
|
||||
friend class HttpRequest;
|
||||
|
||||
void readNext();
|
||||
void writeNext();
|
||||
|
||||
bool mReadyWrite { true };
|
||||
|
||||
QByteArray mBuffer;
|
||||
QByteArray mBodyPartial;
|
||||
QIODevice *mFrom;
|
||||
QIODevice *mTo;
|
||||
|
||||
qint64 mBufferSize;
|
||||
qint64 alreadyRead { 0 };
|
||||
qint64 mFileLength;
|
||||
bool mFromSupportsSignals { false };
|
||||
bool mToSupportsSignals { false };
|
||||
QScopedPointer<Logger> mLogger;
|
||||
|
||||
signals:
|
||||
void signalDone();
|
||||
|
||||
};
|
||||
}
|
||||
Executable
+112
@@ -0,0 +1,112 @@
|
||||
#pragma once
|
||||
|
||||
#include <httq/httq_export.h>
|
||||
#include <http_parser.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QUrl>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QUrlQuery>
|
||||
|
||||
|
||||
class QTcpSocket;
|
||||
class QIODevice;
|
||||
|
||||
|
||||
namespace httq
|
||||
{
|
||||
class AbstractServer;
|
||||
class Logger;
|
||||
class DataStream;
|
||||
class HttpRequest;
|
||||
|
||||
|
||||
struct HttpRequestData
|
||||
{
|
||||
QByteArray mData;
|
||||
QUrl mUrl;
|
||||
QString mCurrentHeaderField;
|
||||
QMap<QString, QString> mHeaders;
|
||||
bool mDone { false };
|
||||
QByteArray mBodyPartial;
|
||||
QUrlQuery mQuery;
|
||||
HttpRequest *mHttpRquest;
|
||||
};
|
||||
|
||||
|
||||
class HTTQ_EXPORT HttpRequest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
explicit HttpRequest(QTcpSocket *cli, AbstractServer *parent = nullptr);
|
||||
public:
|
||||
~HttpRequest();
|
||||
|
||||
qint64 availableBytes() const;
|
||||
http_method method() const { return (enum http_method)mParser.method; }
|
||||
QString methodString() const { return QString::fromUtf8(http_method_str(method())); }
|
||||
const QUrl &url() const { return mData.mUrl; }
|
||||
const QUrlQuery &query() const { return mData.mQuery; }
|
||||
qint64 contentLength() const { return mContentLength; }
|
||||
const QMap<QString, QString> &requestHeaders() const { return mData.mHeaders; }
|
||||
|
||||
|
||||
Logger *logger() { return mLogger; }
|
||||
QString toString() const;
|
||||
|
||||
|
||||
void addHeader(const QString &key, const QString &value);
|
||||
void write(int status, const QByteArray &data, const QString &contentType);
|
||||
void write(int status, const QJsonValue &jsonValue);
|
||||
DataStream *createDataStreamFromClient(QIODevice *to, qint64 fileSize, qint64 bufferSize = 1024 * 1024);
|
||||
DataStream *createDataStreamToClient(int status, const QString &contentType, QIODevice *from, qint64 fileSize, qint64 bufferSize = 1024 * 1024);
|
||||
|
||||
friend class DataStream;
|
||||
|
||||
|
||||
private:
|
||||
friend class AbstractServer;
|
||||
|
||||
|
||||
void writeStatusHeader(int status);
|
||||
void writeHeaders();
|
||||
|
||||
static int on_message_begin(http_parser *parser);
|
||||
static int on_url(http_parser *parser, const char *at, size_t length);
|
||||
static int on_status(http_parser *parser, const char *at, size_t length);
|
||||
static int on_header_field(http_parser *parser, const char *at, size_t length);
|
||||
static int on_header_value(http_parser *parser, const char *at, size_t length);
|
||||
static int on_headers_complete(http_parser *parser);
|
||||
static int on_body(http_parser *parser, const char *at, size_t length);
|
||||
static int on_message_complete(http_parser *parser);
|
||||
static int on_chunk_header(http_parser *parser);
|
||||
static int on_chunk_complete(http_parser *parser);
|
||||
|
||||
static HttpRequestData *data(http_parser *parser) { return static_cast<HttpRequestData *>(parser->data); }
|
||||
static Logger *dataLogger(http_parser *parser) { return static_cast<HttpRequestData *>(parser->data)->mHttpRquest->logger(); }
|
||||
|
||||
|
||||
QTcpSocket *mCli;
|
||||
http_parser mParser;
|
||||
http_parser_settings mParserSettings;
|
||||
HttpRequestData mData;
|
||||
bool mDone { false };
|
||||
qint64 mContentLength { 0 };
|
||||
qint64 alreadyRead { 0 };
|
||||
QMap<QString, QString> mHeaders;
|
||||
Logger *mLogger;
|
||||
|
||||
|
||||
private slots:
|
||||
void slotReadyRead();
|
||||
|
||||
|
||||
signals:
|
||||
void signalUpgrade(QTcpSocket *sock);
|
||||
void signalReady();
|
||||
|
||||
};
|
||||
}
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <httq/httq_export.h>
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
namespace httq
|
||||
{
|
||||
class Logger;
|
||||
|
||||
|
||||
class HTTQ_EXPORT LoggerFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LoggerFactory(QObject *parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
virtual Logger *createLogger(QObject *parent);
|
||||
};
|
||||
|
||||
|
||||
class HTTQ_EXPORT Logger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Logger(LoggerFactory *loggerFactory, QObject *parent);
|
||||
|
||||
virtual void debug(const QString &message);
|
||||
virtual void warning(const QString &message);
|
||||
virtual void error(const QString &message);
|
||||
|
||||
virtual LoggerFactory *getLoggerFactory() const
|
||||
{
|
||||
Q_ASSERT(mLoggerFactory);
|
||||
return mLoggerFactory;
|
||||
}
|
||||
|
||||
protected:
|
||||
QPointer<LoggerFactory> mLoggerFactory;
|
||||
|
||||
private:
|
||||
QDebug qtLogger(const QString &type, QDebug debug);
|
||||
|
||||
QString mPath;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user