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

iguana: add version 1.0.6 #25439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions recipes/iguana/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.0.6":
url: "https://github.com/qicosmos/iguana/archive/refs/tags/1.0.6.tar.gz"
sha256: "cfacf1cce4ebe49b947ec823f93a23c2a7fd220f67f6847e9f449e7c469deb9e"
"1.0.5":
url: "https://github.com/qicosmos/iguana/archive/refs/tags/1.0.5.tar.gz"
sha256: "b7a7385c49574a60f9f6bf887c1addbc08f557a0117bf18cf7eec532ac2536b1"
Expand Down
6 changes: 5 additions & 1 deletion recipes/iguana/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ project(test_package LANGUAGES CXX)

find_package(iguana REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
if(iguana_VERSION VERSION_GREATER_EQUAL "1.0.6")
add_executable(${PROJECT_NAME} test_package.cpp)
else()
add_executable(${PROJECT_NAME} test_package_1_0_5.cpp)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE iguana::iguana)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
13 changes: 10 additions & 3 deletions recipes/iguana/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iostream>
#include <iguana/json_reader.hpp>
#include <iguana/json_writer.hpp>

Expand All @@ -7,20 +8,26 @@ struct person {
int64_t age;
};

REFLECTION(person, name, age);
#if __cplusplus < 202002L
YLT_REFL(person, name, age);
#endif
} // namespace client

struct MyStruct {
uint64_t a;
};
REFLECTION(MyStruct, a);
#if __cplusplus < 202002L
YLT_REFL(MyStruct, a);
#endif

struct student {
int id;
std::string name;
int age;
};
REFLECTION(student, id, name, age);
#if __cplusplus < 202002L
YLT_REFL(student, id, name, age);
#endif

void test() {
MyStruct p = {5566777755311};
Expand Down
81 changes: 81 additions & 0 deletions recipes/iguana/all/test_package/test_package_1_0_5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include <iguana/json_reader.hpp>
#include <iguana/json_writer.hpp>

namespace client {
struct person {
std::string name;
int64_t age;
};

REFLECTION(person, name, age);
} // namespace client

struct MyStruct {
uint64_t a;
};
REFLECTION(MyStruct, a);

struct student {
int id;
std::string name;
int age;
};
REFLECTION(student, id, name, age);

void test() {
MyStruct p = {5566777755311};
iguana::string_stream ss;
iguana::to_json(p, ss);

MyStruct p2;
iguana::from_json(p2, ss);
std::cout << p2.a << std::endl;
}

void test_v() {
client::person p1 = {"tom", 20};
client::person p2 = {"jack", 19};
client::person p3 = {"mike", 21};

std::vector<client::person> v{p1, p2, p3};
iguana::string_stream ss;
iguana::to_json(v, ss);
std::cout << ss << std::endl;

std::vector<client::person> v1;
iguana::from_json(v1, ss);
}

void test_disorder() {
student s{1, "tom", 20};
iguana::string_stream ss;
iguana::to_json(s, ss);
std::cout << ss << std::endl;

student s1{};
std::string str = "{\"name\":\"tom\",\"id\":1,\"age\":20}";
iguana::from_json(s1, str.data(), str.length());
std::string str1 = "{\"name\":\"tom\",\"age\":20,\"id\":1}";
iguana::from_json(s1, str1.data(), str1.length());

std::string str2 = "{ \"id\":1,\"name\" : \"madoka\",\"age\" : 27 }";
iguana::from_json(s1, str2.data(), str2.length());
}

int main(void) {
test_disorder();
test_v();
test();
client::person p = {"zombie chow", -311};
iguana::string_stream ss;
iguana::to_json(p, ss);

std::cout << ss << std::endl;
client::person p2;

iguana::from_json(p2, ss.data(), ss.length());

std::cout << p2.name << " - " << p2.age << std::endl;

return 0;
}
2 changes: 2 additions & 0 deletions recipes/iguana/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"1.0.6":
folder: all
"1.0.5":
folder: all
"1.0.4":
Expand Down
Loading