Skip to content

Commit 1729e9c

Browse files
committed
Fix some compilation errors
- add missing include for std::unique_ptr - fix global operator<< template to be specific to Json::Value - add missing include guards to header implementation files - include the template implementations in tests
1 parent fc8897a commit 1729e9c

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

include/json/reader.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// recognized in your jurisdiction.
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

6+
#ifndef CPPTL_JSON_READER_INL_INCLUDED
7+
#define CPPTL_JSON_READER_INL_INCLUDED
8+
69
#if !defined(JSON_IS_AMALGAMATION)
710
#include "assertions.h"
811
#include "reader.h"
@@ -2100,3 +2103,5 @@ std::istream& operator>>(std::istream& sin, _Value& root) {
21002103

21012104
} // namespace detail
21022105
} // namespace Json
2106+
2107+
#endif // CPPTL_JSON_READER_INL_INCLUDED

include/json/value.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#if !defined(JSON_IS_AMALGAMATION)
1010
#include "forwards.h"
1111
#endif // if !defined(JSON_IS_AMALGAMATION)
12+
#include <memory>
1213
#include <string>
1314
#include <vector>
1415
#include <exception>
@@ -887,8 +888,7 @@ typedef detail::ValueIteratorBase<detail::Value<>> ValueIteratorBase; // class
887888

888889
namespace std {
889890
/// Specialize std::swap() for Json::Value.
890-
template<class _Alloc = std::allocator<char>,
891-
class _String = std::basic_string<char, std::char_traits<char>, std::allocator<char>>>
891+
template<class _Alloc, class _String>
892892
inline void swap(Json::detail::Value<_Alloc, _String>& a, Json::detail::Value<_Alloc, _String>& b) { a.swap(b); }
893893
}
894894

include/json/value.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// recognized in your jurisdiction.
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

6+
#ifndef CPPTL_JSON_VALUE_INL_INCLUDED
7+
#define CPPTL_JSON_VALUE_INL_INCLUDED
8+
69
#if !defined(JSON_IS_AMALGAMATION)
710
#include "assertions.h"
811
#include "value.h"
@@ -1730,3 +1733,5 @@ _Value& Path<_Value>::make(_Value& root) const {
17301733

17311734
} // namespace detail
17321735
} // namespace Json
1736+
1737+
#endif // CPPTL_JSON_VALUE_INL_INCLUDED

include/json/writer.inl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// recognized in your jurisdiction.
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

6+
#ifndef JSON_WRITER_INL_INCLUDED
7+
#define JSON_WRITER_INL_INCLUDED
8+
69
#if !defined(JSON_IS_AMALGAMATION)
710
#include <json/writer.h>
811
#include "tool.h"
@@ -1249,19 +1252,21 @@ typedef std::auto_ptr<StreamWriter<_Value>> StreamWriterPtr;
12491252

12501253
/// \brief Output using the StyledStreamWriter.
12511254
/// \see Json::operator>>()
1252-
template<class _Value>
1253-
std::ostream& operator<<(std::ostream& sout, _Value const& root) {
1255+
template<class _Alloc, class _String>
1256+
std::ostream& operator<<(std::ostream& sout, Value<_Alloc, _String> const& root) {
12541257
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
1255-
typedef std::unique_ptr<StreamWriter<_Value>> StreamWriterPtr;
1258+
typedef std::unique_ptr<StreamWriter<Value<_Alloc, _String>>> StreamWriterPtr;
12561259
#else
1257-
typedef std::auto_ptr<StreamWriter<_Value>> StreamWriterPtr;
1260+
typedef std::auto_ptr<StreamWriter<Value<_Alloc, _String>>> StreamWriterPtr;
12581261
#endif
12591262

1260-
StreamWriterBuilder<_Value> builder;
1263+
StreamWriterBuilder<Value<_Alloc, _String>> builder;
12611264
StreamWriterPtr const writer(builder.newStreamWriter());
12621265
writer->write(root, &sout);
12631266
return sout;
12641267
}
12651268

12661269
} // namespace detail
12671270
} // namespace Json
1271+
1272+
#endif // JSON_WRITER_INL_INCLUDED

src/test_lib_json/jsontest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#define JSONTEST_H_INCLUDED
88

99
#include <json/config.h>
10-
#include <json/value.h>
11-
#include <json/writer.h>
10+
#include <json/value.inl>
11+
#include <json/writer.inl>
1212
#include <stdio.h>
1313
#include <deque>
1414
#include <sstream>

0 commit comments

Comments
 (0)