1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
diff --git a/.travis.yml b/.travis.yml
index e5b56eb..87f2926 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,4 +14,4 @@ script:
- cmake --build . --target all --
after_script:
- - ctest
+ - ctest
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fb24877..a10a49f 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,15 +60,17 @@ endif()
message(${CMAKE_INSTALL_INCLUDEDIR})
-
+
set(CPACK_PACKAGE_VERSION_MAJOR 4)
set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 8)
set(CPACK_PACKAGE_DESCRIPTION "A C++ JSON Parser/Generator Implemented with Boost Spirit")
include(CPack)
-
+
+set(EXPORT_HEADERS )
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
@@ -80,4 +82,4 @@ INSTALL(
json_spirit/json_spirit_writer_template.h
json_spirit/json_spirit_writer_options.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json_spirit)
-
+
diff --git a/json_spirit/CMakeLists.txt b/json_spirit/CMakeLists.txt
index 23da64c..10d4e2b 100755
--- a/json_spirit/CMakeLists.txt
+++ b/json_spirit/CMakeLists.txt
@@ -15,13 +15,19 @@ 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})
+ 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_BINDIR})
+ install(TARGETS json_spirit ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ else()
+ install(TARGETS json_spirit LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+
endif(BUILD_STATIC_LIBS)
diff --git a/json_spirit/json_spirit_global.h b/json_spirit/json_spirit_global.h
new file mode 100644
index 0000000..07a7d2c
--- /dev/null
+++ b/json_spirit/json_spirit_global.h
@@ -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
\ No newline at end of file
diff --git a/json_spirit/json_spirit_reader.h b/json_spirit/json_spirit_reader.h
index a6cfac7..50cc6f5 100755
--- a/json_spirit/json_spirit_reader.h
+++ b/json_spirit/json_spirit_reader.h
@@ -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>
@@ -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
}
diff --git a/json_spirit/json_spirit_writer.h b/json_spirit/json_spirit_writer.h
index 2722780..f60dc07 100755
--- a/json_spirit/json_spirit_writer.h
+++ b/json_spirit/json_spirit_writer.h
@@ -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>
@@ -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
}
diff --git a/json_test/json_spirit_value_test.cpp b/json_test/json_spirit_value_test.cpp
index e055dae..faab022 100755
--- a/json_test/json_spirit_value_test.cpp
+++ b/json_test/json_spirit_value_test.cpp
@@ -381,9 +381,15 @@ namespace
Container_constructor_runner()
{
vector< double > vd = list_of( 1.2 )( 1.3 ); test_container_constructor( vd );
+ #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
+ vector< int > vi = { 1 }; test_container_constructor( vi );
+ vi = { 1, 2 }; test_container_constructor( vi );
+ vi = { 1, 2, 3 }; test_container_constructor( vi );
+ #else
vector< int > vi = list_of( 1 ); test_container_constructor( vi );
vi = list_of( 1 )( 2 ); test_container_constructor( vi );
vi = list_of( 1 )( 2 )( 3 ); test_container_constructor( vi );
+ #endif
list< double > ld = list_of( 1.2 )( 1.3 ); test_container_constructor( ld );
list< int > li = list_of( 1 ); test_container_constructor( li );
li = list_of( 1 )( 2 ); test_container_constructor( li );
@@ -447,9 +453,15 @@ namespace
}
vector< double > vd = list_of( 1.2 )( 1.3 ); test_variant_array_constructor< double > ( vd );
+ #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
+ vector< int > vi = { 1 }; test_variant_array_constructor< int >( vi );
+ vi = { 1, 2 }; test_variant_array_constructor< int >( vi );
+ vi = { 1, 2, 3 }; test_variant_array_constructor< int >( vi );
+ #else
vector< int > vi = list_of( 1 ); test_variant_array_constructor< int >( vi );
vi = list_of( 1 )( 2 ); test_variant_array_constructor< int >( vi );
vi = list_of( 1 )( 2 )( 3 ); test_variant_array_constructor< int >( vi );
+ #endif
list< double > ld = list_of( 1.2 )( 1.3 ); test_variant_array_constructor< double >( ld );
list< int > li = list_of( 1 ); test_variant_array_constructor< int >( li );
li = list_of( 1 )( 2 ); test_variant_array_constructor< int >( li );
|