-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:getml/reflect-cpp
- Loading branch information
Showing
13 changed files
with
273 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,7 @@ | |
*.yaml | ||
|
||
!vcpkg.json | ||
|
||
# clangd | ||
compile_flags.txt | ||
compile_commands.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@PACKAGE_INIT@ | ||
|
||
set(REFLECTCPP_BSON @REFLECTCPP_BSON@) | ||
set(REFLECTCPP_FLEXBUFFERS @REFLECTCPP_FLEXBUFFERS@) | ||
set(REFLECTCPP_TOML @REFLECTCPP_TOML@) | ||
set(REFLECTCPP_XML @REFLECTCPP_XML@) | ||
set(REFLECTCPP_YAML @REFLECTCPP_YAML@) | ||
|
||
if(REFLECTCPP_BSON OR REFLECTCPP_FLEXBUFFERS OR REFLECTCPP_XML OR REFLECTCPP_YAML) | ||
include(CMakeFindDependencyMacro) | ||
endif() | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/reflectcpp-exports.cmake) | ||
|
||
|
||
if (REFLECTCPP_BSON) | ||
find_dependency(bson-1.0) | ||
endif () | ||
|
||
if (REFLECTCPP_FLEXBUFFERS) | ||
find_dependency(flatbuffers) | ||
endif () | ||
|
||
if (REFLECTCPP_TOML) | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(tomlplusplus REQUIRED IMPORTED_TARGET tomlplusplus) | ||
endif() | ||
|
||
if (REFLECTCPP_XML) | ||
find_dependency(pugixml) | ||
endif () | ||
|
||
if (REFLECTCPP_YAML) | ||
find_dependency(yaml-cpp) | ||
endif () | ||
|
||
check_required_components(reflectcpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <cassert> | ||
#include <iostream> | ||
#include <rfl.hpp> | ||
#include <source_location> | ||
|
||
namespace test_inheritance { | ||
|
||
void test() { | ||
std::cout << std::source_location::current().function_name() << std::endl; | ||
|
||
struct S { | ||
int x; | ||
}; | ||
|
||
struct T : S {}; | ||
|
||
const auto name = get<0>(rfl::fields<T>()).name(); | ||
if (name == "x") { | ||
std::cout << "OK" << std::endl; | ||
} else { | ||
std::cout << "FAIL\n" | ||
<< "Expected member name 'x', got '" << name << "'" << std::endl; | ||
} | ||
} | ||
|
||
} // namespace test_inheritance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace test_inheritance{ | ||
void test(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <cassert> | ||
#include <iostream> | ||
#include <rfl.hpp> | ||
|
||
#include "rfl/internal/num_fields.hpp" | ||
|
||
namespace test_inheritance2 { | ||
|
||
struct EmptyBase1 {}; | ||
struct EmptyBase2 {}; | ||
struct Derived1 : public EmptyBase1 { | ||
int x; | ||
int y; | ||
}; | ||
struct Derived2 : public EmptyBase1, public EmptyBase2 { | ||
int x; | ||
int y; | ||
int z; | ||
}; | ||
|
||
struct BaseX { | ||
int x; | ||
int y; | ||
}; | ||
struct EmptyDerived0 : BaseX, EmptyBase1 {}; | ||
struct EmptyDerived1 : EmptyBase1, BaseX {}; | ||
struct EmptyDerived2 : EmptyBase1, EmptyBase2, BaseX {}; | ||
|
||
void test() { | ||
Derived1 derived1; | ||
const auto derived1_view = rfl::to_view(derived1); | ||
static_assert(derived1_view.size() == 2); | ||
Derived2 derived2; | ||
const auto derived2_view = rfl::to_view(derived2); | ||
static_assert(derived2_view.size() == 3); | ||
|
||
EmptyDerived1 empty_derived0; | ||
auto empty_derived0_view = rfl::to_view(empty_derived0); | ||
static_assert(empty_derived0_view.size() == 2); | ||
|
||
EmptyDerived1 empty_derived1; | ||
auto empty_derived1_view = rfl::to_view(empty_derived1); | ||
static_assert(empty_derived1_view.size() == 2); | ||
|
||
EmptyDerived1 empty_derived2; | ||
auto empty_derived2_view = rfl::to_view(empty_derived2); | ||
static_assert(empty_derived0_view.size() == 2); | ||
|
||
std::cout << "OK\n"; | ||
} | ||
|
||
} // namespace test_inheritance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace test_inheritance2 { | ||
void test(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.