Skip to content

Commit

Permalink
complete cmake projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Madokakaroto authored and Madokakaroto committed Apr 6, 2017
1 parent a965c5f commit 25b442e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -27,3 +27,5 @@
*.exe
*.out
*.app

build
25 changes: 21 additions & 4 deletions CMakeLists.txt
Expand Up @@ -3,8 +3,25 @@ project(iguana)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++14")
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")
set(IGUANA_DIR ${CMAKE_CURRENT_SOURCE_DIR})

set(SOURCE_FILES
example.cpp
)
add_executable(iguana ${SOURCE_FILES})
include_directories(
${IGUANA_DIR}
${IGUANA_DIR}/third_party/msgpack/include
)

set(JSON_EXAMPLE
example/json_example.cpp
)

set(XML_EXAMPLE
example/xml_example.cpp
)

set(MSGPACK_EXAMPLE
example/msgpack_example.cpp
)

add_executable(json_example ${JSON_EXAMPLE})
add_executable(xml_example ${XML_EXAMPLE})
add_executable(msgpack_example ${MSGPACK_EXAMPLE})
29 changes: 29 additions & 0 deletions example/json_example.cpp
@@ -0,0 +1,29 @@
#include <iguana/json.hpp>

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

REFLECTION(person, name, age);
}

int main(void)
{
client::person p = { "zombie chow", 31 };

iguana::string_stream ss;
iguana::json::to_json(ss, p);

auto json_str = ss.str();
std::cout << json_str << std::endl;

client::person p2;
iguana::json::from_json(p2, json_str.data(), json_str.length());

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

0 comments on commit 25b442e

Please sign in to comment.