Skip to content

Commit

Permalink
Merge branch 'windows_port'
Browse files Browse the repository at this point in the history
  • Loading branch information
smlee-hdactech committed Jan 15, 2019
2 parents f48e4df + 223a983 commit fbb982a
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ json_map_demo/json_map_demo
json_test/json_test

build/
.vs/
_build/
CMakeSettings.json
.vscode/
29 changes: 16 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,22 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}")
endif()

message(${CMAKE_INSTALL_INCLUDEDIR})


set(CPACK_PACKAGE_VERSION_MAJOR 4)
set(CPACK_PACKAGE_VERSION_MINOR 1)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_DESCRIPTION "A C++ JSON Parser/Generator Implemented with Boost Spirit")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/json_spirit.pc.cmakein
${CMAKE_CURRENT_BINARY_DIR}/json_spirit.pc @ONLY)
set(CPACK_PACKAGE_DESCRIPTION "A C++ JSON Parser/Generator Implemented with Boost Spirit")

if(NOT MSVC)
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/json_spirit.pc.cmakein
${CMAKE_CURRENT_BINARY_DIR}/json_spirit.pc @ONLY)
include(CPack)


INSTALL(
FILES
json_spirit/json_spirit_global.h
json_spirit/json_spirit.h
json_spirit/json_spirit_error_position.h
json_spirit/json_spirit_reader.h
Expand All @@ -83,8 +85,9 @@ INSTALL(
json_spirit/json_spirit_writer_template.h
json_spirit/json_spirit_writer_options.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json_spirit)

if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/json_spirit.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}")
endif()


if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
if(NOT MSVC)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/json_spirit.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}")
endif()
endif()
9 changes: 7 additions & 2 deletions json_spirit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ SET(JSON_SPIRIT_SRCS
FIND_PACKAGE(Boost 1.34 REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})



OPTION(BUILD_STATIC_LIBS "Build static libraries" OFF)

if(BUILD_STATIC_LIBS)
ADD_LIBRARY(json_spirit STATIC ${JSON_SPIRIT_SRCS})
install(TARGETS json_spirit ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
else(BUILD_STATIC_LIBS)
ADD_LIBRARY(json_spirit SHARED ${JSON_SPIRIT_SRCS})
install(TARGETS json_spirit LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(WIN32)
install(TARGETS json_spirit RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS json_spirit ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
else()
install(TARGETS json_spirit LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif(BUILD_STATIC_LIBS)
18 changes: 18 additions & 0 deletions json_spirit/json_spirit_global.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef JSON_SPIRIT_GLOBAL_H
#define JSON_SPIRIT_GLOBAL_H

#if (defined _WIN32) || (defined _WIN64)
#define DECL_EXPORT __declspec(dllexport)
#define DECL_IMPORT __declspec(dllimport)
#else
#define DECL_EXPORT
#define DECL_IMPORT
#endif

#if defined(json_spirit_EXPORTS)
# define json_spirit_EXPORT DECL_EXPORT
#else
# define json_spirit_EXPORT DECL_IMPORT
#endif

#endif
49 changes: 25 additions & 24 deletions json_spirit/json_spirit_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# pragma once
#endif

#include "json_spirit_global.h"
#include "json_spirit_value.h"
#include "json_spirit_error_position.h"
#include <iostream>
Expand All @@ -20,43 +21,43 @@ namespace json_spirit
// functions to reads a JSON values

#ifdef JSON_SPIRIT_VALUE_ENABLED
bool read( const std::string& s, Value& value );
bool read( std::istream& is, Value& value );
bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
json_spirit_EXPORT bool read( const std::string& s, Value& value );
json_spirit_EXPORT bool read( std::istream& is, Value& value );
json_spirit_EXPORT bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );

void read_or_throw( const std::string& s, Value& value );
void read_or_throw( std::istream& is, Value& value );
void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
json_spirit_EXPORT void read_or_throw( const std::string& s, Value& value );
json_spirit_EXPORT void read_or_throw( std::istream& is, Value& value );
json_spirit_EXPORT void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
#endif

#if defined( JSON_SPIRIT_WVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING )
bool read( const std::wstring& s, wValue& value );
bool read( std::wistream& is, wValue& value );
bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
json_spirit_EXPORT bool read( const std::wstring& s, wValue& value );
json_spirit_EXPORT bool read( std::wistream& is, wValue& value );
json_spirit_EXPORT bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );

void read_or_throw( const std::wstring& s, wValue& value );
void read_or_throw( std::wistream& is, wValue& value );
void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
json_spirit_EXPORT void read_or_throw( const std::wstring& s, wValue& value );
json_spirit_EXPORT void read_or_throw( std::wistream& is, wValue& value );
json_spirit_EXPORT void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
#endif

#ifdef JSON_SPIRIT_MVALUE_ENABLED
bool read( const std::string& s, mValue& value );
bool read( std::istream& is, mValue& value );
bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
json_spirit_EXPORT bool read( const std::string& s, mValue& value );
json_spirit_EXPORT bool read( std::istream& is, mValue& value );
json_spirit_EXPORT bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );

void read_or_throw( const std::string& s, mValue& value );
void read_or_throw( std::istream& is, mValue& value );
void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
json_spirit_EXPORT void read_or_throw( const std::string& s, mValue& value );
json_spirit_EXPORT void read_or_throw( std::istream& is, mValue& value );
json_spirit_EXPORT void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
#endif

#if defined( JSON_SPIRIT_WMVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING )
bool read( const std::wstring& s, wmValue& value );
bool read( std::wistream& is, wmValue& value );
bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
json_spirit_EXPORT bool read( const std::wstring& s, wmValue& value );
json_spirit_EXPORT bool read( std::wistream& is, wmValue& value );
json_spirit_EXPORT bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );

void read_or_throw( const std::wstring& s, wmValue& value );
void read_or_throw( std::wistream& is, wmValue& value );
void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
json_spirit_EXPORT void read_or_throw( const std::wstring& s, wmValue& value );
json_spirit_EXPORT void read_or_throw( std::wistream& is, wmValue& value );
json_spirit_EXPORT void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
#endif
}

Expand Down
33 changes: 17 additions & 16 deletions json_spirit/json_spirit_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# pragma once
#endif

#include "json_spirit_global.h"
#include "json_spirit_value.h"
#include "json_spirit_writer_options.h"
#include <iostream>
Expand All @@ -20,44 +21,44 @@ namespace json_spirit
// these functions to convert JSON Values to text

#ifdef JSON_SPIRIT_VALUE_ENABLED
void write( const Value& value, std::ostream& os, unsigned int options = 0 );
std::string write( const Value& value, unsigned int options = 0 );
json_spirit_EXPORT void write( const Value& value, std::ostream& os, unsigned int options = 0 );
json_spirit_EXPORT std::string write( const Value& value, unsigned int options = 0 );
#endif

#ifdef JSON_SPIRIT_MVALUE_ENABLED
void write( const mValue& value, std::ostream& os, unsigned int options = 0 );
std::string write( const mValue& value, unsigned int options = 0 );
json_spirit_EXPORT void write( const mValue& value, std::ostream& os, unsigned int options = 0 );
json_spirit_EXPORT std::string write( const mValue& value, unsigned int options = 0 );
#endif

#if defined( JSON_SPIRIT_WVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING )
void write( const wValue& value, std::wostream& os, unsigned int options = 0 );
std::wstring write( const wValue& value, unsigned int options = 0 );
json_spirit_EXPORT void write( const wValue& value, std::wostream& os, unsigned int options = 0 );
json_spirit_EXPORT std::wstring write( const wValue& value, unsigned int options = 0 );
#endif

#if defined( JSON_SPIRIT_WMVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING )
void write( const wmValue& value, std::wostream& os, unsigned int options = 0 );
std::wstring write( const wmValue& value, unsigned int options = 0 );
json_spirit_EXPORT void write( const wmValue& value, std::wostream& os, unsigned int options = 0 );
json_spirit_EXPORT std::wstring write( const wmValue& value, unsigned int options = 0 );
#endif

// these "formatted" versions of the "write" functions are the equivalent of the above functions
// with option "pretty_print"

#ifdef JSON_SPIRIT_VALUE_ENABLED
void write_formatted( const Value& value, std::ostream& os );
std::string write_formatted( const Value& value );
json_spirit_EXPORT void write_formatted( const Value& value, std::ostream& os );
json_spirit_EXPORT std::string write_formatted( const Value& value );
#endif
#ifdef JSON_SPIRIT_MVALUE_ENABLED
void write_formatted( const mValue& value, std::ostream& os );
std::string write_formatted( const mValue& value );
json_spirit_EXPORT void write_formatted( const mValue& value, std::ostream& os );
json_spirit_EXPORT std::string write_formatted( const mValue& value );
#endif

#if defined( JSON_SPIRIT_WVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING )
void write_formatted( const wValue& value, std::wostream& os );
std::wstring write_formatted( const wValue& value );
json_spirit_EXPORT void write_formatted( const wValue& value, std::wostream& os );
json_spirit_EXPORT std::wstring write_formatted( const wValue& value );
#endif
#if defined( JSON_SPIRIT_WMVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING )
void write_formatted( const wmValue& value, std::wostream& os );
std::wstring write_formatted( const wmValue& value );
json_spirit_EXPORT void write_formatted( const wmValue& value, std::wostream& os );
json_spirit_EXPORT std::wstring write_formatted( const wmValue& value );
#endif
}

Expand Down

0 comments on commit fbb982a

Please sign in to comment.