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