Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
Config.h
浏览该文件的文档.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
22#pragma once
23
24#include <cassert>
25#include <cinttypes>
26#include <algorithm>
27#include <string>
28#include <sese/util/Memory.h>
30
31// namespace alias
32namespace sese {
33namespace sys = sese::system;
34}
35
36#ifdef _WIN32
37#pragma warning(disable : 4819)
38#define SESE_PLATFORM_WINDOWS
40#elif __linux__
41#define SESE_PLATFORM_LINUX
43#elif __APPLE__
44#define SESE_PLATFORM_APPLE
46#endif
47
48#define SESE_MARCO_END \
49 switch (0) \
50 case 0: \
51 default: \
52 break
53
54#define SESE_STD_WRAPPER(name, member) \
55 [[nodiscard]] auto name() const { return member.name(); }
56
57#if defined(__MINGW32__) || defined(__GNUC__)
58#define SESE_DEPRECATED __attribute__((deprecated))
59#define SESE_DEPRECATED_WITH(x) SESE_DEPRECATED
60#else
61#define SESE_DEPRECATED [[deprecated]]
62#define SESE_DEPRECATED_WITH(x) [[deprecated(x)]]
63#endif /* __MINGW32__ */
64
65#if defined(_MSC_VER)
66#define SESE_ALWAYS_INLINE __forceinline
67#elif defined(__clang__)
68#define SESE_ALWAYS_INLINE inline __attribute__((always_inline))
69#elif defined(__GNUC__)
70#define SESE_ALWAYS_INLINE inline __attribute__((always_inline))
71#else
72#endif
73
75static constexpr int32_t TIME_DEFAULT_ZONE = 8;
77static constexpr const char *TIME_DEFAULT_PATTERN = "UTCz yyyy-MM-dd HH:mm:ss.ff";
79static constexpr const char *TIME_GREENWICH_MEAN_PATTERN = "ddd, dd MMM yyyy HH:mm:ss %G%M%T";
81static constexpr const char *TIME_SHORT_PATTERN = "yyyy-MM-dd%THH:mm:ss.ff%Z";
82
84static constexpr size_t STRING_BUFFER_SIZE_FACTOR = 1024;
86static constexpr const char *SPACE_CHARS = " \n\r\t\v\b";
87
89static constexpr const char *THREAD_DEFAULT_NAME = "UNKNOWN";
91static constexpr const char *THREAD_MAIN_NAME = "Main";
92
94static constexpr size_t RECORD_OUTPUT_BUFFER = 4096;
96#ifndef SESE_RECORD_TIME_PATTERN
97static constexpr const char *RECORD_DEFAULT_TIME_PATTERN = TIME_SHORT_PATTERN;
98#else
99static constexpr const char *RECORD_DEFAULT_TIME_PATTERN = SESE_RECORD_TIME_PATTERN;
100#endif
102#ifndef SESE_RECORD_TEXT_PATTERN
103static constexpr const char *RECORD_DEFAULT_TEXT_PATTERN = "c lv fn:li tn:th> m\n";
104#else
105static constexpr const char *RECORD_DEFAULT_TEXT_PATTERN = SESE_RECORD_TEXT_PATTERN;
106#endif
108static constexpr const char *RECORD_DEFAULT_FILE_TIME_PATTERN = "yyyyMMdd HHmmssff";
110static constexpr const size_t RECORD_BUFFER_SIZE = 4096;
111
113static constexpr const size_t STREAM_BYTE_STREAM_SIZE_FACTOR = 1024;
114
116#ifdef SESE_IS_DEBUG
117static constexpr bool ENABLE_TEST = true;
118#else
119static constexpr bool ENABLE_TEST = false;
120#endif
121
123static constexpr size_t TIMER_WHEEL_NUMBER = 30;
124
126static constexpr size_t SERVER_DEFAULT_THREADS = 4;
128static constexpr size_t SERVER_MAX_CONNECTION = 511;
130static constexpr size_t SERVER_KEEP_ALIVE_DURATION = 10;
131
133static constexpr size_t HTTP_MAX_SINGLE_LINE = 1023;
135static constexpr const char *HTTPD_NAME = "sese::service::HttpServer";
137static constexpr const char *HTTPD_BOUNDARY = "000000SESE0BOUNDARY000000";
139static constexpr const char *HTTP_CLIENT_NAME = "sese::net::http::HttpClient";
140
142static constexpr size_t ZLIB_CHUNK_SIZE = 1024 * 16;
143
145static constexpr size_t IOCP_WSABUF_SIZE = 65535;
146
148static constexpr size_t MTU_VALUE = 1472;
150static constexpr size_t DNS_PACKAGE_SIZE = 512;