Unverified Commit 88481be8 authored by Ge Jun's avatar Ge Jun Committed by GitHub

Merge pull request #291 from peiyuanzheng/rapidjson_namespace

change butil/third_party/rapidjson namespace to make it ABI-compatible with other versions of rapidjson used in the same project.
parents 322b87d9 cc94704b
......@@ -53,9 +53,9 @@ DEFINE_int32(consul_retry_interval_ms, 500,
constexpr char kConsulIndex[] = "X-Consul-Index";
std::string RapidjsonValueToString(const rapidjson::Value& value) {
rapidjson::StringBuffer buffer;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
std::string RapidjsonValueToString(const BUTIL_RAPIDJSON_NAMESPACE::Value& value) {
BUTIL_RAPIDJSON_NAMESPACE::StringBuffer buffer;
BUTIL_RAPIDJSON_NAMESPACE::PrettyWriter<BUTIL_RAPIDJSON_NAMESPACE::StringBuffer> writer(buffer);
value.Accept(writer);
return buffer.GetString();
}
......@@ -126,7 +126,7 @@ int ConsulNamingService::GetServers(const char* service_name,
// set to de-duplicate and keep the order.
std::set<ServerNode> presence;
rapidjson::Document services;
BUTIL_RAPIDJSON_NAMESPACE::Document services;
services.Parse(cntl.response_attachment().to_string().c_str());
if (!services.IsArray()) {
LOG(ERROR) << "The consul's response for "
......@@ -134,14 +134,14 @@ int ConsulNamingService::GetServers(const char* service_name,
return -1;
}
for (rapidjson::SizeType i = 0; i < services.Size(); ++i) {
for (BUTIL_RAPIDJSON_NAMESPACE::SizeType i = 0; i < services.Size(); ++i) {
if (!services[i].HasMember("Service")) {
LOG(ERROR) << "No service info in node: "
<< RapidjsonValueToString(services[i]);
continue;
}
const rapidjson::Value& service = services[i]["Service"];
const BUTIL_RAPIDJSON_NAMESPACE::Value& service = services[i]["Service"];
if (!service.HasMember("Address") ||
!service["Address"].IsString() ||
!service.HasMember("Port") ||
......
......@@ -17,7 +17,7 @@
#include "rapidjson.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// Allocator
......@@ -260,6 +260,6 @@ private:
template <typename BaseAllocator>
const bool MemoryPoolAllocator<BaseAllocator>::kNeedFree;
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_ENCODINGS_H_
......@@ -63,7 +63,7 @@ RAPIDJSON_DIAG_OFF(effc++)
#include <utility> // std::move
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
// Forward declaration.
template <typename Encoding, typename Allocator>
......@@ -2030,7 +2030,7 @@ GenericValue<Encoding,Allocator>::GenericValue(const GenericValue<Encoding,Sourc
}
}
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#if defined(_MSC_VER) || defined(__GNUC__)
RAPIDJSON_DIAG_POP
......
......@@ -22,7 +22,7 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++)
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Input byte stream wrapper with a statically bound encoding.
/*!
......@@ -252,7 +252,7 @@ private:
#undef RAPIDJSON_ENCODINGS_FUNC
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#ifdef __GNUC__
RAPIDJSON_DIAG_POP
......
......@@ -27,7 +27,7 @@ RAPIDJSON_DIAG_OFF(effc++)
RAPIDJSON_DIAG_OFF(overflow)
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// Encoding
......@@ -616,7 +616,7 @@ struct Transcoder<Encoding, Encoding> {
}
};
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#if defined(__GNUC__) || defined(_MSV_VER)
RAPIDJSON_DIAG_POP
......
......@@ -17,7 +17,7 @@
#include "error.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Maps error code of parsing into error message.
/*!
......@@ -60,6 +60,6 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErro
}
}
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_ERROR_EN_H__
......@@ -47,7 +47,7 @@
#define RAPIDJSON_ERROR_STRING(x) x
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// ParseErrorCode
......@@ -142,6 +142,6 @@ private:
*/
typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetParseErrorFunc)(ParseErrorCode);
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_ERROR_ERROR_H__
......@@ -18,7 +18,7 @@
#include "rapidjson.h"
#include <cstdio>
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! File byte stream for input using fread().
/*!
......@@ -83,6 +83,6 @@ private:
bool eof_;
};
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_FILESTREAM_H_
......@@ -18,7 +18,7 @@
#include "rapidjson.h"
#include <cstdio>
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Wrapper of C file stream for input using fread().
/*!
......@@ -86,6 +86,6 @@ inline void PutN(FileWriteStream& stream, char c, size_t n) {
stream.PutN(c, n);
}
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_FILESTREAM_H_
......@@ -21,7 +21,7 @@
#include <intrin.h> // for _umul128
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
class BigInteger {
......@@ -275,6 +275,6 @@ private:
};
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_BIGINTEGER_H_
......@@ -26,7 +26,7 @@
#pragma intrinsic(_BitScanReverse64)
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
#ifdef __GNUC__
......@@ -242,6 +242,6 @@ RAPIDJSON_DIAG_POP
#endif
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_DIYFP_H_
......@@ -23,7 +23,7 @@
#include "diyfp.h"
#include "ieee754.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
#ifdef __GNUC__
......@@ -212,6 +212,6 @@ RAPIDJSON_DIAG_POP
#endif
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_DTOA_
......@@ -17,7 +17,7 @@
#include "../rapidjson.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
class Double {
......@@ -72,6 +72,6 @@ private:
};
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_IEEE754_
......@@ -17,7 +17,7 @@
#include "../rapidjson.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
inline const char* GetDigitsLut() {
......@@ -299,6 +299,6 @@ inline char* i64toa(int64_t value, char* buffer) {
}
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_ITOA_
......@@ -31,7 +31,7 @@ RAPIDJSON_DIAG_OFF(6334)
#endif
//@cond RAPIDJSON_INTERNAL
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
// Helper to wrap/convert arbitrary types to void, useful for arbitrary type matching
......@@ -149,29 +149,29 @@ template <typename T> struct RemoveSfinaeTag;
template <typename T> struct RemoveSfinaeTag<SfinaeTag&(*)(T)> { typedef T Type; };
#define RAPIDJSON_REMOVEFPTR_(type) \
typename ::RAPIDJSON_NAMESPACE::internal::RemoveSfinaeTag \
< ::RAPIDJSON_NAMESPACE::internal::SfinaeTag&(*) type>::Type
typename ::BUTIL_RAPIDJSON_NAMESPACE::internal::RemoveSfinaeTag \
< ::BUTIL_RAPIDJSON_NAMESPACE::internal::SfinaeTag&(*) type>::Type
#define RAPIDJSON_ENABLEIF(cond) \
typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \
typename ::BUTIL_RAPIDJSON_NAMESPACE::internal::EnableIf \
<RAPIDJSON_REMOVEFPTR_(cond)>::Type * = NULL
#define RAPIDJSON_DISABLEIF(cond) \
typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \
typename ::BUTIL_RAPIDJSON_NAMESPACE::internal::DisableIf \
<RAPIDJSON_REMOVEFPTR_(cond)>::Type * = NULL
#define RAPIDJSON_ENABLEIF_RETURN(cond,returntype) \
typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \
typename ::BUTIL_RAPIDJSON_NAMESPACE::internal::EnableIf \
<RAPIDJSON_REMOVEFPTR_(cond), \
RAPIDJSON_REMOVEFPTR_(returntype)>::Type
#define RAPIDJSON_DISABLEIF_RETURN(cond,returntype) \
typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \
typename ::BUTIL_RAPIDJSON_NAMESPACE::internal::DisableIf \
<RAPIDJSON_REMOVEFPTR_(cond), \
RAPIDJSON_REMOVEFPTR_(returntype)>::Type
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
//@endcond
#if defined(__GNUC__) || defined(_MSC_VER)
......
......@@ -17,7 +17,7 @@
#include "../rapidjson.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
//! Computes integer powers of 10 in double (10.0^n).
......@@ -50,6 +50,6 @@ inline double Pow10(int n) {
}
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_POW10_
......@@ -17,7 +17,7 @@
#include "../rapidjson.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
///////////////////////////////////////////////////////////////////////////////
......@@ -174,6 +174,6 @@ private:
};
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_STACK_H_
......@@ -17,7 +17,7 @@
#include "../rapidjson.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
//! Custom strlen() which works on different character types.
......@@ -34,6 +34,6 @@ inline SizeType StrLen(const Ch* s) {
}
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_INTERNAL_STRFUNC_H_
......@@ -21,7 +21,7 @@
#include "diyfp.h"
#include "pow10.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
inline double FastPath(double significand, int exp) {
......@@ -265,6 +265,6 @@ inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t
}
} // namespace internal
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_STRTOD_
......@@ -18,7 +18,7 @@
#include "rapidjson.h"
#include "internal/stack.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Represents an in-memory output byte stream.
/*!
......@@ -65,6 +65,6 @@ inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) {
std::memset(memoryBuffer.stack_.Push<char>(n), c, n * sizeof(c));
}
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_MEMORYBUFFER_H_
......@@ -17,7 +17,7 @@
#include "rapidjson.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Represents an in-memory input byte stream.
/*!
......@@ -56,6 +56,6 @@ struct MemoryStream {
size_t size_; //!< Size of the stream.
};
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_MEMORYBUFFER_H_
......@@ -7,7 +7,7 @@
#include "writer.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Optimized writer
/*! This class mainly inherit writer class in rapidjson
......@@ -96,6 +96,6 @@ private:
OptimizedWriter(const OptimizedWriter&);
OptimizedWriter& operator=(const OptimizedWriter&);
};
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_OPTIMIZED_WRITER_H
......@@ -18,7 +18,7 @@
#include "document.h"
#include "internal/itoa.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
static const SizeType kPointerInvalidIndex = ~SizeType(0); //!< Represents an invalid index in GenericPointer::Token
......@@ -1308,6 +1308,6 @@ bool EraseValueByPointer(T& root, const CharType(&source)[N]) {
//@}
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_POINTER_H_
......@@ -22,7 +22,7 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++)
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Writer with indentation and spacing.
/*!
......@@ -198,7 +198,7 @@ private:
PrettyWriter& operator=(const PrettyWriter&);
};
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#ifdef __GNUC__
RAPIDJSON_DIAG_POP
......
......@@ -109,14 +109,21 @@
\brief provide custom rapidjson namespace (closing expression)
\see RAPIDJSON_NAMESPACE
*/
#ifndef RAPIDJSON_NAMESPACE
#define RAPIDJSON_NAMESPACE rapidjson
// NOTE:
// Add prefix 'BUTIL_' to original 'RAPIDJSON_NAMESPACE', 'RAPIDJSON_NAMESPACE_BEGIN'
// and 'RAPIDJSON_NAMESPACE_END', and set BUTIL_RAPIDJSON_NAMESPACE to butil::rapidjson,
// in order to distinguish with other version RapidJSON in a single binary. (Please refer
// to the reason mentioned in the comments above)
// When using RapidJSON API inside brpc, please use 'BUTIL_RAPIDJSON_NAMESPACE::' instead of
// 'rapidjson::'.
#ifndef BUTIL_RAPIDJSON_NAMESPACE
#define BUTIL_RAPIDJSON_NAMESPACE butil::rapidjson
#endif
#ifndef RAPIDJSON_NAMESPACE_BEGIN
#define RAPIDJSON_NAMESPACE_BEGIN namespace RAPIDJSON_NAMESPACE {
#ifndef BUTIL_RAPIDJSON_NAMESPACE_BEGIN
#define BUTIL_RAPIDJSON_NAMESPACE_BEGIN namespace butil { namespace rapidjson {
#endif
#ifndef RAPIDJSON_NAMESPACE_END
#define RAPIDJSON_NAMESPACE_END }
#ifndef BUTIL_RAPIDJSON_NAMESPACE_END
#define BUTIL_RAPIDJSON_NAMESPACE_END } }
#endif
///////////////////////////////////////////////////////////////////////////////
......@@ -313,20 +320,20 @@
#ifdef RAPIDJSON_DOXYGEN_RUNNING
#define RAPIDJSON_NO_SIZETYPEDEFINE
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Size type (for string lengths, array sizes, etc.)
/*! RapidJSON uses 32-bit array/string indices even on 64-bit platforms,
instead of using \c size_t. Users may override the SizeType by defining
\ref RAPIDJSON_NO_SIZETYPEDEFINE.
*/
typedef unsigned SizeType;
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif
// always import std::size_t to rapidjson namespace
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
using std::size_t;
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
///////////////////////////////////////////////////////////////////////////////
// RAPIDJSON_ASSERT
......@@ -350,11 +357,11 @@ RAPIDJSON_NAMESPACE_END
// Adopt from boost
#ifndef RAPIDJSON_STATIC_ASSERT
//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
template <bool x> struct STATIC_ASSERTION_FAILURE;
template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
template<int x> struct StaticAssertTest {};
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#define RAPIDJSON_JOIN(X, Y) RAPIDJSON_DO_JOIN(X, Y)
#define RAPIDJSON_DO_JOIN(X, Y) RAPIDJSON_DO_JOIN2(X, Y)
......@@ -373,8 +380,8 @@ RAPIDJSON_NAMESPACE_END
\hideinitializer
*/
#define RAPIDJSON_STATIC_ASSERT(x) \
typedef ::RAPIDJSON_NAMESPACE::StaticAssertTest< \
sizeof(::RAPIDJSON_NAMESPACE::STATIC_ASSERTION_FAILURE<bool(x) >)> \
typedef ::BUTIL_RAPIDJSON_NAMESPACE::StaticAssertTest< \
sizeof(::BUTIL_RAPIDJSON_NAMESPACE::STATIC_ASSERTION_FAILURE<bool(x) >)> \
RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE
#endif
......@@ -496,9 +503,9 @@ RAPIDJSON_NAMESPACE_END
/*! \namespace rapidjson
\brief main RapidJSON namespace
\see RAPIDJSON_NAMESPACE
\see BUTIL_RAPIDJSON_NAMESPACE
*/
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// Stream
......@@ -655,6 +662,6 @@ enum Type {
kNumberType = 6 //!< number
};
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_RAPIDJSON_H_
......@@ -115,7 +115,7 @@ RAPIDJSON_DIAG_OFF(effc++)
#include "error/error.h" // ParseErrorCode, ParseResult
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
template<class T, class U>
struct is_same {
......@@ -1552,7 +1552,7 @@ private:
//! Reader with UTF8 encoding and default allocator.
typedef GenericReader<UTF8<>, UTF8<> > Reader;
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#ifdef __GNUC__
RAPIDJSON_DIAG_POP
......
......@@ -23,7 +23,7 @@
#include "internal/stack.h"
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! Represents an in-memory output stream.
/*!
......@@ -92,6 +92,6 @@ inline void PutN(GenericStringBuffer<UTF8<> >& stream, char c, size_t n) {
std::memset(stream.stack_.Push<char>(n), c, n * sizeof(c));
}
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_STRINGBUFFER_H_
......@@ -32,7 +32,7 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
#endif
RAPIDJSON_NAMESPACE_BEGIN
BUTIL_RAPIDJSON_NAMESPACE_BEGIN
//! JSON writer
/*! Writer implements the concept Handler.
......@@ -386,7 +386,7 @@ inline bool Writer<StringBuffer>::WriteDouble(double d) {
return true;
}
RAPIDJSON_NAMESPACE_END
BUTIL_RAPIDJSON_NAMESPACE_END
#ifdef _MSC_VER
RAPIDJSON_DIAG_POP
......
This diff is collapsed.
......@@ -268,10 +268,10 @@ bool ProtoMessageToJsonStream(const google::protobuf::Message& message,
PbToJsonConverter converter(options);
bool succ = false;
if (options.pretty_json) {
rapidjson::PrettyWriter<OutputStream> writer(os);
BUTIL_RAPIDJSON_NAMESPACE::PrettyWriter<OutputStream> writer(os);
succ = converter.Convert(message, writer);
} else {
rapidjson::OptimizedWriter<OutputStream> writer(os);
BUTIL_RAPIDJSON_NAMESPACE::OptimizedWriter<OutputStream> writer(os);
succ = converter.Convert(message, writer);
}
if (!succ && error) {
......@@ -287,7 +287,7 @@ bool ProtoMessageToJson(const google::protobuf::Message& message,
std::string* error) {
// TODO(gejun): We could further wrap a std::string as a buffer to reduce
// a copying.
rapidjson::StringBuffer buffer;
BUTIL_RAPIDJSON_NAMESPACE::StringBuffer buffer;
if (json2pb::ProtoMessageToJsonStream(message, options, buffer, error)) {
json->append(buffer.GetString(), buffer.GetSize());
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment