Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a0004a5
[#286] added ifdef std::expected and separated parts common to both c…
jowillianto Dec 14, 2024
83ae753
[#286] Broken API by returning rfl::Error on error() instead of std::…
jowillianto Dec 15, 2024
d388e82
[#286] update parser with respect to api breaking
jowillianto Dec 15, 2024
fd35f72
[#286] throw runtime error when error() is accessed without it having…
jowillianto Dec 15, 2024
20cbdc2
[#286] Use rfl::Error::make_for_result to differentiate between error…
jowillianto Jan 13, 2025
54f2918
[#286] Use rfl::Unexpected
jowillianto Jan 19, 2025
a882706
[#286] fix documentation
jowillianto Jan 19, 2025
353d18e
[#286] test simultaneously with c++23 and c++20
jowillianto Jan 30, 2025
10d588a
[#286] merge with main branch
jowillianto Jan 30, 2025
49466b8
Updated the submoduke
liuzicheng1987 Feb 1, 2025
03a03b2
Added an error(...) utility function
liuzicheng1987 Feb 1, 2025
4f7192a
Improved comments
liuzicheng1987 Feb 1, 2025
d0a9a3a
Make sure it compiles on Linux
liuzicheng1987 Feb 1, 2025
8226967
Added REFLECTCPP_CXX23
liuzicheng1987 Feb 1, 2025
dce4379
Removed more instances of Error(...)
liuzicheng1987 Feb 1, 2025
6587b3e
Use same_as_v
liuzicheng1987 Feb 1, 2025
2a2e752
Use std::is_same()
liuzicheng1987 Feb 1, 2025
69bd1da
Fix typo
liuzicheng1987 Feb 1, 2025
6de8aa4
Fixed benchmarks
liuzicheng1987 Feb 1, 2025
9a9c510
Fixed person.cpp
liuzicheng1987 Feb 1, 2025
f356acf
Added explicit tests for C++23 on Linux
liuzicheng1987 Feb 1, 2025
7da6753
Renamed the Linux pipeline
liuzicheng1987 Feb 1, 2025
2c98753
Fixed typo
liuzicheng1987 Feb 1, 2025
f9e9578
Minor fix in the Reader
liuzicheng1987 Feb 1, 2025
298b7da
Added CXX23 tests for macOS and Windows
liuzicheng1987 Feb 1, 2025
0eedb80
Don't use move - they are views anyway
liuzicheng1987 Feb 1, 2025
e241905
Fixed typo
liuzicheng1987 Feb 1, 2025
a7aa15a
Moved all functions related to results into the header files
liuzicheng1987 Feb 1, 2025
7ba6b6a
Added missing reference
liuzicheng1987 Feb 1, 2025
d9f9611
Designed std::expected as an explicit opt-in
liuzicheng1987 Feb 1, 2025
13e3107
Only do GCC on linux for C++ 23 (LLVM does not appear to support it yet)
liuzicheng1987 Feb 1, 2025
1f721af
Cap'n proto does not appear to support C++23 on platforms other than …
liuzicheng1987 Feb 1, 2025
535a2ac
Remove from conan as well
liuzicheng1987 Feb 1, 2025
8d9e274
Always use the error helper function
liuzicheng1987 Feb 1, 2025
8862ce5
Removing the macOS and Windows C++23 build pipelines (they seem to be…
liuzicheng1987 Feb 1, 2025
0533312
Added documentation
liuzicheng1987 Feb 1, 2025
d87d9b0
Added clang-19 to the testing pipeline
liuzicheng1987 Feb 2, 2025
10d38aa
Install clang-19, if necessary
liuzicheng1987 Feb 2, 2025
56c4a50
Fixed typo
liuzicheng1987 Feb 2, 2025
5c13eec
Another attempt to make Clang-19 work
liuzicheng1987 Feb 2, 2025
3f1cedd
Remove clang-19 check
liuzicheng1987 Feb 2, 2025
28308d4
[#286] set required standard for REFLECTCPP_USE_STD_EXPECTED=ON(cxx23…
jowillianto Feb 3, 2025
0c73fbe
Allow user to override the standard used
liuzicheng1987 Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: linux
name: linux-cxx20

on: [ pull_request, workflow_dispatch ]

Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
sudo ln -s $(which ccache) /usr/local/bin/$CC
sudo ln -s $(which ccache) /usr/local/bin/$CXX
$CXX --version
cmake -S . -B build -G Ninja -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Run tests
run: |
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/linux-cxx23.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: linux-cxx23

on: [ pull_request, workflow_dispatch ]

env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

jobs:
linux:
strategy:
fail-fast: false
matrix:
include:
- compiler: gcc
compiler-version: 13
- compiler: gcc
compiler-version: 14
name: "${{ github.job }} (${{ matrix.compiler }}-${{ matrix.compiler-version }})"
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: "${{ github.job }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}"
max-size: "2G"
- name: Run vcpkg
uses: lukka/run-vcpkg@v11
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y ninja-build ${{ matrix.additional-dep }}
- name: Install Conan
run: |
sudo apt install -y pipx
pipx install conan
conan profile detect
- name: Make sure the library compiles with Conan
run: conan build . --build=missing -s compiler.cppstd=gnu23 -o *:with_capnproto=True -o *:with_cbor=True -o *:with_flatbuffers=True -o *:with_msgpack=True -o *:with_toml=True -o *:with_ubjson=True -o *:with_xml=True -o *:with_yaml=True
- name: Compile
run: |
if [[ "${{ matrix.compiler }}" == "llvm" ]]; then
export CC=clang-${{ matrix.compiler-version }}
export CXX=clang++-${{ matrix.compiler-version }}
elif [[ "${{ matrix.compiler }}" == "gcc" ]]; then
export CC=gcc-${{ matrix.compiler-version }}
export CXX=g++-${{ matrix.compiler-version }}
fi
sudo ln -s $(which ccache) /usr/local/bin/$CC
sudo ln -s $(which ccache) /usr/local/bin/$CXX
$CXX --version
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=23 -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release -DREFLECTCPP_USE_STD_EXPECTED=ON
cmake --build build
- name: Run tests
run: |
ctest --test-dir build --output-on-failure
- name: Run benchmarks
run: |
echo '# Benchmarks' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks across different formats' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks for JSON' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=licenses >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: macos-clang
name: macos-cxx20

on: [ pull_request, workflow_dispatch ]

Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
export CMAKE_GENERATOR=Ninja
fi
$CXX --version
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
cmake --build build -j 4
- name: Run tests
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: windows-msvc
name: windows-cxx20

on: [ pull_request, workflow_dispatch ]

Expand All @@ -24,7 +24,7 @@ jobs:
- uses: lukka/run-vcpkg@v11
- name: Compile
run: |
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j4
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Precompiled Headers
*.gch
*.pch

.cache
# Compiled Dynamic libraries
*.so
*.dylib
Expand Down
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ option(REFLECTCPP_BUILD_TESTS "Build tests" OFF)

option(REFLECTCPP_USE_BUNDLED_DEPENDENCIES "Use the bundled dependencies" ON)

option(REFLECTCPP_USE_STD_EXPECTED "Use std::expected instead of the built-in Result type (requires C++-23)" OFF)

if(REFLECTCPP_USE_STD_EXPECTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DREFLECTCPP_USE_STD_EXPECTED")
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 23)
endif()
else()
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
endif()

set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(REFLECTCPP_USE_VCPKG_DEFAULT OFF)

if(REFLECTCPP_BUILD_BENCHMARKS)
Expand Down Expand Up @@ -51,8 +66,6 @@ endif ()

project(reflectcpp VERSION 0.17.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)

if (REFLECTCPP_BUILD_SHARED)
add_library(reflectcpp SHARED)
set_target_properties(reflectcpp PROPERTIES SOVERSION ${PROJECT_VERSION})
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ https://conan.io/center/recipes/reflect-cpp
This will compile reflect-cpp with JSON support only. You can then include reflect-cpp in your project and link to the binary.

```bash
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release
cmake --build build -j 4 # gcc, clang
cmake --build build --config Release -j 4 # MSVC
```
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ this repository to learn how to install vcpkg.
To compile the benchmarks, do the following:

```bash
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DREFLECTCPP_BUILD_BENCHMARKS=ON
cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release -DREFLECTCPP_BUILD_BENCHMARKS=ON
cmake --build build -j 4 # gcc, clang
cmake --build build --config Release -j 4 # MSVC
```
Expand Down
30 changes: 15 additions & 15 deletions benchmarks/all/canada_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void BM_canada_read_reflect_cpp_avro(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::avro::read<FeatureCollection>(data, schema);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -66,7 +66,7 @@ static void BM_canada_read_reflect_cpp_bson(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::bson::read<FeatureCollection>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -78,7 +78,7 @@ static void BM_canada_read_reflect_cpp_capnproto(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::capnproto::read<FeatureCollection>(data, schema);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -89,7 +89,7 @@ static void BM_canada_read_reflect_cpp_cbor(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::cbor::read<FeatureCollection>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -102,7 +102,7 @@ static void BM_canada_read_reflect_cpp_cbor_without_field_names(
const auto res =
rfl::cbor::read<FeatureCollection, rfl::NoFieldNames>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -113,7 +113,7 @@ static void BM_canada_read_reflect_cpp_flexbuf(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::flexbuf::read<FeatureCollection>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -126,7 +126,7 @@ static void BM_canada_read_reflect_cpp_flexbuf_without_field_names(
const auto res =
rfl::flexbuf::read<FeatureCollection, rfl::NoFieldNames>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -137,7 +137,7 @@ static void BM_canada_read_reflect_cpp_json(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::json::read<FeatureCollection>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -150,7 +150,7 @@ static void BM_canada_read_reflect_cpp_json_without_field_names(
const auto res =
rfl::json::read<FeatureCollection, rfl::NoFieldNames>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -161,7 +161,7 @@ static void BM_canada_read_reflect_cpp_msgpack(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::msgpack::read<FeatureCollection>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -174,7 +174,7 @@ static void BM_canada_read_reflect_cpp_msgpack_without_field_names(
const auto res =
rfl::msgpack::read<FeatureCollection, rfl::NoFieldNames>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -185,7 +185,7 @@ static void BM_canada_read_reflect_cpp_toml(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::toml::read<FeatureCollection>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -196,7 +196,7 @@ static void BM_canada_read_reflect_cpp_ubjson(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::ubjson::read<FeatureCollection>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -209,7 +209,7 @@ static void BM_canada_read_reflect_cpp_ubjson_without_field_names(
const auto res =
rfl::ubjson::read<FeatureCollection, rfl::NoFieldNames>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand All @@ -220,7 +220,7 @@ static void BM_canada_read_reflect_cpp_yaml(benchmark::State &state) {
for (auto _ : state) {
const auto res = rfl::yaml::read<FeatureCollection>(data);
if (!res) {
std::cout << res.error()->what() << std::endl;
std::cout << res.error().what() << std::endl;
}
}
}
Expand Down
Loading
Loading