- This is a cross-platform library software library about c, c ++, unix4, posix.
- This library has been continuously developed for more than three years, and it serves as the underlying support for many large projects.
- Incorporate unit test, benchmark test, cmake, process monitoring, daemon, asynchronous libraries libuv, lua, cpython, re2, json, yaml, mysql, redis, opencv, qt, lz4, oci ...
- 這是關於c,c ++,unix4,posix的跨平台庫軟體庫。
- 這個函式庫已經連續開發了三年多,它為許多大型專案提供了基礎支援。
- 合併了單元測試,基準測試,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 平行分散式測試。
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 iciunction the icis function the On. 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.
ccxx的核心函式庫程式碼在根目錄下ccxx資料夾中,大概有(14MB 左右)。模組大多以一個檔案.cpp來完成功能,預設靜態類別方式直接呼叫)。例子可參考sample 及test 的目錄。
- cxappenv.h: 運作環境(執行程式名稱, 工作目錄, 環境變數)
- cxinterinfo.h: 程式的資訊輸入輸出介面。實作有: cxlog.h(日誌), CxConsoleInterinfo(終端)
- cxfile.h: 檔案系統
- cxsocket.h: 網路通信
- cxthread.h: 線程訊號,IPC
- cxapplication.h 類似(Node.js)中的Event Loop。採用wait 訊號機制對事件隊列進行輪詢並執行。目前參與到Event Loop 中的有(cxchannel.h, cxtimer.h)。 cxapplication_qt.h 是Qt 參與到Qt 的Event Loop。
- cxchannel.h: (要實例化來使用)開獨立執行緒進行收發和監聽,收到資料及事件push 到主執行緒的Event Loop 中,因此資料不需要跨線加鎖。實作有: cxchannel_udp.h, cxchannel_tcpserver.h, cxchannel_tcpclient.h, cxchannel_serial.h
- cxcrc.h: 資料檢驗
- cxdatabase.h: (要實例化來使用)以表格的方式統一資料操作的介面類別。實作有:cxdatabase_odbc.h, cxdatabase_sqlite.h(直接呼叫官方sqlite3.c來實作相關函數)
- cxprocess.h: 系統進程
- cxprocmutex.h: 進程鎖
- cxtimer.h: (要實例化來使用)定時器
- cxtime.h: 時間與日期
- cxuuid.h: GUID, UUID
- cxsharememory.h: 共享記憶體,進程間通訊IPC (InterProcess Communication)
- cxprofile.h: (要實例化來使用)設定檔以表格的方式封閉使用。實作有: cxprofile_skv_json.h, cxprofile_skv_xml.h。 (skv: section key value)
- cxencoding.h: 實現GBK 與UTF-8 之間的轉換
- cxlua資料夾: 以lua 的方式公開ccxx 功能塊,lua_run.h 是main的入口。
- 其它第三方封裝有(cxhiredis.h(Redis的封閉), cxtinyxml.h(Xml檔案讀寫), cxrapidjson.h(正規表示式),lz4.h(壓縮解壓縮))
- gtest, luv, benchmark, yaml 的自身原始碼已經放到3rd 中。
- openssl, curl 是以頭檔加函式庫的方式
- c++ call python(callpython)(./ccxx/sample/callpython), python call c++(cxpython)(./ccxx/ccxx/cxpython). referto https://github.com/oudream/hello-cmake
- opencv 的官方範例程式碼用cmake已經包含進來,並且能編譯以方便試驗。
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 是 cple cvalled directles) For exase reamples to exase referalled the directory of sample and test.
- cxappenv.h: running environment (run program name, working directory, environment variables)
- cxinterinfo.h: program information input and output interface. Implementations are: cxlog.h (log), CxConsoleInterinfo (terminal)
- cxfile.h: file system
- cxsocket.h: network communication
- cxthread.h: thread signal, IPC
- 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 (cxchanmerh.h, cxtimer.h). cxtiappmer.h)。 the event loop where Qt participates in Qt.
- 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 lock Loop of the main thread, so the data does not need to be locked Imple lines. : cxchannel_udp.h, cxchannel_tcpserver.h, cxchannel_tcpclient.h, cxchannel_serial.h
- cxcrc.h: data check
- 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.cunc toeves relsqlite.h (directly call the official sqlite3.cunc toeves)
- cxprocess.h: system process
- cxprocmutex.h: process lock
- cxtimer.h: (to be instantiated to use) timer
- cxtime.h: time and date
- cxuuid.h: GUID, UUID
- cxsharememory.h: shared memory, IPC (InterProcess Communication)
- 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)
- cxencoding.h: convert between GBK and UTF-8
- cxlua folder: exposes ccxx function blocks in lua, lua_run.h is the main entry.
- 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))
- gtest, luv, benchmark, yaml's own source code has been placed in 3rd.
- openssl, curl is a header file plus library
- 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)
- The official sample code for opencv has been included with cmake and can be compiled for easy testing.
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
- ODBC : ccxx_database_odbc is a library for connecting databases with odbc
- ODBC : ccxx_database_odbc 是一個用odbc 連接資料庫的函式庫
- UUID : Except for windows, CxUuid (uuid) is implemented using the libuuid library
- 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
# 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
# ...
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)
各個作業系統編譯後的圖片(cn)
# ## 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
# ...
todo: CxDatabase::loadSql : if loaded count > max return
todo: add libuv channel
todo: exit or signal : reentrant function eg : CxLog() <<