Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor iguana2 #302

Merged
merged 45 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
41bacce
json writer
qicosmos Aug 22, 2024
2bb8532
use ylt.reflection
qicosmos Aug 23, 2024
2490267
update json example
qicosmos Aug 23, 2024
2fad0db
update json example
qicosmos Aug 26, 2024
0050e2f
fix some compile
qicosmos Aug 26, 2024
df852d0
rename
qicosmos Aug 26, 2024
3ccb253
index_of
qicosmos Aug 26, 2024
9878051
use ylt refl
qicosmos Aug 26, 2024
332d63a
fix compile
qicosmos Aug 26, 2024
451b2fe
format
qicosmos Aug 26, 2024
f492ed6
fix macro
qicosmos Aug 26, 2024
44576dd
for msvc;remove gcc8
qicosmos Aug 27, 2024
7a93b2d
Merge branch 'refactor_iguana' of https://github.com/qicosmos/iguana …
qicosmos Aug 27, 2024
0875402
msvc
qicosmos Aug 27, 2024
db436c1
test msvc
qicosmos Aug 27, 2024
ab2f837
fix for msvc arg count
qicosmos Aug 27, 2024
5ef8bd0
test
qicosmos Aug 27, 2024
486ceaa
members_tuple
qicosmos Aug 29, 2024
ada7f74
use offset
qicosmos Aug 29, 2024
f3cf85b
clean
qicosmos Aug 29, 2024
ff32e93
pb writer
qicosmos Aug 29, 2024
3c31e58
pb writer
qicosmos Aug 29, 2024
7525f64
fix compile
qicosmos Aug 29, 2024
a620135
compile
qicosmos Aug 29, 2024
0f49f2c
compile
qicosmos Aug 29, 2024
e7683e7
pb reader
qicosmos Aug 30, 2024
75dc229
xml writer
qicosmos Aug 30, 2024
e1348ab
pb reader part1
qicosmos Aug 31, 2024
ee80d77
xml compile
qicosmos Aug 31, 2024
b95d004
compile for gcc
qicosmos Sep 2, 2024
97fcf7f
yaml
qicosmos Sep 2, 2024
11e4299
alias method
qicosmos Sep 2, 2024
db7f3ce
alias
qicosmos Sep 3, 2024
cb66680
dynamic
qicosmos Sep 4, 2024
f539404
optimize
qicosmos Sep 4, 2024
dc2746d
update
qicosmos Sep 4, 2024
e609c48
optimize performance
qicosmos Sep 5, 2024
f08ec4f
remove and improve
qicosmos Sep 5, 2024
2094cc3
pb_field
qicosmos Sep 5, 2024
2cfe76c
tuple view
qicosmos Sep 5, 2024
77ffd96
for compile
qicosmos Sep 5, 2024
9a37ca7
compile
qicosmos Sep 5, 2024
130157f
compile
qicosmos Sep 5, 2024
bcb84c2
for msvc
qicosmos Sep 5, 2024
126745f
for damn it msvc
qicosmos Sep 5, 2024
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
44 changes: 22 additions & 22 deletions .github/workflows/linux-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,31 @@ jobs:
working-directory: ${{ github.workspace }}/build
run: ctest -C ${{ matrix.mode }} -j 1 -V

ubuntu_gcc8:
strategy:
matrix:
mode: [ Debug, Release ]
cpp_version: [17]
runs-on: ubuntu-20.04
# ubuntu_gcc8:
# strategy:
# matrix:
# mode: [ Debug, Release ]
# cpp_version: [17]
# runs-on: ubuntu-20.04

steps:
- name: check out
uses: actions/checkout@v3
# steps:
# - name: check out
# uses: actions/checkout@v3

- name: Install GCC8
run: |
sudo apt update
sudo apt install gcc-8 g++-8
# - name: Install GCC8
# run: |
# sudo apt update
# sudo apt install gcc-8 g++-8

- name: checkout gcc version
run: gcc-8 --version
# - name: checkout gcc version
# run: gcc-8 --version

- name: configure cmake
run: CXX=g++-8 CC=gcc-8 cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }}
# - name: configure cmake
# run: CXX=g++-8 CC=gcc-8 cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }}

- name: build project
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.mode }}
# - name: build project
# run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.mode }}

- name: test
working-directory: ${{ github.workspace }}/build
run: ctest -C ${{ matrix.mode }} -j 1 -V
# - name: test
# working-directory: ${{ github.workspace }}/build
# run: ctest -C ${{ matrix.mode }} -j 1 -V
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ set(YAML_EXAMPLE
example/yaml_example.cpp
)

set(TEST_SOME test/test.cpp)
set(TEST_SOME test/test_some.cpp)
set(TEST_UT test/unit_test.cpp)
set(TEST_JSON_FILES test/test_json_files.cpp)
set(TEST_XML test/test_xml.cpp)
Expand All @@ -88,6 +88,7 @@ set(TEST_UTIL test/test_util.cpp)
set(TEST_XMLNOTHROW test/test_xml_nothrow.cpp)
set(TEST_PB test/test_pb.cpp)
set(TEST_PROTO test/test_proto3.cpp)
set(TEST_CPP20 test/test_cpp20.cpp)
set(PB_BENCHMARK benchmark/pb_benchmark.cpp)

add_executable(json_example ${JSON_EXAMPLE})
Expand All @@ -105,6 +106,7 @@ add_executable(yaml_benchmark ${YAMLBENCH})
add_executable(test_nothrow ${TEST_NOTHROW})
add_executable(test_util ${TEST_UTIL})
add_executable(test_pb ${TEST_PB})
add_executable(test_cpp20 ${TEST_CPP20})

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9)
Expand Down Expand Up @@ -166,4 +168,5 @@ add_test(NAME test_yaml COMMAND test_yaml)
add_test(NAME test_nothrow COMMAND test_nothrow)
add_test(NAME test_util COMMAND test_util)
add_test(NAME test_xml_nothrow COMMAND test_xml_nothrow)
add_test(NAME test_pb COMMAND test_pb)
add_test(NAME test_pb COMMAND test_pb)
add_test(NAME test_cpp20 COMMAND test_cpp20)
30 changes: 18 additions & 12 deletions benchmark/json_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "json_benchmark.h"

class ScopedTimer {
public:
public:
ScopedTimer(const char *name)
: m_name(name), m_beg(std::chrono::high_resolution_clock::now()) {}
ScopedTimer(const char *name, uint64_t &ns) : ScopedTimer(name) {
Expand All @@ -18,7 +18,7 @@ class ScopedTimer {
<< std::setw(12) << dur.count() << " ns\n";
}

private:
private:
const char *m_name;
std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
uint64_t *m_ns = nullptr;
Expand Down Expand Up @@ -60,7 +60,8 @@ struct fixed_name_object_t {
std::string name4{};

#ifdef HAS_RAPIDJSON
template <typename Writer> void Serialize(Writer &writer) const {
template <typename Writer>
void Serialize(Writer &writer) const {
writer.StartObject();
writer.String("name0");
writer.String(name0);
Expand All @@ -76,14 +77,15 @@ struct fixed_name_object_t {
}
#endif
};
REFLECTION(fixed_name_object_t, name0, name1, name2, name3, name4);
YLT_REFL(fixed_name_object_t, name0, name1, name2, name3, name4);

struct nested_object_t {
std::vector<std::array<double, 3>> v3s{};
std::string id{};

#ifdef HAS_RAPIDJSON
template <typename Writer> void Serialize(Writer &writer) const {
template <typename Writer>
void Serialize(Writer &writer) const {
writer.StartObject();
writer.String("v3s");
writer.StartArray();
Expand All @@ -103,7 +105,7 @@ struct nested_object_t {
}
#endif
};
REFLECTION(nested_object_t, v3s, id);
YLT_REFL(nested_object_t, v3s, id);

struct another_object_t {
std::string string{};
Expand All @@ -112,7 +114,8 @@ struct another_object_t {
nested_object_t nested_object{};

#ifdef HAS_RAPIDJSON
template <typename Writer> void Serialize(Writer &writer) const {
template <typename Writer>
void Serialize(Writer &writer) const {
writer.StartObject();
writer.String("string");
writer.String(string);
Expand All @@ -126,7 +129,7 @@ struct another_object_t {
}
#endif
};
REFLECTION(another_object_t, string, another_string, boolean, nested_object);
YLT_REFL(another_object_t, string, another_string, boolean, nested_object);

struct obj_t {
// fixed_object_t fixed_object{};
Expand All @@ -139,7 +142,8 @@ struct obj_t {
bool another_bool{};

#ifdef HAS_RAPIDJSON
template <typename Writer> void Serialize(Writer &writer) const {
template <typename Writer>
void Serialize(Writer &writer) const {
writer.StartObject();
writer.String("fixed_name_object");
fixed_name_object.Serialize(writer);
Expand Down Expand Up @@ -167,8 +171,8 @@ struct obj_t {
}
#endif
};
REFLECTION(obj_t, fixed_name_object, another_object, string_array, string,
number, boolean, another_bool);
YLT_REFL(obj_t, fixed_name_object, another_object, string_array, string, number,
boolean, another_bool);

obj_t create_object() {
fixed_name_object_t fix_obj = {"James", "Abraham", "Susan", "Frank",
Expand Down Expand Up @@ -283,7 +287,9 @@ void test_from_json_file() {
for (auto &pair : test_map) {
auto content = iguana::json_file_content(pair.first);
std::visit(
[&](auto &&arg) { test_from_json(pair.first, arg, content, 10); },
[&](auto &&arg) {
test_from_json(pair.first, arg, content, 10);
},
pair.second);
}
}
Expand Down
Loading
Loading