mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-17 06:37:43 -05:00
* Added GTest (googletest) Example The examples tests the Fibonacci library similar to the doctest example. * Add Example for the cereal library. * Update examples/cereal/CMakeLists.txt Co-Authored-By: Lars Melchior <TheLartians@users.noreply.github.com> * Remove Test Coverage Code * Remove Test Coverage Option
35 lines
629 B
C++
35 lines
629 B
C++
#define CATCH_CONFIG_MAIN
|
|
|
|
#include <cereal/cereal.hpp>
|
|
#include <cereal/archives/json.hpp>
|
|
|
|
#include <string>
|
|
#include <sstream>
|
|
|
|
struct player_data
|
|
{
|
|
int id{-1};
|
|
std::string name{};
|
|
};
|
|
|
|
template<typename Archive>
|
|
void serialize(Archive& archive, player_data const &data)
|
|
{
|
|
archive(
|
|
cereal::make_nvp("id", data.id),
|
|
cereal::make_nvp("name", data.name)
|
|
);
|
|
}
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
player_data player{3, "Gamer One"};
|
|
std::ostringstream oss;
|
|
cereal::JSONOutputArchive output(oss);
|
|
output(cereal::make_nvp("player_data", player));
|
|
|
|
std::cout << oss.str() << std::endl;
|
|
|
|
return 0;
|
|
}
|