mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
update the rapidjson used by discord-rpc to current master dfbe1db9da455552f7a9ad5d2aea17dd9d832ac1
This commit is contained in:
@ -21,9 +21,7 @@
|
||||
#ifdef __clang__
|
||||
RAPIDJSON_DIAG_PUSH
|
||||
RAPIDJSON_DIAG_OFF(switch-enum)
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#elif defined(_MSC_VER)
|
||||
RAPIDJSON_DIAG_PUSH
|
||||
RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
|
||||
#endif
|
||||
@ -165,7 +163,12 @@ public:
|
||||
GenericPointer(const Token* tokens, size_t tokenCount) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(const_cast<Token*>(tokens)), tokenCount_(tokenCount), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {}
|
||||
|
||||
//! Copy constructor.
|
||||
GenericPointer(const GenericPointer& rhs, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
|
||||
GenericPointer(const GenericPointer& rhs) : allocator_(rhs.allocator_), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
//! Copy constructor.
|
||||
GenericPointer(const GenericPointer& rhs, Allocator* allocator) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
@ -197,6 +200,36 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Swap the content of this pointer with an other.
|
||||
/*!
|
||||
\param other The pointer to swap with.
|
||||
\note Constant complexity.
|
||||
*/
|
||||
GenericPointer& Swap(GenericPointer& other) RAPIDJSON_NOEXCEPT {
|
||||
internal::Swap(allocator_, other.allocator_);
|
||||
internal::Swap(ownAllocator_, other.ownAllocator_);
|
||||
internal::Swap(nameBuffer_, other.nameBuffer_);
|
||||
internal::Swap(tokens_, other.tokens_);
|
||||
internal::Swap(tokenCount_, other.tokenCount_);
|
||||
internal::Swap(parseErrorOffset_, other.parseErrorOffset_);
|
||||
internal::Swap(parseErrorCode_, other.parseErrorCode_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! free-standing swap function helper
|
||||
/*!
|
||||
Helper function to enable support for common swap implementation pattern based on \c std::swap:
|
||||
\code
|
||||
void swap(MyClass& a, MyClass& b) {
|
||||
using std::swap;
|
||||
swap(a.pointer, b.pointer);
|
||||
// ...
|
||||
}
|
||||
\endcode
|
||||
\see Swap()
|
||||
*/
|
||||
friend inline void swap(GenericPointer& a, GenericPointer& b) RAPIDJSON_NOEXCEPT { a.Swap(b); }
|
||||
|
||||
//@}
|
||||
|
||||
//!@name Append token
|
||||
@ -240,7 +273,7 @@ public:
|
||||
template <typename T>
|
||||
RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >), (GenericPointer))
|
||||
Append(T* name, Allocator* allocator = 0) const {
|
||||
return Append(name, StrLen(name), allocator);
|
||||
return Append(name, internal::StrLen(name), allocator);
|
||||
}
|
||||
|
||||
#if RAPIDJSON_HAS_STDSTRING
|
||||
@ -274,7 +307,7 @@ public:
|
||||
else {
|
||||
Ch name[21];
|
||||
for (size_t i = 0; i <= length; i++)
|
||||
name[i] = buffer[i];
|
||||
name[i] = static_cast<Ch>(buffer[i]);
|
||||
Token token = { name, length, index };
|
||||
return Append(token, allocator);
|
||||
}
|
||||
@ -353,6 +386,33 @@ public:
|
||||
*/
|
||||
bool operator!=(const GenericPointer& rhs) const { return !(*this == rhs); }
|
||||
|
||||
//! Less than operator.
|
||||
/*!
|
||||
\note Invalid pointers are always greater than valid ones.
|
||||
*/
|
||||
bool operator<(const GenericPointer& rhs) const {
|
||||
if (!IsValid())
|
||||
return false;
|
||||
if (!rhs.IsValid())
|
||||
return true;
|
||||
|
||||
if (tokenCount_ != rhs.tokenCount_)
|
||||
return tokenCount_ < rhs.tokenCount_;
|
||||
|
||||
for (size_t i = 0; i < tokenCount_; i++) {
|
||||
if (tokens_[i].index != rhs.tokens_[i].index)
|
||||
return tokens_[i].index < rhs.tokens_[i].index;
|
||||
|
||||
if (tokens_[i].length != rhs.tokens_[i].length)
|
||||
return tokens_[i].length < rhs.tokens_[i].length;
|
||||
|
||||
if (int cmp = std::memcmp(tokens_[i].name, rhs.tokens_[i].name, sizeof(Ch) * tokens_[i].length))
|
||||
return cmp < 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//@}
|
||||
|
||||
//!@name Stringify
|
||||
@ -428,10 +488,11 @@ public:
|
||||
v = &((*v)[t->index]);
|
||||
}
|
||||
else {
|
||||
typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));
|
||||
typename ValueType::MemberIterator m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
|
||||
if (m == v->MemberEnd()) {
|
||||
v->AddMember(ValueType(t->name, t->length, allocator).Move(), ValueType().Move(), allocator);
|
||||
v = &(--v->MemberEnd())->value; // Assumes AddMember() appends at the end
|
||||
m = v->MemberEnd();
|
||||
v = &(--m)->value; // Assumes AddMember() appends at the end
|
||||
exist = false;
|
||||
}
|
||||
else
|
||||
@ -483,7 +544,7 @@ public:
|
||||
switch (v->GetType()) {
|
||||
case kObjectType:
|
||||
{
|
||||
typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));
|
||||
typename ValueType::MemberIterator m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
|
||||
if (m == v->MemberEnd())
|
||||
break;
|
||||
v = &m->value;
|
||||
@ -532,14 +593,14 @@ public:
|
||||
*/
|
||||
ValueType& GetWithDefault(ValueType& root, const ValueType& defaultValue, typename ValueType::AllocatorType& allocator) const {
|
||||
bool alreadyExist;
|
||||
Value& v = Create(root, allocator, &alreadyExist);
|
||||
ValueType& v = Create(root, allocator, &alreadyExist);
|
||||
return alreadyExist ? v : v.CopyFrom(defaultValue, allocator);
|
||||
}
|
||||
|
||||
//! Query a value in a subtree with default null-terminated string.
|
||||
ValueType& GetWithDefault(ValueType& root, const Ch* defaultValue, typename ValueType::AllocatorType& allocator) const {
|
||||
bool alreadyExist;
|
||||
Value& v = Create(root, allocator, &alreadyExist);
|
||||
ValueType& v = Create(root, allocator, &alreadyExist);
|
||||
return alreadyExist ? v : v.SetString(defaultValue, allocator);
|
||||
}
|
||||
|
||||
@ -547,7 +608,7 @@ public:
|
||||
//! Query a value in a subtree with default std::basic_string.
|
||||
ValueType& GetWithDefault(ValueType& root, const std::basic_string<Ch>& defaultValue, typename ValueType::AllocatorType& allocator) const {
|
||||
bool alreadyExist;
|
||||
Value& v = Create(root, allocator, &alreadyExist);
|
||||
ValueType& v = Create(root, allocator, &alreadyExist);
|
||||
return alreadyExist ? v : v.SetString(defaultValue, allocator);
|
||||
}
|
||||
#endif
|
||||
@ -719,7 +780,7 @@ public:
|
||||
switch (v->GetType()) {
|
||||
case kObjectType:
|
||||
{
|
||||
typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));
|
||||
typename ValueType::MemberIterator m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
|
||||
if (m == v->MemberEnd())
|
||||
return false;
|
||||
v = &m->value;
|
||||
@ -758,7 +819,7 @@ private:
|
||||
*/
|
||||
Ch* CopyFromRaw(const GenericPointer& rhs, size_t extraToken = 0, size_t extraNameBufferSize = 0) {
|
||||
if (!allocator_) // allocator is independently owned.
|
||||
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
|
||||
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
|
||||
|
||||
size_t nameBufferSize = rhs.tokenCount_; // null terminators for tokens
|
||||
for (Token *t = rhs.tokens_; t != rhs.tokens_ + rhs.tokenCount_; ++t)
|
||||
@ -806,7 +867,7 @@ private:
|
||||
|
||||
// Create own allocator if user did not supply.
|
||||
if (!allocator_)
|
||||
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
|
||||
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
|
||||
|
||||
// Count number of '/' as tokenCount
|
||||
tokenCount_ = 0;
|
||||
@ -1029,8 +1090,8 @@ private:
|
||||
unsigned char u = static_cast<unsigned char>(c);
|
||||
static const char hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
os_.Put('%');
|
||||
os_.Put(hexDigits[u >> 4]);
|
||||
os_.Put(hexDigits[u & 15]);
|
||||
os_.Put(static_cast<typename OutputStream::Ch>(hexDigits[u >> 4]));
|
||||
os_.Put(static_cast<typename OutputStream::Ch>(hexDigits[u & 15]));
|
||||
}
|
||||
private:
|
||||
OutputStream& os_;
|
||||
@ -1347,11 +1408,7 @@ bool EraseValueByPointer(T& root, const CharType(&source)[N]) {
|
||||
|
||||
RAPIDJSON_NAMESPACE_END
|
||||
|
||||
#ifdef __clang__
|
||||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(__clang__) || defined(_MSC_VER)
|
||||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user