Skip to content

Commit

Permalink
Merge pull request Tencent#193 from pah/feature/custom-namespace
Browse files Browse the repository at this point in the history
Allow customization of RapidJSON namespace
  • Loading branch information
miloyip committed Nov 7, 2014
2 parents 8307f0f + a0f9de6 commit 8d4405c
Show file tree
Hide file tree
Showing 25 changed files with 188 additions and 60 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ before_script:
script:
- make -C build/gmake -f test.make config=${CONF}${BITS}
- make -C build/gmake -f example.make config=${CONF}${BITS}
- if [ "$CONF" = "debug" ] && ( objdump -t -C intermediate/${CONF}/gmake/unittest/x${BITS}/namespacetest.o | grep rapidjson ) ; then echo "Symbol check failed!" ; false; fi
- pushd bin
- ./unittest_${CONF}_x${BITS}_gmake
- valgrind --leak-check=full --error-exitcode=1 ./unittest_${CONF}_x${BITS}_gmake
Expand Down
2 changes: 2 additions & 0 deletions build/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,8 @@ INCLUDE_FILE_PATTERNS =

PREDEFINED = \
RAPIDJSON_DOXYGEN_RUNNING \
RAPIDJSON_NAMESPACE_BEGIN="namespace rapidjson {" \
RAPIDJSON_NAMESPACE_END="}" \
RAPIDJSON_REMOVEFPTR_(x)=x \
RAPIDJSON_ENABLEIF_RETURN(cond,returntype)="RAPIDJSON_REMOVEFPTR_ returntype" \
RAPIDJSON_DISABLEIF_RETURN(cond,returntype)="RAPIDJSON_REMOVEFPTR_ returntype"
Expand Down
4 changes: 2 additions & 2 deletions include/rapidjson/allocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "rapidjson.h"

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

///////////////////////////////////////////////////////////////////////////////
// Allocator
Expand Down Expand Up @@ -240,6 +240,6 @@ class MemoryPoolAllocator {
BaseAllocator* ownBaseAllocator_; //!< base allocator created by this object.
};

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_ENCODINGS_H_
4 changes: 2 additions & 2 deletions include/rapidjson/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ RAPIDJSON_DIAG_OFF(effc++)
#include <utility> // std::move
#endif

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

// Forward declaration.
template <typename Encoding, typename Allocator>
Expand Down Expand Up @@ -1899,7 +1899,7 @@ GenericValue<Encoding,Allocator>::GenericValue(const GenericValue<Encoding,Sourc
RawAssign(*d.stack_.template Pop<GenericValue>(1));
}

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#if defined(_MSC_VER) || defined(__GNUC__)
RAPIDJSON_DIAG_POP
Expand Down
4 changes: 2 additions & 2 deletions include/rapidjson/encodedstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++)
#endif

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

//! Input byte stream wrapper with a statically bound encoding.
/*!
Expand Down Expand Up @@ -281,7 +281,7 @@ class AutoUTFOutputStream {

#undef RAPIDJSON_ENCODINGS_FUNC

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#ifdef __GNUC__
RAPIDJSON_DIAG_POP
Expand Down
4 changes: 2 additions & 2 deletions include/rapidjson/encodings.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++)
#endif

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

///////////////////////////////////////////////////////////////////////////////
// Encoding
Expand Down Expand Up @@ -621,7 +621,7 @@ struct Transcoder<Encoding, Encoding> {
}
};

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#if defined(__GNUC__) || defined(_MSV_VER)
RAPIDJSON_DIAG_POP
Expand Down
4 changes: 2 additions & 2 deletions include/rapidjson/error/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "error.h"

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

//! Maps error code of parsing into error message.
/*!
Expand Down Expand Up @@ -66,6 +66,6 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErro
}
}

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_ERROR_EN_H__
4 changes: 2 additions & 2 deletions include/rapidjson/error/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define RAPIDJSON_ERROR_STRING(x) x
#endif

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

///////////////////////////////////////////////////////////////////////////////
// ParseErrorCode
Expand Down Expand Up @@ -145,6 +145,6 @@ struct ParseResult {
*/
typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetParseErrorFunc)(ParseErrorCode);

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_ERROR_ERROR_H__
4 changes: 2 additions & 2 deletions include/rapidjson/filereadstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "rapidjson.h"
#include <cstdio>

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

//! File byte stream for input using fread().
/*!
Expand Down Expand Up @@ -89,6 +89,6 @@ class FileReadStream {
bool eof_;
};

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_FILESTREAM_H_
4 changes: 2 additions & 2 deletions include/rapidjson/filestream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "rapidjson.h"
#include <cstdio>

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

//! (Deprecated) Wrapper of C file stream for input or output.
/*!
Expand Down Expand Up @@ -68,6 +68,6 @@ class FileStream {
size_t count_;
};

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_FILESTREAM_H_
4 changes: 2 additions & 2 deletions include/rapidjson/filewritestream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "rapidjson.h"
#include <cstdio>

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

//! Wrapper of C file stream for input using fread().
/*!
Expand Down Expand Up @@ -92,6 +92,6 @@ inline void PutN(FileWriteStream& stream, char c, size_t n) {
stream.PutN(c, n);
}

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_FILESTREAM_H_
4 changes: 2 additions & 2 deletions include/rapidjson/internal/dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include "itoa.h" // GetDigitsLut()

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN
namespace internal {

#ifdef __GNUC__
Expand Down Expand Up @@ -413,6 +413,6 @@ RAPIDJSON_DIAG_POP
#endif

} // namespace internal
} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_DTOA_
4 changes: 2 additions & 2 deletions include/rapidjson/internal/itoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef RAPIDJSON_ITOA_
#define RAPIDJSON_ITOA_

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN
namespace internal {

inline const char* GetDigitsLut() {
Expand Down Expand Up @@ -301,6 +301,6 @@ inline char* i64toa(int64_t value, char* buffer) {
}

} // namespace internal
} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_ITOA_
16 changes: 8 additions & 8 deletions include/rapidjson/internal/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RAPIDJSON_DIAG_OFF(6334)
#endif

//@cond RAPIDJSON_INTERNAL
namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN
namespace internal {

// Helper to wrap/convert arbitrary types to void, useful for arbitrary type matching
Expand Down Expand Up @@ -157,29 +157,29 @@ template <typename T> struct RemoveSfinaeTag;
template <typename T> struct RemoveSfinaeTag<SfinaeTag&(*)(T)> { typedef T Type; };

#define RAPIDJSON_REMOVEFPTR_(type) \
typename ::rapidjson::internal::RemoveSfinaeTag \
< ::rapidjson::internal::SfinaeTag&(*) type>::Type
typename ::RAPIDJSON_NAMESPACE::internal::RemoveSfinaeTag \
< ::RAPIDJSON_NAMESPACE::internal::SfinaeTag&(*) type>::Type

#define RAPIDJSON_ENABLEIF(cond) \
typename ::rapidjson::internal::EnableIf \
typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \
<RAPIDJSON_REMOVEFPTR_(cond)>::Type * = NULL

#define RAPIDJSON_DISABLEIF(cond) \
typename ::rapidjson::internal::DisableIf \
typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \
<RAPIDJSON_REMOVEFPTR_(cond)>::Type * = NULL

#define RAPIDJSON_ENABLEIF_RETURN(cond,returntype) \
typename ::rapidjson::internal::EnableIf \
typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \
<RAPIDJSON_REMOVEFPTR_(cond), \
RAPIDJSON_REMOVEFPTR_(returntype)>::Type

#define RAPIDJSON_DISABLEIF_RETURN(cond,returntype) \
typename ::rapidjson::internal::DisableIf \
typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \
<RAPIDJSON_REMOVEFPTR_(cond), \
RAPIDJSON_REMOVEFPTR_(returntype)>::Type

} // namespace internal
} // namespace rapidjson
RAPIDJSON_NAMESPACE_END
//@endcond

#if defined(__GNUC__) || defined(_MSC_VER)
Expand Down
4 changes: 2 additions & 2 deletions include/rapidjson/internal/pow10.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef RAPIDJSON_POW10_
#define RAPIDJSON_POW10_

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN
namespace internal {

//! Computes integer powers of 10 in double (10.0^n).
Expand Down Expand Up @@ -54,6 +54,6 @@ inline double Pow10(int n) {
}

} // namespace internal
} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_POW10_
4 changes: 2 additions & 2 deletions include/rapidjson/internal/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef RAPIDJSON_INTERNAL_STACK_H_
#define RAPIDJSON_INTERNAL_STACK_H_

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN
namespace internal {

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -178,6 +178,6 @@ class Stack {
};

} // namespace internal
} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_STACK_H_
4 changes: 2 additions & 2 deletions include/rapidjson/internal/strfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef RAPIDJSON_INTERNAL_STRFUNC_H_
#define RAPIDJSON_INTERNAL_STRFUNC_H_

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN
namespace internal {

//! Custom strlen() which works on different character types.
Expand All @@ -38,6 +38,6 @@ inline SizeType StrLen(const Ch* s) {
}

} // namespace internal
} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_INTERNAL_STRFUNC_H_
4 changes: 2 additions & 2 deletions include/rapidjson/memorybuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "rapidjson.h"
#include "internal/stack.h"

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

//! Represents an in-memory output byte stream.
/*!
Expand Down Expand Up @@ -71,6 +71,6 @@ inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) {
std::memset(memoryBuffer.stack_.Push<char>(n), c, n * sizeof(c));
}

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_MEMORYBUFFER_H_
4 changes: 2 additions & 2 deletions include/rapidjson/memorystream.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "rapidjson.h"

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

//! Represents an in-memory input byte stream.
/*!
Expand Down Expand Up @@ -62,6 +62,6 @@ struct MemoryStream {
size_t size_; //!< Size of the stream.
};

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#endif // RAPIDJSON_MEMORYBUFFER_H_
4 changes: 2 additions & 2 deletions include/rapidjson/prettywriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++)
#endif

namespace rapidjson {
RAPIDJSON_NAMESPACE_BEGIN

//! Writer with indentation and spacing.
/*!
Expand Down Expand Up @@ -196,7 +196,7 @@ class PrettyWriter : public Writer<OutputStream, SourceEncoding, TargetEncoding,
PrettyWriter& operator=(const PrettyWriter&);
};

} // namespace rapidjson
RAPIDJSON_NAMESPACE_END

#ifdef __GNUC__
RAPIDJSON_DIAG_POP
Expand Down
Loading

0 comments on commit 8d4405c

Please sign in to comment.