Skip to content

Commit

Permalink
fixed serialization_examples to use boost, and moved it to boost exam…
Browse files Browse the repository at this point in the history
…ples. Changed CmakeLists to create separate executables for each source
  • Loading branch information
2208loki committed Nov 10, 2024
1 parent 0a7743a commit 0bd72b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
19 changes: 13 additions & 6 deletions examples/build/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ include_directories (../../include

file(GLOB_RECURSE Example_sources ../../src/*.cpp)

add_executable (jsoncons_examples ${Example_sources})

if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# special link option on Linux because llvm stl rely on GNU stl
target_link_libraries (jsoncons_examples -Wl,-lstdc++)
endif()
# Loop through each example file and create an executable for each
foreach(example_file ${Example_sources})
# Extract the filename without path and extension
get_filename_component(example_name ${example_file} NAME_WE)

# Create an executable with the example name and file
add_executable(${example_name} ${example_file})

if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# special link option on Linux because llvm stl rely on GNU stl
target_link_libraries(${example_name} -Wl,-lstdc++)
endif()
endforeach()
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include <jsoncons/json.hpp>
#include <iomanip>
#include <assert.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace jsoncons;
namespace boost_mp = boost::multiprecision;

void serialization_example1()
{
Expand Down Expand Up @@ -409,7 +411,8 @@ void bignum_access_examples()
// If your compiler supports extended integral types
#if (defined(__GNUC__) || defined(__clang__)) && defined(JSONCONS_HAS_INT128)
__int128 i = j.as<__int128>();
std::cout << "(4) " << i << "\n\n";
boost_mp::int128_t boost_i = static_cast<boost_mp::int128_t>(i);
std::cout << "(4) " << boost_i << "\n\n";
#endif
}

Expand Down Expand Up @@ -485,7 +488,9 @@ int main()
decimal_precision_examples();
bignum_access_examples();
chinese_char();
chinese_uchar8_t();
#ifdef __cpp_char8_t
chinese_uchar8_t();
#endif
std::cout << std::endl;
}

0 comments on commit 0bd72b7

Please sign in to comment.