Skip to content
/ ccxx Public

This is a cross-platform library software library about c, c ++, unix4, posix. Include gtest, benchmark, cmake, process lock, daemon, libuv, lua, cpython, re2, json, yaml, mysql, redis, opencv, qt, lz4, oci ... https://hub.docker.com/u/oudream

License

Notifications You must be signed in to change notification settings

oudream/ccxx

Repository files navigation

CCXX (en)

  1. This is a cross-platform library software library about c, c ++, unix4, posix.
  2. This library has been continuously developed for more than three years, and it serves as the underlying support for many large projects.
  3. Incorporate unit test, benchmark test, cmake, process monitoring, daemon, asynchronous libraries libuv, lua, cpython, re2, json, yaml, mysql, redis, opencv, qt, lz4, oci ...

CCXX (cn)

  1. 这是关于c,c ++,unix4,posix的跨平台库软件库。
  2. 这个库已经连续开发了三年多,它为许多大型项目提供了基础支持。
  3. 合并了单元测试,基准测试,cmake,进程监视,守护程序,异步库libuv,lua,cpython,re2,json,yaml,mysql,redis,opencv,qt,lz4,oci ...

宣言

库要轻量,精简,尽量一个模块用一个文件完成,模块之间尽量不产生依赖,尽量单独拷贝几个文件就能完成目标功能。在达到效率基础上库的使用次序 -> clib ->stl -> unix api -> posix -> os api。要多写 unit test , benchmark , docker in k8s 并行分布式测试。

Manifesto

The library should be lightweight and streamlined, and one module should be completed with one file as much as possible. There should be no dependencies between the modules. Try to copy several files separately to complete the target function. On the basis of efficiency, the order of use of the library-> clib-> stl-> unix api-> posix-> os api. To write more unit test, benchmark, docker in k8s parallel distributed testing.

简介 (brief introduction)

ccxx的核心库代码在根目录下ccxx文件夹中中,大概有(14MB 左右)。模块大多以一个文件.cpp来完成功能,默认静态类方式直接调用)。例子可参考 sample 及 test 的目录。

  1. cxappenv.h: 运行环境(运行程序名, 工作目录, 环境变量)
  2. cxinterinfo.h: 程序的信息输入输出接口。实现有: cxlog.h(日志), CxConsoleInterinfo(终端)
  3. cxfile.h: 文件系统
  4. cxsocket.h: 网络通信
  5. cxthread.h: 线程信号,IPC
  6. cxapplication.h 类似(Node.js)中的Event Loop。采用 wait 信号机制对事件队列进行轮询并执行。目前参与到 Event Loop 中的有(cxchannel.h, cxtimer.h)。cxapplication_qt.h 是 Qt 参与到 Qt 的 Event Loop。
  7. cxchannel.h: (要实例化来使用)开独立线程进行收发和监听,收到数据及事件 push 到主线程的 Event Loop 中,因此数据不需要跨线加锁。实现有: cxchannel_udp.h, cxchannel_tcpserver.h, cxchannel_tcpclient.h, cxchannel_serial.h
  8. cxcrc.h: 数据检验
  9. cxdatabase.h: (要实例化来使用)以表的方式统一数据操作的接口类。实现有:cxdatabase_odbc.h, cxdatabase_sqlite.h(直接调用官方 sqlite3.c来实现相关功能)
  10. cxprocess.h: 系统进程
  11. cxprocmutex.h: 进程锁
  12. cxtimer.h: (要实例化来使用)定时器
  13. cxtime.h: 时间与日期
  14. cxuuid.h: GUID, UUID
  15. cxsharememory.h: 共享内存,进程间通信IPC (InterProcess Communication)
  16. cxprofile.h: (要实例化来使用)配置文件以表的方式来封闭使用。实现有: cxprofile_skv_json.h, cxprofile_skv_xml.h。(skv: section key value)
  17. cxencoding.h: 实现 GBK 与 UTF-8 之间的转换
  18. cxlua文件夹: 以 lua 的方式公开 ccxx 功能块,lua_run.h 是 main的入口。
  19. 其它第三方封装有(cxhiredis.h(Redis的封闭), cxtinyxml.h(Xml文件读写), cxrapidjson.h(正则表达式),lz4.h(压缩解压))
  20. gtest, luv, benchmark, yaml 的自身源码已经放到 3rd 中。
  21. openssl, curl 是以头文件加库的方式
  22. c++ call python(callpython)(./ccxx/sample/callpython), python call c++(cxpython)(./ccxx/ccxx/cxpython). referto https://github.com/oudream/hello-cmake
  23. opencv 的官方样例代码用cmake已经包含进来,并能编译以方便试验。

brief introduction

The core library code of ccxx is located in the ccxx folder in the root directory (about 14MB). Modules mostly use a file .cpp to complete the function, and the default static class method is called directly). For examples, please refer to the directory of sample and test.

  1. cxappenv.h: running environment (run program name, working directory, environment variables)
  2. cxinterinfo.h: program information input and output interface. Implementations are: cxlog.h (log), CxConsoleInterinfo (terminal)
  3. cxfile.h: file system
  4. cxsocket.h: network communication
  5. cxthread.h: thread signal, IPC
  6. cxapplication.h is similar to the Event Loop in (Node.js). The wait signal mechanism is used to poll and execute the event queue. Currently participating in the Event Loop (cxchannel.h, cxtimer.h). cxapplication_qt.h is the event loop where Qt participates in Qt.
  7. cxchannel.h: (to be instantiated to use) open a separate thread to send and receive and monitor, receive data and events push to the Event Loop of the main thread, so the data does not need to be locked across lines. Implementations are: cxchannel_udp.h, cxchannel_tcpserver.h, cxchannel_tcpclient.h, cxchannel_serial.h
  8. cxcrc.h: data check
  9. cxdatabase.h: (to be instantiated for use) interface class that unifies data operations in a table. The implementations are: cxdatabase_odbc.h, cxdatabase_sqlite.h (directly call the official sqlite3.c to achieve related functions)
  10. cxprocess.h: system process
  11. cxprocmutex.h: process lock
  12. cxtimer.h: (to be instantiated to use) timer
  13. cxtime.h: time and date
  14. cxuuid.h: GUID, UUID
  15. cxsharememory.h: shared memory, IPC (InterProcess Communication)
  16. cxprofile.h: (to be instantiated for use) The profile is closed for use as a table. The implementations are: cxprofile_skv_json.h, cxprofile_skv_xml.h. (skv: section key value)
  17. cxencoding.h: convert between GBK and UTF-8
  18. cxlua folder: exposes ccxx function blocks in lua, lua_run.h is the main entry.
  19. Other third-party packages include (cxhiredis.h (closed by Redis), cxtinyxml.h (Xml file read and write), cxrapidjson.h (regular expression), lz4.h (compression and decompression))
  20. gtest, luv, benchmark, yaml's own source code has been placed in 3rd.
  21. openssl, curl is a header file plus library
  22. c ++ call python (callpython) (./ ccxx / sample / callpython), python call c ++ (cxpython) (./ ccxx / ccxx / cxpython). Referto [https://github.com/oudream/hello-cmake ] (https://github.com/oudream/hello-cmake)
  23. The official sample code for opencv has been included with cmake and can be compiled for easy testing.

Source Code

git clone https://github.com/oudream/ccxx.git
# You can extract several related files for use as needed
# 可以根据需要提取其中几个相关文件来用的
docker run -d -p 2235:22 oudream/ubuntu-ccxx-env:18.04.12
ssh root@localhost -p 2235 -AXY -v
# password is: 123456
# You can run the following examples to experiment (可以运行以下样例来试验)
/opt/ccxx/build/deploy/unix/bin_d/cxtest_timer
# or
/opt/ccxx/build/deploy/unix/bin_d/cxtest_channel_udp_client1
# or
/opt/ccxx/build/deploy/unix/bin_d/cxtest_channel_udp_server1
# or
/opt/ccxx/build/deploy/unix/bin_d/cxsample_lua
# or
/opt/ccxx/build/deploy/unix/bin_d/benchmark_cxstring
# ctrl + c to exit
^c

Before compiling: Two libraries are required ( 有两个库是必须的 )

  1. ODBC : ccxx_database_odbc is a library for connecting databases with odbc
  2. ODBC : ccxx_database_odbc 是一个用 odbc 连接数据库的库
  3. UUID : Except for windows, CxUuid (uuid) is implemented using the libuuid library
  4. UUID : 除了 windows 以外, CxUuid (uuid) 是用 libuuid库实现的
### mac
brew install unixodbc

### Ubuntu: -D"OTL_ODBC_UNIX" -lodbc
sudo apt-get install unixodbc unixodbc-dev
sudo apt-get install uuid-dev

### CentOS: -D"OTL_ODBC_UNIX" -lodbc
sudo yum install unixODBC-devel
sudo yum install libuuid-devel

Simple Compile

# git and compile
git clone https://github.com/oudream/ccxx.git
cd ccxx
cmake . -DCMAKE_BUILD_TYPE=Debug --build . -B"./build/cmake-gcc"
cd ./build/cmake-gcc && make

# try run gtest (google test)
make test

# try run app
cd /opt/ccxx/build/deploy/unix/bin_d
./cxtest_timer
./cxtest_channel_udp_client1
./cxtest_channel_udp_server1
./cxsample_lua
./benchmark_cxstring
# ...

Customize Compile

vim /opt/ccxx/build/cmake/local.all.config.cmake
# e.g. modify -> set(gs_project_enable_uv 1) to set(gs_project_enable_uv 0)
# e.g. modify -> set(gs_project_enable_openssl 1) to set(gs_project_enable_openssl 0)

Compiled pictures for each operating system (en)

各个操作系统编译后的图片 (cn)

Full Compile On Ubuntu

### 1 step: build and install OpenCV 4.1.2 (4c71dbf)
## https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
## https://opencv.org/releases/
# cd /opt/<my_working_directory>
### 1 step: apt insall depend libs
# libopencv-dev
sudo echo "deb http://security.ubuntu.com/ubuntu xenial-security main" | tee /etc/apt/sources.list.d/libjasper.list && \
sudo apt update -y ; apt upgrade -y && \
sudo apt install -y gcc g++ cmake build-essential gdb gdbserver git \
        unixodbc unixodbc-dev libcurl4-openssl-dev uuid uuid-dev libssl-dev libncurses5-dev \
        qt5-default libqt5svg5 libqt5svg5-dev qtcreator \
        libssl-dev libncurses5-dev \
        libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev \
        python3-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev \
        software-properties-common 

### 2 step: git code and make it
cd /opt && \
git clone https://github.com/opencv/opencv.git && \
cd /opt/opencv && git reset --hard 4c71dbf && \
mkdir build && cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j7 && sudo make install

### 3 step: down source and compile
cd /opt && \
git clone https://github.com/oudream/ccxx.git && \
cd ccxx && \
cmake . -DCMAKE_BUILD_TYPE=Debug -DCCXX_BUILD_TYPE=all --build . -B"./build/cmake-gcc" && \
cd build/cmake-gcc && make

### 4 step: run apps
/opt/ccxx/build/deploy/unix/bin_d/cxtest_timer
# or
/opt/ccxx/build/deploy/unix/bin_d/cxtest_channel_udp_client1
# or
/opt/ccxx/build/deploy/unix/bin_d/cxtest_channel_udp_server1
# or
/opt/ccxx/build/deploy/unix/bin_d/cxsample_lua
# or
/opt/ccxx/build/deploy/unix/bin_d/benchmark_cxstring
# ctrl + c to exit
^c
# ...

ccxx source code

examples

test, but not googletest

Tools

Tools On Windows

May be install related dependent libraries according to your needs

Jenkins

Docker

reference

ccxx的交叉编译目录

todo

todo: CxDatabase::loadSql : if loaded count > max return

todo: add libuv channel

todo: exit or signal : reentrant function e.g. : CxLog() <<

About

This is a cross-platform library software library about c, c ++, unix4, posix. Include gtest, benchmark, cmake, process lock, daemon, libuv, lua, cpython, re2, json, yaml, mysql, redis, opencv, qt, lz4, oci ... https://hub.docker.com/u/oudream

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published