Skip to content

Commit

Permalink
Introduce new Json library Glaze
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Oct 11, 2024
1 parent a8b0580 commit 19d5cc0
Show file tree
Hide file tree
Showing 39 changed files with 809 additions and 297 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++ programs.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

permissions:
actions: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
docker:
name: Docker build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
matrix:
with-tests: [0, 1]
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/ubuntu-special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ on:
jobs:
ubuntu-special-build:
name: Build on Ubuntu with monitoring / protobuf support
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
compiler: [g++-11]
buildmode: [Debug]
build-special-from-source: [0, 1]
prometheus-options: ["-DBUILD_SHARED_LIBS=ON -DENABLE_PULL=OFF -DENABLE_PUSH=ON -DENABLE_COMPRESSION=OFF -DENABLE_TESTING=OFF"]
Expand All @@ -25,7 +24,6 @@ jobs:
run: |
sudo apt update
sudo apt install cmake libssl-dev git libcurl4-openssl-dev ninja-build -y --no-install-recommends
echo "CC=$(echo ${{matrix.compiler}} | sed -e 's/^g++/gcc/' | sed 's/+//g')" >> $GITHUB_ENV
- name: Install prometheus-cpp
run: |
Expand All @@ -39,14 +37,12 @@ jobs:
sudo cmake --install _build
env:
CXX: ${{matrix.compiler}}
CMAKE_BUILD_TYPE: ${{matrix.buildmode}}
if: matrix.build-special-from-source == 0

- name: Configure CMake
run: cmake -S . -B build -DCCT_BUILD_PROMETHEUS_FROM_SRC=${{matrix.build-special-from-source}} -DCCT_ENABLE_PROTO=${{matrix.build-special-from-source}} -DCCT_ENABLE_ASAN=OFF -GNinja
env:
CXX: ${{matrix.compiler}}
CMAKE_BUILD_TYPE: ${{matrix.buildmode}}

- name: Build
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
jobs:
ubuntu-build:
name: Build on Ubuntu
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
compiler: [g++-11, clang++-18]
compiler: [g++-13, clang++-18]
buildmode: [Debug, Release]

steps:
Expand All @@ -25,14 +25,6 @@ jobs:
sudo apt install cmake libssl-dev libcurl4-openssl-dev ninja-build -y --no-install-recommends
echo "CC=$(echo ${{matrix.compiler}} | sed -e 's/^g++/gcc/' | sed 's/+//g')" >> $GITHUB_ENV
- name: Install gcc
run: |
sudo apt install ${{matrix.compiler}} -y --no-install-recommends
# Temporary workaround for libasan bug stated here: https://github.com/google/sanitizers/issues/1716
sudo sysctl vm.mmap_rnd_bits=28
if: startsWith(matrix.compiler, 'g')

- name: Install clang
run: |
CLANG_VERSION=$(echo ${{matrix.compiler}} | cut -d- -f2)
Expand Down
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if(CCT_ENABLE_TESTS)
enable_testing()
endif()

# nlohmann_json - json library
# nlohmann_json - json container library
find_package(nlohmann_json CONFIG)
if(NOT nlohmann_json_FOUND)
FetchContent_Declare(
Expand All @@ -111,6 +111,18 @@ if(NOT nlohmann_json_FOUND)
list(APPEND fetchContentPackagesToMakeAvailable nlohmann_json)
endif()

# Glaze - fast json serialization library
find_package(glaze CONFIG)
if(NOT glaze)
FetchContent_Declare(
glaze
URL https://github.com/stephenberry/glaze/archive/refs/tags/v3.6.2.tar.gz
URL_HASH SHA256=74b14656b7a47c0a03d0a857adf5059e8c2351a7a84623593be0dd16b293216c
)

list(APPEND fetchContentPackagesToMakeAvailable glaze)
endif()

# prometheus for monitoring support
if(CCT_BUILD_PROMETHEUS_FROM_SRC)
FetchContent_Declare(
Expand Down Expand Up @@ -259,6 +271,8 @@ endif()
# Link to sub folders CMakeLists.txt, from the lowest level to the highest level for documentation
# (beware of cyclic dependencies)
add_subdirectory(src/tech)
add_subdirectory(src/basic-objects)
add_subdirectory(src/schema)
add_subdirectory(src/monitoring)
add_subdirectory(src/http-request)
add_subdirectory(src/objects)
Expand Down
19 changes: 10 additions & 9 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ But they have partial support which is sufficient to build `coincenter`.

The following compilers are known to compile `coincenter` (and are tested in the CI):

- **GCC** version >= 11
- **GCC** version >= 12
- **Clang** version >= 18
- **MSVC** version >= 19.39

Expand Down Expand Up @@ -135,14 +135,15 @@ cmake -S . -B build --preset conan-release
In all cases, they do not need to be installed. If they are not found at configure time, `cmake` will fetch sources and compile them automatically.
If you are building frequently `coincenter` you can install them to speed up its compilation.

| Library | Description | License |
| -------------------------------------------------------------- | -------------------------------------------------- | -------------------- |
| [amc](https://github.com/AmadeusITGroup/amc.git) | High performance C++ containers (maintained by me) | MIT |
| [googletest](https://github.com/google/googletest.git) | Google Testing and Mocking Framework | BSD-3-Clause License |
| [json](https://github.com/nlohmann/json) | JSON for Modern C++ | MIT |
| [spdlog](https://github.com/gabime/spdlog.git) | Fast C++ logging library | MIT |
| [prometheus-cpp](https://github.com/jupp0r/prometheus-cpp.git) | Prometheus Client Library for Modern C++ | MIT |
| [jwt-cpp](https://github.com/Thalhammer/jwt-cpp) | Creating and validating json web tokens in C++ | MIT |
| Library | Description | License |
| -------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------- |
| [amc](https://github.com/AmadeusITGroup/amc.git) | High performance C++ containers (maintained by me) | MIT |
| [googletest](https://github.com/google/googletest.git) | Google Testing and Mocking Framework | BSD-3-Clause License |
| [json container](https://github.com/nlohmann/json) | JSON for Modern C++ | MIT |
| [json serialization](https://github.com/stephenberry/glaze) | Extremely fast, in memory, JSON and interface library for modern C++ | MIT |
| [spdlog](https://github.com/gabime/spdlog.git) | Fast C++ logging library | MIT |
| [prometheus-cpp](https://github.com/jupp0r/prometheus-cpp.git) | Prometheus Client Library for Modern C++ | MIT |
| [jwt-cpp](https://github.com/Thalhammer/jwt-cpp) | Creating and validating json web tokens in C++ | MIT |

### With cmake

Expand Down
2 changes: 1 addition & 1 deletion src/api/exchanges/src/kucoinprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ json PrivateQuery(CurlHandle& curlHandle, const APIKey& apiKey, HttpRequestType
strToSign.push_back('?');
strToSign.append(postData.str());
} else {
strToSign.append(postData.toJson().dump());
strToSign.append(postData.toJsonStr());
postDataFormat = CurlOptions::PostDataFormat::kJson;
}
}
Expand Down
33 changes: 33 additions & 0 deletions src/basic-objects/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Create objects lib
aux_source_directory(src BASIC_OBJECTS_SRC)

add_coincenter_library(basic-objects STATIC ${BASIC_OBJECTS_SRC})

target_link_libraries(coincenter_basic-objects PUBLIC coincenter_tech)

add_unit_test(
currencycode_test
test/currencycode_test.cpp
LIBRARIES
coincenter_tech
DEFINITIONS
CCT_DISABLE_SPDLOG
)

add_unit_test(
market_test
test/market_test.cpp
LIBRARIES
coincenter_basic-objects
DEFINITIONS
CCT_DISABLE_SPDLOG
)

add_unit_test(
monetaryamount_test
test/monetaryamount_test.cpp
LIBRARIES
coincenter_basic-objects
DEFINITIONS
CCT_DISABLE_SPDLOG
)
Loading

0 comments on commit 19d5cc0

Please sign in to comment.