code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
package com.example.demo3_viewpager2.fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.fragment.app.Fragment; import com.example.demo3_viewpager2.R; /** * A simple {@link Fragment} subclass. * Use the {@link CFragment#ne...
2201_75403000/MediaWatch_APP
demo3_viewpager2/src/main/java/com/example/demo3_viewpager2/fragment/CFragment.java
Java
unknown
2,054
package com.example.demo3_viewpager2.fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.fragment.app.Fragment; import com.example.demo3_viewpager2.R; /** * A simple {@link Fragment} subclass. * Use the {@link DFragment#ne...
2201_75403000/MediaWatch_APP
demo3_viewpager2/src/main/java/com/example/demo3_viewpager2/fragment/DFragment.java
Java
unknown
2,054
import pandas as pd import math import numpy as np '''在小偏心计算中,获取符合条件的相对受压区计算高度,同时返回远端钢筋的压(拉)力''' def cal_bs(roots,eb,fy): for i in roots: if i>eb and i<=1: x = i if x <= 1.6-eb: return [fy*((0.8-x)/(0.8-eb)),x] else: return [-fy,x] '''大偏心求解远端钢筋面积As,和近端...
2201_75699492/c-s
mian.py
Python
unknown
6,535
# 1. 加载数据并探索 # 导入包 import pandas as pd # 加载数据 df = pd.read_csv('水果数据集.csv') # 查看数据前5行 print(df.head()) # 统计信息 print(df.describe()) # 类别分布 print(df['水果名称'].value_counts())
2201_75876277/jiqixuexi
1.py
Python
unknown
262
# 2. 数据预处理 # 2.1 将颜色(分类特征)转换为数值 #导入包 from sklearn.preprocessing import LabelEncoder # 对颜色列进行编码 encoder_color = LabelEncoder() df['颜色编码'] = encoder_color.fit_transform(df['颜色']) # 查看编码映射(可选) print("颜色编码映射:", dict(zip(encoder_color.classes_, encoder_color.transform(encoder_color.classes_)))) #2.2 特征标准化...
2201_75876277/jiqixuexi
2.py
Python
unknown
663
# 3. 划分训练集和测试集 #导入包 from sklearn.model_selection import train_test_split # 特征和标签 X = df[['大小(cm)', '颜色编码']] # 或使用 X_scaled y = df['水果名称'] # 划分数据集(80%训练,20%测试) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
2201_75876277/jiqixuexi
3.py
Python
unknown
346
# 4. 选择并训练模型 # 以随机森林(适合分类任务)为例: #导入包 from sklearn.ensemble import RandomForestClassifier # 初始化模型 model = RandomForestClassifier(n_estimators=100, random_state=42) # 训练模型 model.fit(X_train, y_train)
2201_75876277/jiqixuexi
4.py
Python
unknown
280
# 5. 评估模型性能 #导入包 from sklearn.metrics import accuracy_score, classification_report # 预测测试集 y_pred = model.predict(X_test) # 计算准确率 accuracy = accuracy_score(y_test, y_pred) print(f"准确率: {accuracy:.2f}") # 详细分类报告 print(classification_report(y_test, y_pred))
2201_75876277/jiqixuexi
5.py
Python
unknown
328
# 6.优化模型(网格搜索调参) #导入包 from sklearn.model_selection import GridSearchCV # 定义参数网格 param_grid = { 'n_estimators': [50, 100, 200], 'max_depth': [None, 5, 10] } # 网格搜索 grid_search = GridSearchCV(RandomForestClassifier(random_state=42), param_grid, cv=5) grid_search.fit(X_train, y_train) # 最佳参数和模型...
2201_75876277/jiqixuexi
6.py
Python
unknown
476
#7. 保存模型并预测新数据 #7.1 保存模型 import joblib # 保存模型和编码器 joblib.dump(best_model, '水果分类模型.pkl') joblib.dump(encoder_color, '颜色编码器.pkl') #7.2 加载模型并预测 # 加载模型和编码器 loaded_model = joblib.load('水果分类模型.pkl') loaded_encoder = joblib.load('颜色编码器.pkl') # 新数据示例 new_data = pd.DataFrame({ '大小(cm)': [7.5, 20.0, 2.0], ...
2201_75876277/jiqixuexi
7.py
Python
unknown
730
import pandas as pd import numpy as np # 设定随机种子(保证可重复性) np.random.seed(42) # 生成50行数据 data = { '大小(cm)': [], '颜色': [], '水果名称': [] } # 定义水果的规则 fruit_rules = { '苹果': {'大小范围': (5, 10), '可能颜色': ['红', '绿', '黄']}, '香蕉': {'大小范围': (15, 25), '可能颜色': ['黄']}, '葡萄': {'大小范围': (1, 3), '可能颜色...
2201_75876277/jiqixuexi
data/data.py
Python
unknown
1,105
@echo off REM MailServer Windows 编译脚本 echo 开始编译 MailServer... REM 检查 protoc 是否安装 where protoc >nul 2>nul if %errorlevel% neq 0 ( echo 错误: 未找到 protoc 命令 echo 请先安装 Protocol Buffers echo 下载地址: https://github.com/protocolbuffers/protobuf/releases exit /b 1 ) REM 生成 protobuf 文件 echo 生成 Protocol Buffers 文件...
2201_75373101/DistributedClusterServer
MailServer/build.bat
Batchfile
unknown
1,044
#!/bin/bash # MailServer 编译脚本 echo "开始编译 MailServer..." # 检查 protoc 是否安装 if ! command -v protoc &> /dev/null; then echo "错误: 未找到 protoc 命令" echo "请先安装 Protocol Buffers:" echo " Ubuntu/Debian: sudo apt-get install protobuf-compiler libprotobuf-dev" echo " CentOS/RHEL: sudo yum install protobuf-compi...
2201_75373101/DistributedClusterServer
MailServer/build.sh
Shell
unknown
1,138
/* * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/ae.h
C
unknown
4,271
#ifndef __HIREDIS_GLIB_H__ #define __HIREDIS_GLIB_H__ #include <glib.h> #include "../hiredis.h" #include "../async.h" typedef struct { GSource source; redisAsyncContext *ac; GPollFD poll_fd; } RedisSource; static void redis_source_add_read (gpointer data) { RedisSource *source = (RedisSource *)data;...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/glib.h
C
unknown
3,854
#ifndef __HIREDIS_IVYKIS_H__ #define __HIREDIS_IVYKIS_H__ #include <iv.h> #include "../hiredis.h" #include "../async.h" typedef struct redisIvykisEvents { redisAsyncContext *context; struct iv_fd fd; } redisIvykisEvents; static void redisIvykisReadEvent(void *arg) { redisAsyncContext *context = (redisAsyn...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/ivykis.h
C
unknown
2,327
/* * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/libev.h
C
unknown
5,597
/* * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/libevent.h
C
unknown
5,613
#ifndef __HIREDIS_LIBHV_H__ #define __HIREDIS_LIBHV_H__ #include "../../hv/hloop.h" #include "../hiredis.h" #include "../async.h" typedef struct redisLibhvEvents { hio_t *io; htimer_t *timer; } redisLibhvEvents; static void redisLibhvHandleEvents(hio_t* io) { redisAsyncContext* context = (redisAsyncConte...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/libhv.h
C
unknown
3,404
#ifndef HIREDIS_LIBSDEVENT_H #define HIREDIS_LIBSDEVENT_H #include <systemd/sd-event.h> #include "../hiredis.h" #include "../async.h" #define REDIS_LIBSDEVENT_DELETED 0x01 #define REDIS_LIBSDEVENT_ENTERED 0x02 typedef struct redisLibsdeventEvents { redisAsyncContext *context; struct sd_event *event; struc...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/libsdevent.h
C
unknown
4,953
#ifndef __HIREDIS_LIBUV_H__ #define __HIREDIS_LIBUV_H__ #include <stdlib.h> #include <uv.h> #include "../hiredis.h" #include "../async.h" #include <string.h> typedef struct redisLibuvEvents { redisAsyncContext* context; uv_poll_t handle; uv_timer_t timer; int events; } r...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/libuv.h
C
unknown
4,506
// // Created by Дмитрий Бахвалов on 13.07.15. // Copyright (c) 2015 Dmitry Bakhvalov. All rights reserved. // #ifndef __HIREDIS_MACOSX_H__ #define __HIREDIS_MACOSX_H__ #include <CoreFoundation/CoreFoundation.h> #include "../hiredis.h" #include "../async.h" typedef struct { redisAsyncContext *context; CFS...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/macosx.h
C
unknown
3,885
#ifndef HIREDIS_POLL_H #define HIREDIS_POLL_H #include "../async.h" #include "../sockcompat.h" #include <string.h> // for memset #include <errno.h> /* Values to return from redisPollTick */ #define REDIS_POLL_HANDLED_READ 1 #define REDIS_POLL_HANDLED_WRITE 2 #define REDIS_POLL_HANDLED_TIMEOUT 4 /* An adapter t...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/poll.h
C
unknown
5,260
/*- * Copyright (C) 2014 Pietro Cerutti <gahr@gahr.ch> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions an...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/qt.h
C++
unknown
4,233
#ifndef __HIREDIS_REDISMODULEAPI_H__ #define __HIREDIS_REDISMODULEAPI_H__ #include "redismodule.h" #include "../async.h" #include "../hiredis.h" #include <sys/types.h> typedef struct redisModuleEvents { redisAsyncContext *context; RedisModuleCtx *module_ctx; int fd; int reading, writing; int tim...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/adapters/redismoduleapi.h
C
unknown
4,122
/* * Copyright (c) 2020, Michael Grunder <michael dot grunder at gmail dot com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the abo...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/alloc.h
C
unknown
3,130
/* * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com> * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condit...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/async.h
C
unknown
6,288
/* * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com> * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condit...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/async_private.h
C
unknown
3,367
/* Hash table implementation. * * This file implements in memory hash tables with insert/del/replace/find/ * get-random-element operations. Hash tables will auto resize if needed * tables of power of two in size are used, collisions are handled by * chaining. See the source code for more information... :) * * Co...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/dict.h
C
unknown
4,650
#ifndef __HIREDIS_FMACRO_H #define __HIREDIS_FMACRO_H #ifndef _AIX #define _XOPEN_SOURCE 600 #define _POSIX_C_SOURCE 200112L #endif #if defined(__APPLE__) && defined(__MACH__) /* Enable TCP_KEEPALIVE */ #define _DARWIN_C_SOURCE #endif #endif
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/fmacros.h
C
unknown
245
/* * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com> * Copyright (c) 2010-2014, Pieter Noordhuis <pcnoordhuis at gmail dot com> * Copyright (c) 2015, Matt Stancliff <matt at genges dot com>, * Jan-Erik Rediger <janerik at fnordig dot com> * * All rights reserved. * *...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/hiredis.h
C
unknown
14,323
/* * Copyright (c) 2019, Redis Labs * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of co...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/hiredis_ssl.h
C
unknown
6,080
/* Extracted from anet.c to work properly with Hiredis error reporting. * * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com> * Copyright (c) 2010-2014, Pieter Noordhuis <pcnoordhuis at gmail dot com> * Copyright (c) 2015, Matt Stancliff <matt at genges dot com>, * Jan-Er...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/net.h
C
unknown
2,836
/* * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com> * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condit...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/read.h
C
unknown
4,918
/* SDSLib 2.0 -- A C dynamic strings library * * Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com> * Copyright (c) 2015, Oran Agra * Copyright (c) 2015, Redis Labs, Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permit...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/sds.h
C
unknown
9,238
/* SDSLib 2.0 -- A C dynamic strings library * * Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com> * Copyright (c) 2015, Oran Agra * Copyright (c) 2015, Redis Labs, Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permit...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/sdsalloc.h
C
unknown
2,121
/* * Copyright (c) 2019, Marcus Geelnard <m at bitsnbites dot eu> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright n...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/sockcompat.h
C
unknown
4,409
#ifndef _WIN32_HELPER_INCLUDE #define _WIN32_HELPER_INCLUDE #ifdef _MSC_VER #include <winsock2.h> /* for struct timeval */ #ifndef inline #define inline __inline #endif #ifndef strcasecmp #define strcasecmp stricmp #endif #ifndef strncasecmp #define strncasecmp strnicmp #endif #ifndef va_copy #define va_copy(d,s) ...
2201_75373101/DistributedClusterServer
MailServer/include/hiredis/win32.h
C
unknown
1,042
#ifndef HV_ASYNC_HTTP_CLIENT_H_ #define HV_ASYNC_HTTP_CLIENT_H_ #include <map> #include <list> #include "EventLoopThread.h" #include "Channel.h" #include "HttpMessage.h" #include "HttpParser.h" namespace hv { template<typename Conn> class ConnPool { public: int size() { return conns_.size(); } ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/AsyncHttpClient.h
C++
unknown
3,659
#ifndef HV_BUFFER_HPP_ #define HV_BUFFER_HPP_ #include <memory> #include "hbuf.h" namespace hv { typedef HBuf Buffer; typedef std::shared_ptr<Buffer> BufferPtr; } #endif // HV_BUFFER_HPP_
2201_75373101/DistributedClusterServer
MailServer/include/hv/Buffer.h
C++
unknown
198
#ifndef HV_CHANNEL_HPP_ #define HV_CHANNEL_HPP_ #include <string> #include <functional> #include <memory> #include "hloop.h" #include "hsocket.h" #include "Buffer.h" namespace hv { class Channel { public: Channel(hio_t* io = NULL) { io_ = io; fd_ = -1; id_ = 0; ctx_ = NULL; ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/Channel.h
C++
unknown
9,871
#ifndef HV_EVENT_HPP_ #define HV_EVENT_HPP_ #include <functional> #include <memory> #include "hloop.h" namespace hv { struct Event; struct Timer; typedef uint64_t TimerID; #define INVALID_TIMER_ID ((hv::TimerID)-1) typedef std::function<void(Event*)> EventCallback; typedef std::function<void(Tim...
2201_75373101/DistributedClusterServer
MailServer/include/hv/Event.h
C++
unknown
937
#ifndef HV_EVENT_LOOP_HPP_ #define HV_EVENT_LOOP_HPP_ #include <functional> #include <queue> #include <map> #include <mutex> #include "hloop.h" #include "hthread.h" #include "Status.h" #include "Event.h" #include "ThreadLocalStorage.h" namespace hv { class EventLoop : public Status { public: typedef std::func...
2201_75373101/DistributedClusterServer
MailServer/include/hv/EventLoop.h
C++
unknown
7,603
#ifndef HV_EVENT_LOOP_THREAD_HPP_ #define HV_EVENT_LOOP_THREAD_HPP_ #include <thread> #include "hlog.h" #include "EventLoop.h" namespace hv { class EventLoopThread : public Status { public: // Return 0 means OK, other failed. typedef std::function<int()> Functor; EventLoopThread(EventLoopPtr loop = NU...
2201_75373101/DistributedClusterServer
MailServer/include/hv/EventLoopThread.h
C++
unknown
2,874
#ifndef HV_EVENT_LOOP_THREAD_POOL_HPP_ #define HV_EVENT_LOOP_THREAD_POOL_HPP_ #include "EventLoopThread.h" #include "hbase.h" namespace hv { class EventLoopThreadPool : public Status { public: EventLoopThreadPool(int thread_num = std::thread::hardware_concurrency()) { setStatus(kInitializing); th...
2201_75373101/DistributedClusterServer
MailServer/include/hv/EventLoopThreadPool.h
C++
unknown
4,317
#ifndef HV_HTTP_CLIENT_H_ #define HV_HTTP_CLIENT_H_ #include "hexport.h" #include "hssl.h" #include "HttpMessage.h" /* #include <stdio.h> #include "HttpClient.h" int main(int argc, char* argv[]) { HttpRequest req; req.method = HTTP_GET; req.url = "http://www.example.com"; HttpResponse res; int r...
2201_75373101/DistributedClusterServer
MailServer/include/hv/HttpClient.h
C++
unknown
5,529
#ifndef HV_HTTP_CONTEXT_H_ #define HV_HTTP_CONTEXT_H_ #include "hexport.h" #include "HttpMessage.h" #include "HttpResponseWriter.h" namespace hv { struct HttpService; struct HV_EXPORT HttpContext { HttpService* service; HttpRequestPtr request; HttpResponsePtr response; Htt...
2201_75373101/DistributedClusterServer
MailServer/include/hv/HttpContext.h
C++
unknown
5,147
#ifndef HV_HTTP_MESSAGE_H_ #define HV_HTTP_MESSAGE_H_ /* * @class HttpMessage * HttpRequest extends HttpMessage * HttpResponse extends HttpMessage * * @member * request-line: GET / HTTP/1.1\r\n => method path * response-line: HTTP/1.1 200 OK\r\n => status_code * headers, cookies * body * * content, content...
2201_75373101/DistributedClusterServer
MailServer/include/hv/HttpMessage.h
C++
unknown
14,751
#ifndef HV_HTTP_PARSER_H_ #define HV_HTTP_PARSER_H_ #include "hexport.h" #include "HttpMessage.h" class HV_EXPORT HttpParser { public: http_version version; http_session_type type; static HttpParser* New(http_session_type type = HTTP_CLIENT, http_version version = HTTP_V1); virtual ~HttpPars...
2201_75373101/DistributedClusterServer
MailServer/include/hv/HttpParser.h
C++
unknown
1,753
#ifndef HV_HTTP_RESPONSE_WRITER_H_ #define HV_HTTP_RESPONSE_WRITER_H_ #include "Channel.h" #include "HttpMessage.h" namespace hv { class HV_EXPORT HttpResponseWriter : public SocketChannel { public: HttpResponsePtr response; enum State { SEND_BEGIN = 0, SEND_HEADER, SEND_BODY, ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/HttpResponseWriter.h
C++
unknown
2,624
#ifndef HV_HTTP_SERVER_H_ #define HV_HTTP_SERVER_H_ #include "hexport.h" #include "hssl.h" #include "HttpService.h" // #include "WebSocketServer.h" namespace hv { struct WebSocketService; } using hv::HttpService; using hv::WebSocketService; typedef struct http_server_s { char host[64]; int port; // http_port ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/HttpServer.h
C++
unknown
3,494
#ifndef HV_HTTP_SERVICE_H_ #define HV_HTTP_SERVICE_H_ #include <string> #include <map> #include <unordered_map> #include <vector> #include <list> #include <memory> #include <functional> #include "hexport.h" #include "HttpMessage.h" #include "HttpResponseWriter.h" #include "HttpContext.h" #define DEFAULT_BASE_URL ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/HttpService.h
C++
unknown
9,569
#ifndef HV_STATUS_HPP_ #define HV_STATUS_HPP_ #include <atomic> namespace hv { class Status { public: enum KStatus { kNull = 0, kInitializing = 1, kInitialized = 2, kStarting = 3, kStarted = 4, kRunning = 5, kPause ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/Status.h
C++
unknown
914
#ifndef HV_TCP_CLIENT_HPP_ #define HV_TCP_CLIENT_HPP_ #include "hsocket.h" #include "hssl.h" #include "hlog.h" #include "EventLoopThread.h" #include "Channel.h" namespace hv { template<class TSocketChannel = SocketChannel> class TcpClientEventLoopTmpl { public: typedef std::shared_ptr<TSocketChannel> TSocketCha...
2201_75373101/DistributedClusterServer
MailServer/include/hv/TcpClient.h
C++
unknown
8,761
#ifndef HV_TCP_SERVER_HPP_ #define HV_TCP_SERVER_HPP_ #include "hsocket.h" #include "hssl.h" #include "hlog.h" #include "EventLoopThreadPool.h" #include "Channel.h" namespace hv { template<class TSocketChannel = SocketChannel> class TcpServerEventLoopTmpl { public: typedef std::shared_ptr<TSocketChannel> TSocke...
2201_75373101/DistributedClusterServer
MailServer/include/hv/TcpServer.h
C++
unknown
9,737
#ifndef HV_THREAD_LOCAL_STORAGE_H_ #define HV_THREAD_LOCAL_STORAGE_H_ #include "hexport.h" #include "hplatform.h" #ifdef OS_WIN #define hthread_key_t DWORD #define INVALID_HTHREAD_KEY 0xFFFFFFFF #define hthread_key_create(pkey) *pkey = TlsAlloc() #define hthread_key_delete TlsFree #...
2201_75373101/DistributedClusterServer
MailServer/include/hv/ThreadLocalStorage.h
C++
unknown
1,496
#ifndef HV_UDP_CLIENT_HPP_ #define HV_UDP_CLIENT_HPP_ #include "hsocket.h" #include "EventLoopThread.h" #include "Channel.h" namespace hv { template<class TSocketChannel = SocketChannel> class UdpClientEventLoopTmpl { public: typedef std::shared_ptr<TSocketChannel> TSocketChannelPtr; UdpClientEventLoopTmpl...
2201_75373101/DistributedClusterServer
MailServer/include/hv/UdpClient.h
C++
unknown
5,671
#ifndef HV_UDP_SERVER_HPP_ #define HV_UDP_SERVER_HPP_ #include "hsocket.h" #include "EventLoopThreadPool.h" #include "Channel.h" namespace hv { template<class TSocketChannel = SocketChannel> class UdpServerEventLoopTmpl { public: typedef std::shared_ptr<TSocketChannel> TSocketChannelPtr; UdpServerEventLoop...
2201_75373101/DistributedClusterServer
MailServer/include/hv/UdpServer.h
C++
unknown
4,788
#ifndef HV_WEBSOCKET_CHANNEL_H_ #define HV_WEBSOCKET_CHANNEL_H_ #include <mutex> #include "Channel.h" #include "wsdef.h" #include "hmath.h" namespace hv { class HV_EXPORT WebSocketChannel : public SocketChannel { public: ws_session_type type; WebSocketChannel(hio_t* io, ws_session_type type = WS_CLIENT) ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/WebSocketChannel.h
C++
unknown
1,296
#ifndef HV_WEBSOCKET_CLIENT_H_ #define HV_WEBSOCKET_CLIENT_H_ /* * @demo examples/websocket_client_test.cpp */ #include "hexport.h" #include "TcpClient.h" #include "WebSocketChannel.h" #include "HttpParser.h" #include "WebSocketParser.h" namespace hv { class HV_EXPORT WebSocketClient : public TcpClientTmpl<WebS...
2201_75373101/DistributedClusterServer
MailServer/include/hv/WebSocketClient.h
C++
unknown
1,754
#ifndef HV_WEBSOCKET_PARSER_H_ #define HV_WEBSOCKET_PARSER_H_ #include "hexport.h" #include <string> #include <memory> #include <functional> enum websocket_parser_state { WS_FRAME_BEGIN, WS_FRAME_HEADER, WS_FRAME_BODY, WS_FRAME_END, WS_FRAME_FIN, }; struct websocket_parser; class HV_EXPORT WebSo...
2201_75373101/DistributedClusterServer
MailServer/include/hv/WebSocketParser.h
C++
unknown
804
#ifndef HV_WEBSOCKET_SERVER_H_ #define HV_WEBSOCKET_SERVER_H_ /* * @demo examples/websocket_server_test.cpp */ #include "HttpServer.h" #include "WebSocketChannel.h" #define websocket_server_t http_server_t #define websocket_server_run http_server_run #define websocket_server_stop http_server_stop namesp...
2201_75373101/DistributedClusterServer
MailServer/include/hv/WebSocketServer.h
C++
unknown
1,097
#ifndef HV_AXIOS_H_ #define HV_AXIOS_H_ #include "json.hpp" #include "requests.h" /* * Inspired by js axios * * @code #include "axios.h" int main() { const char* strReq = R"( { "method": "POST", "url": "http://127.0.0.1:8080/echo", "timeout": 10, "params": { "p...
2201_75373101/DistributedClusterServer
MailServer/include/hv/axios.h
C++
unknown
4,817
#ifndef HV_BASE64_H_ #define HV_BASE64_H_ #include "hexport.h" #define BASE64_ENCODE_OUT_SIZE(s) (((s) + 2) / 3 * 4) #define BASE64_DECODE_OUT_SIZE(s) (((s)) / 4 * 3) BEGIN_EXTERN_C // @return encoded size HV_EXPORT int hv_base64_encode(const unsigned char *in, unsigned int inlen, char *out); // @return decode...
2201_75373101/DistributedClusterServer
MailServer/include/hv/base64.h
C++
unknown
1,225
#ifndef HV_PROTO_RPC_HANDLER_CALC_H_ #define HV_PROTO_RPC_HANDLER_CALC_H_ #include "../router.h" #include "../generated/calc.pb.h" void calc_add(const protorpc::Request& req, protorpc::Response* res) { // params if (req.params_size() != 2) { return bad_request(req, res); } protorpc::CalcParam...
2201_75373101/DistributedClusterServer
MailServer/include/hv/handler/calc.h
C
unknown
2,230
#ifndef HV_PROTO_RPC_HANDLER_H_ #define HV_PROTO_RPC_HANDLER_H_ #include "../router.h" void error_response(protorpc::Response* res, int code, const std::string& message) { res->mutable_error()->set_code(code); res->mutable_error()->set_message(message); } void not_found(const protorpc::Request& req, protorpc...
2201_75373101/DistributedClusterServer
MailServer/include/hv/handler/handler.h
C++
unknown
541
#ifndef HV_PROTO_RPC_HANDLER_LOGIN_H_ #define HV_PROTO_RPC_HANDLER_LOGIN_H_ #include "../router.h" #include "../generated/login.pb.h" void login(const protorpc::Request& req, protorpc::Response* res) { // params if (req.params_size() == 0) { return bad_request(req, res); } protorpc::LoginPara...
2201_75373101/DistributedClusterServer
MailServer/include/hv/handler/login.h
C
unknown
660
#ifndef HV_ASYNC_H_ #define HV_ASYNC_H_ #include "hexport.h" #include "hthreadpool.h" #include "singleton.h" namespace hv { class HV_EXPORT GlobalThreadPool : public HThreadPool { SINGLETON_DECL(GlobalThreadPool) protected: GlobalThreadPool() : HThreadPool() {} ~GlobalThreadPool() {} }; /* * return a f...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hasync.h
C++
unknown
1,341
#ifndef HV_ATOMIC_H_ #define HV_ATOMIC_H_ #ifdef __cplusplus // c++11 #include <atomic> using std::atomic_flag; using std::atomic_long; #define ATOMIC_FLAG_TEST_AND_SET(p) ((p)->test_and_set()) #define ATOMIC_FLAG_CLEAR(p) ((p)->clear()) #else #include "hplatform.h" // for HAVE_STDATOMIC_H #if HAV...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hatomic.h
C++
unknown
3,614
#ifndef HV_BASE_H_ #define HV_BASE_H_ #include "hexport.h" #include "hplatform.h" // for bool #include "hdef.h" // for printd BEGIN_EXTERN_C //--------------------alloc/free--------------------------- HV_EXPORT void* hv_malloc(size_t size); HV_EXPORT void* hv_realloc(void* oldptr, size_t newsize, size_t oldsize); HV...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hbase.h
C
unknown
4,292
#ifndef HV_BUF_H_ #define HV_BUF_H_ #include "hdef.h" // for MAX #include "hbase.h" // for HV_ALLOC, HV_FREE typedef struct hbuf_s { char* base; size_t len; #ifdef __cplusplus hbuf_s() { base = NULL; len = 0; } hbuf_s(void* data, size_t len) { this->base = (char*)dat...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hbuf.h
C++
unknown
5,426
#ifndef HV_CONFIG_H_ #define HV_CONFIG_H_ #ifndef HAVE_STDBOOL_H #define HAVE_STDBOOL_H 1 #endif #ifndef HAVE_STDINT_H #define HAVE_STDINT_H 1 #endif #ifndef HAVE_STDATOMIC_H #define HAVE_STDATOMIC_H 1 #endif #ifndef HAVE_SYS_TYPES_H #define HAVE_SYS_TYPES_H 1 #endif #ifndef HAVE_SYS_STAT_H #define HAVE_SYS_STAT_H...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hconfig.h
C
unknown
1,504
#ifndef HV_DEF_H_ #define HV_DEF_H_ #include "hplatform.h" #ifndef ABS #define ABS(n) ((n) > 0 ? (n) : -(n)) #endif #ifndef NABS #define NABS(n) ((n) < 0 ? (n) : -(n)) #endif #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) #endif #ifndef BITSET #define BITSET(p, n) (*(p) |= (1u << (n))) #endif...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hdef.h
C
unknown
4,996
#ifndef HV_DIR_H_ #define HV_DIR_H_ /* *@code int main(int argc, char* argv[]) { const char* dir = "."; if (argc > 1) { dir = argv[1]; } std::list<hdir_t> dirs; listdir(dir, dirs); for (auto& item : dirs) { printf("%c%c%c%c%c%c%c%c%c%c\t", item.type, ite...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hdir.h
C++
unknown
1,832
#ifndef HV_ENDIAN_H_ #define HV_ENDIAN_H_ #include "hplatform.h" #if defined(OS_MAC) #include <libkern/OSByteOrder.h> #define htobe16(v) OSSwapHostToBigInt16(v) #define htobe32(v) OSSwapHostToBigInt32(v) #define htobe64(v) OSSwapHostToBigInt64(v) #define be16toh(v) OSSwapBigToHostInt16(v) #define be32toh(v) OSSwapBigT...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hendian.h
C++
unknown
7,350
#ifndef HV_ERR_H_ #define HV_ERR_H_ #include <errno.h> #include "hexport.h" #ifndef SYS_NERR #define SYS_NERR 133 #endif // F(errcode, name, errmsg) // [1, 133] #define FOREACH_ERR_SYS(F) // [1xx~5xx] #define FOREACH_ERR_STATUS(F) // [1xxx] #define FOREACH_ERR_COMMON(F) \ F(0, OK, "OK") ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/herr.h
C
unknown
4,532
#ifndef HV_EXPORT_H_ #define HV_EXPORT_H_ // HV_EXPORT #if defined(HV_STATICLIB) || defined(HV_SOURCE) #define HV_EXPORT #elif defined(_MSC_VER) #if defined(HV_DYNAMICLIB) || defined(HV_EXPORTS) || defined(hv_EXPORTS) #define HV_EXPORT __declspec(dllexport) #else #define HV_EXPORT __decls...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hexport.h
C
unknown
2,651
#ifndef HV_FILE_H_ #define HV_FILE_H_ #include <string> // for std::string #include "hplatform.h" // for stat #include "hbuf.h" // for HBuf class HFile { public: HFile() { filepath[0] = '\0'; fp = NULL; } ~HFile() { close(); } int open(const char* filepath, const char* m...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hfile.h
C++
unknown
2,949
#ifndef HV_LOG_H_ #define HV_LOG_H_ /* * hlog is thread-safe */ #include <string.h> #ifdef _WIN32 #define DIR_SEPARATOR '\\' #define DIR_SEPARATOR_STR "\\" #else #define DIR_SEPARATOR '/' #define DIR_SEPARATOR_STR "/" #endif #ifndef __FILENAME__ // #define __FILENAME__ (strrchr(__FILE__, DIR_SEPA...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hlog.h
C
unknown
6,973
#ifndef HV_LOOP_H_ #define HV_LOOP_H_ #include "hexport.h" #include "hplatform.h" #include "hdef.h" #include "hssl.h" typedef struct hloop_s hloop_t; typedef struct hevent_s hevent_t; // NOTE: The following structures are subclasses of hevent_t, // inheriting hevent_t data members and function members. type...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hloop.h
C
unknown
27,527
#ifndef HV_MAIN_H_ #define HV_MAIN_H_ #include "hexport.h" #include "hplatform.h" #include "hdef.h" #include "hproc.h" #ifdef _MSC_VER #pragma comment(lib, "winmm.lib") // for timeSetEvent #endif BEGIN_EXTERN_C typedef struct main_ctx_s { char run_dir[MAX_PATH]; char program_name[MAX_PATH]; char ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hmain.h
C
unknown
3,037
#ifndef HV_MAP_H_ #define HV_MAP_H_ #include "hconfig.h" #include <map> #include <string> // MultiMap namespace std { /* int main() { std::MultiMap<std::string, std::string> kvs; kvs["name"] = "hw"; kvs["filename"] = "1.jpg"; kvs["filename"] = "2.jpg"; //kvs.insert(std::pair<std::string,std::stri...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hmap.h
C++
unknown
1,401
#ifndef HV_MATH_H_ #define HV_MATH_H_ #include <math.h> static inline unsigned long floor2e(unsigned long num) { unsigned long n = num; int e = 0; while (n>>=1) ++e; unsigned long ret = 1; while (e--) ret<<=1; return ret; } static inline unsigned long ceil2e(unsigned long num) { // 2**0 =...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hmath.h
C
unknown
1,531
#ifndef HV_MUTEX_H_ #define HV_MUTEX_H_ #include "hexport.h" #include "hplatform.h" #include "htime.h" BEGIN_EXTERN_C #ifdef OS_WIN #define hmutex_t CRITICAL_SECTION #define hmutex_init InitializeCriticalSection #define hmutex_destroy DeleteCriticalSection #define hmutex_lock ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hmutex.h
C++
unknown
9,115
#ifndef HV_OBJECT_POOL_H_ #define HV_OBJECT_POOL_H_ /* * @usage unittest/objectpool_test.cpp */ #include <list> #include <memory> #include <mutex> #include <condition_variable> #define DEFAULT_OBJECT_POOL_INIT_NUM 0 #define DEFAULT_OBJECT_POOL_MAX_NUM 4 #define DEFAULT_OBJECT_POOL_TIMEOUT 3000 // ms te...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hobjectpool.h
C++
unknown
4,375
#ifndef HV_PATH_H_ #define HV_PATH_H_ #include <string> // for std::string #include "hexport.h" class HV_EXPORT HPath { public: static bool exists(const char* path); static bool isdir(const char* path); static bool isfile(const char* path); static bool islink(const char* path); // filepath = /mn...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hpath.h
C++
unknown
809
#ifndef HV_PLATFORM_H_ #define HV_PLATFORM_H_ #include "hconfig.h" // OS #if defined(WIN64) || defined(_WIN64) #define OS_WIN64 #define OS_WIN32 #elif defined(WIN32)|| defined(_WIN32) #define OS_WIN32 #elif defined(ANDROID) || defined(__ANDROID__) #define OS_ANDROID #define OS_LINUX #elif defined(...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hplatform.h
C
unknown
8,765
#ifndef HV_PROC_H_ #define HV_PROC_H_ #include "hplatform.h" typedef struct proc_ctx_s { pid_t pid; // tid in Windows time_t start_time; int spawn_cnt; procedure_t init; void* init_userdata; procedure_t proc; void* proc_userdata; ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hproc.h
C
unknown
1,621
#ifndef HV_SCOPE_H_ #define HV_SCOPE_H_ #include <functional> typedef std::function<void()> Function; #include "hdef.h" // same as golang defer class Defer { public: Defer(Function&& fn) : _fn(std::move(fn)) {} ~Defer() { if(_fn) _fn();} private: Function _fn; }; #define defer(code) Defer STRINGCAT(_defe...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hscope.h
C++
unknown
1,441
#ifndef HV_SOCKET_H_ #define HV_SOCKET_H_ #include "hexport.h" #include "hplatform.h" #ifdef ENABLE_UDS #ifdef OS_WIN #include <afunix.h> // import struct sockaddr_un #else #include <sys/un.h> // import struct sockaddr_un #endif #endif #ifdef _MSC_VER #pragma comment(lib, "ws2_32.lib") #endif #define LOCALH...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hsocket.h
C
unknown
8,022
#ifndef HV_SSL_H_ #define HV_SSL_H_ #include "hexport.h" #include "hplatform.h" #if !defined(WITH_OPENSSL) && \ !defined(WITH_GNUTLS) && \ !defined(WITH_MBEDTLS) #ifdef OS_WIN #define WITH_WINTLS #ifdef _MSC_VER #pragma comment(lib, "secur32.lib") #pragma comment(lib, "crypt32.lib...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hssl.h
C
unknown
2,150
#ifndef HV_STRING_H_ #define HV_STRING_H_ #include <string> #include <vector> #include <iostream> #include <sstream> #include "hexport.h" #include "hplatform.h" #include "hmap.h" #define SPACE_CHARS " \t\r\n" #define PAIR_CHARS "{}[]()<>\"\"\'\'``" namespace hv { HV_EXPORT extern std::string ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hstring.h
C++
unknown
2,436
#ifndef HV_SYS_INFO_H_ #define HV_SYS_INFO_H_ #include "hplatform.h" #ifdef OS_LINUX #include <sys/sysinfo.h> #endif #ifdef OS_DARWIN #include <mach/mach_host.h> #include <sys/sysctl.h> #endif static inline int get_ncpu() { #ifdef OS_WIN SYSTEM_INFO si; GetSystemInfo(&si); return si.dwNumberOfProcessors...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hsysinfo.h
C
unknown
1,773
#ifndef HV_THREAD_H_ #define HV_THREAD_H_ #include "hplatform.h" #ifdef OS_WIN #define hv_getpid (long)GetCurrentProcessId #else #define hv_getpid (long)getpid #endif #ifdef OS_WIN #define hv_gettid (long)GetCurrentThreadId #elif HAVE_GETTID || defined(OS_ANDROID) #define hv_gettid (long)gettid #elif defined...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hthread.h
C++
unknown
4,838
#ifndef HV_THREAD_POOL_H_ #define HV_THREAD_POOL_H_ /* * @usage unittest/threadpool_test.cpp */ #include <time.h> #include <thread> #include <list> #include <queue> #include <functional> #include <atomic> #include <mutex> #include <condition_variable> #include <future> #include <memory> #include <utility> #include ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hthreadpool.h
C++
unknown
6,907
#ifndef HV_TIME_H_ #define HV_TIME_H_ #include "hexport.h" #include "hplatform.h" BEGIN_EXTERN_C #define SECONDS_PER_MINUTE 60 #define SECONDS_PER_HOUR 3600 #define SECONDS_PER_DAY 86400 // 24*3600 #define SECONDS_PER_WEEK 604800 // 7*24*3600 #define IS_LEAP_YEAR(year) (((year)%4 == 0 && (year)%100 !=...
2201_75373101/DistributedClusterServer
MailServer/include/hv/htime.h
C
unknown
3,286
#ifndef HV_HTTP_CONTENT_H_ #define HV_HTTP_CONTENT_H_ #include "hexport.h" #include "hstring.h" // NOTE: WITHOUT_HTTP_CONTENT // ndk-r10e no std::to_string and can't compile modern json.hpp #ifndef WITHOUT_HTTP_CONTENT #include "json.hpp" // https://github.com/nlohmann/json #endif BEGIN_NAMESPACE_HV // QueryParams ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/http_content.h
C++
unknown
2,133
#ifndef HV_HTTP_DEF_H_ #define HV_HTTP_DEF_H_ #include "hexport.h" #define DEFAULT_HTTP_PORT 80 #define DEFAULT_HTTPS_PORT 443 enum http_version { HTTP_V1 = 1, HTTP_V2 = 2 }; enum http_session_type { HTTP_CLIENT, HTTP_SERVER }; enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH }; enum http_pa...
2201_75373101/DistributedClusterServer
MailServer/include/hv/httpdef.h
C
unknown
14,526
#ifndef HV_URL_H_ #define HV_URL_H_ #include <string> // import std::string #include "hexport.h" class HV_EXPORT HUrl { public: static std::string escape(const std::string& str, const char* unescaped_chars = ""); static std::string unescape(const std::string& str); HUrl() : port(0) {} ~HUrl() {} ...
2201_75373101/DistributedClusterServer
MailServer/include/hv/hurl.h
C++
unknown
845
#ifndef HV_H_ #define HV_H_ /** * @copyright 2018 HeWei, all rights reserved. */ // platform #include "hconfig.h" #include "hexport.h" #include "hplatform.h" // c #include "hdef.h" // <stddef.h> #include "hatomic.h"// <stdatomic.h> #include "herr.h" // <errno.h> #include "htime.h" // <time.h> #include "hmath....
2201_75373101/DistributedClusterServer
MailServer/include/hv/hv.h
C
unknown
713