Skip to content

Commit 64e40aa

Browse files
committed
Added support for amalgated source and header generation (a la sqlite). Refer to README.txt section "Generating amalgated source and header" for detail.
The amalgated sources are generated by concatenating JsonCpp source in the correct order and defining macro JSON_IS_AMALGATED to prevent inclusion of other headers. Sources and header has been modified to prevent any inclusion when this macro is defined. The script amalgate.py handle the generation.
1 parent 91923f2 commit 64e40aa

14 files changed

Lines changed: 82 additions & 18 deletions

NEWS.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
Notes: you need to setup the environment by running vcvars32.bat
1414
(e.g. MSVC 2008 command prompt in start menu) before running scons.
1515

16+
- Added support for amalgated source and header generation (a la sqlite).
17+
Refer to README.txt section "Generating amalgated source and header"
18+
for detail.
19+
1620
* Value
1721

1822
- Removed experimental ValueAllocator, it caused static

README.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,37 @@ Notes that the documentation is also available for download as a tarball.
9090
The documentation of the latest release is available online at:
9191
http://jsoncpp.sourceforge.net/
9292

93+
* Generating amalgated source and header
94+
======================================
95+
96+
JsonCpp is provided with a script to generate a single header and a single
97+
source file to ease inclusion in an existing project.
98+
99+
The amalgated source can be generated at any time by running the following
100+
command from the top-directory (requires python 2.6):
101+
102+
python amalgate.py
103+
104+
It is possible to specify header name. See -h options for detail. By default,
105+
the following files are generated:
106+
- dist/jsoncpp.cpp: source file that need to be added to your project
107+
- dist/json/json.h: header file corresponding to use in your project. It is
108+
equivalent to including json/json.h in non-amalgated source. This header
109+
only depends on standard headers.
110+
- dist/json/json-forwards.h: header the provides forward declaration
111+
of all JsonCpp types. This typically what should be included in headers to
112+
speed-up compilation.
113+
114+
The amalgated sources are generated by concatenating JsonCpp source in the
115+
correct order and defining macro JSON_IS_AMALGATED to prevent inclusion of
116+
other headers.
93117

94118
* Using json-cpp in your project:
95119
===============================
96120

97-
include/ should be added to your compiler include path. jsoncpp headers should be included as follow:
121+
include/ should be added to your compiler include path. jsoncpp headers
122+
should be included as follow:
123+
98124
#include <json/json.h>
99125

100126

include/json/config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
/// instead of C assert macro.
2929
# define JSON_USE_EXCEPTION 1
3030

31+
/// If defined, indicates that the source file is amalgated
32+
/// to prevent private header inclusion.
33+
/// Remarks: it is automatically defined in the generated amalgated header.
34+
// #define JSON_IS_AMALGATED
35+
36+
3137
# ifdef JSON_IN_CPPTL
3238
# include <cpptl/config.h>
3339
# ifndef JSON_USE_CPPTL

include/json/features.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
77
# define CPPTL_JSON_FEATURES_H_INCLUDED
88

9+
#if !defined(JSON_IS_AMALGATED)
910
# include "forwards.h"
11+
#endif // if !defined(JSON_IS_AMALGATED)
1012

1113
namespace Json {
1214

include/json/forwards.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#ifndef JSON_FORWARDS_H_INCLUDED
77
# define JSON_FORWARDS_H_INCLUDED
88

9+
#if !defined(JSON_IS_AMALGATED)
910
# include "config.h"
11+
#endif // if !defined(JSON_IS_AMALGATED)
1012

1113
namespace Json {
1214

include/json/reader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#ifndef CPPTL_JSON_READER_H_INCLUDED
77
# define CPPTL_JSON_READER_H_INCLUDED
88

9+
#if !defined(JSON_IS_AMALGATED)
910
# include "features.h"
1011
# include "value.h"
12+
#endif // if !defined(JSON_IS_AMALGATED)
1113
# include <deque>
1214
# include <stack>
1315
# include <string>

include/json/value.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#ifndef CPPTL_JSON_H_INCLUDED
77
# define CPPTL_JSON_H_INCLUDED
88

9+
#if !defined(JSON_IS_AMALGATED)
910
# include "forwards.h"
11+
#endif // if !defined(JSON_IS_AMALGATED)
1012
# include <string>
1113
# include <vector>
1214

include/json/writer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#ifndef JSON_WRITER_H_INCLUDED
77
# define JSON_WRITER_H_INCLUDED
88

9+
#if !defined(JSON_IS_AMALGATED)
910
# include "value.h"
11+
#endif // if !defined(JSON_IS_AMALGATED)
1012
# include <vector>
1113
# include <string>
1214
# include <iostream>

src/lib_json/json_internalarray.inl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

66
// included by json_value.cpp
7-
// everything is within Json namespace
7+
8+
namespace Json {
89

910
// //////////////////////////////////////////////////////////////////
1011
// //////////////////////////////////////////////////////////////////
@@ -451,3 +452,5 @@ ValueInternalArray::compare( const ValueInternalArray &other ) const
451452
}
452453
return 0;
453454
}
455+
456+
} // namespace Json

src/lib_json/json_internalmap.inl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

66
// included by json_value.cpp
7-
// everything is within Json namespace
7+
8+
namespace Json {
89

910
// //////////////////////////////////////////////////////////////////
1011
// //////////////////////////////////////////////////////////////////
@@ -610,3 +611,5 @@ ValueInternalMap::distance( const IteratorState &x, const IteratorState &y )
610611
increment( it );
611612
return offset;
612613
}
614+
615+
} // namespace Json

0 commit comments

Comments
 (0)