16#ifndef RAPIDJSON_POINTER_H_
17#define RAPIDJSON_POINTER_H_
21#include "internal/itoa.h"
26RAPIDJSON_DIAG_OFF(
switch-
enum)
27#elif defined(_MSC_VER)
29RAPIDJSON_DIAG_OFF(4512)
32#if defined(RAPIDJSON_CPLUSPLUS) && RAPIDJSON_CPLUSPLUS >= 201703L
33#define RAPIDJSON_IF_CONSTEXPR if constexpr
35#define RAPIDJSON_IF_CONSTEXPR if
74template <
typename ValueType,
typename Allocator = CrtAllocator>
78 typedef typename ValueType::Ch
Ch;
113 Parse(source, internal::StrLen(source));
116#if RAPIDJSON_HAS_STDSTRING
124 Parse(source.c_str(), source.size());
136 Parse(source, length);
210 internal::Swap(
tokens_, other.tokens_);
245 Ch *p = r.CopyFromRaw(*
this, 1, token.length + 1);
246 std::memcpy(p, token.name, (token.length + 1) *
sizeof(
Ch));
261 Token token = { name, length, kPointerInvalidIndex };
262 return Append(token, allocator);
271 template <
typename T>
274 return Append(name, internal::StrLen(name), allocator);
277#if RAPIDJSON_HAS_STDSTRING
285 return Append(name.c_str(),
static_cast<SizeType>(name.size()), allocator);
297 char* end =
sizeof(
SizeType) == 4 ? internal::u32toa(index, buffer) : internal::u64toa(index, buffer);
299 buffer[length] =
'\0';
301 RAPIDJSON_IF_CONSTEXPR (
sizeof(
Ch) == 1) {
302 Token token = {
reinterpret_cast<Ch*
>(buffer), length, index };
303 return Append(token, allocator);
307 for (
size_t i = 0; i <= length; i++)
308 name[i] =
static_cast<Ch>(buffer[i]);
309 Token token = { name, length, index };
310 return Append(token, allocator);
321 if (token.IsString())
322 return Append(token.GetString(), token.GetStringLength(), allocator);
326 return Append(
static_cast<SizeType>(token.GetUint64()), allocator);
345 Allocator& GetAllocator() {
return *
allocator_; }
354 size_t GetTokenCount()
const {
return tokenCount_; }
385 bool operator!=(
const GenericPointer& rhs)
const {
return !(*
this == rhs); }
424 template<
typename OutputStream>
425 bool Stringify(OutputStream& os)
const {
426 return Stringify<false, OutputStream>(os);
434 template<
typename OutputStream>
435 bool StringifyUriFragment(OutputStream& os)
const {
436 return Stringify<true, OutputStream>(os);
459 ValueType& Create(ValueType& root,
typename ValueType::AllocatorType& allocator,
bool* alreadyExist = 0)
const {
461 ValueType* v = &root;
464 if (v->IsArray() && t->name[0] ==
'-' && t->length == 1) {
465 v->PushBack(ValueType().Move(), allocator);
466 v = &((*v)[v->Size() - 1]);
470 if (t->index == kPointerInvalidIndex) {
475 if (!v->IsArray() && !v->IsObject())
480 if (t->index >= v->Size()) {
481 v->Reserve(t->index + 1, allocator);
482 while (t->index >= v->Size())
483 v->PushBack(ValueType().Move(), allocator);
486 v = &((*v)[t->index]);
489 typename ValueType::MemberIterator m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
490 if (m == v->MemberEnd()) {
491 v->AddMember(ValueType(t->name, t->length, allocator).Move(), ValueType().Move(), allocator);
503 *alreadyExist = exist;
514 template <
typename stackAllocator>
515 ValueType& Create(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document,
bool* alreadyExist = 0)
const {
516 return Create(document, document.
GetAllocator(), alreadyExist);
541 UriType GetUri(ValueType& root,
const UriType& rootUri,
size_t* unresolvedTokenIndex = 0, Allocator* allocator = 0)
const {
542 static const Ch kIdString[] = {
'i',
'd',
'\0' };
543 static const ValueType kIdValue(kIdString, 2);
544 UriType base = UriType(rootUri, allocator);
546 ValueType* v = &root;
548 switch (v->GetType()) {
552 typename ValueType::MemberIterator m = v->FindMember(kIdValue);
553 if (m != v->MemberEnd() && (m->value).IsString()) {
554 UriType here = UriType(m->value, allocator).Resolve(base, allocator);
557 m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
558 if (m == v->MemberEnd())
564 if (t->index == kPointerInvalidIndex || t->index >= v->Size())
566 v = &((*v)[t->index]);
573 if (unresolvedTokenIndex)
574 *unresolvedTokenIndex =
static_cast<size_t>(t -
tokens_);
575 return UriType(allocator);
580 UriType GetUri(
const ValueType& root,
const UriType& rootUri,
size_t* unresolvedTokenIndex = 0, Allocator* allocator = 0)
const {
581 return GetUri(
const_cast<ValueType&
>(root), rootUri, unresolvedTokenIndex, allocator);
602 ValueType* Get(ValueType& root,
size_t* unresolvedTokenIndex = 0)
const {
604 ValueType* v = &root;
606 switch (v->GetType()) {
609 typename ValueType::MemberIterator m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
610 if (m == v->MemberEnd())
616 if (t->index == kPointerInvalidIndex || t->index >= v->Size())
618 v = &((*v)[t->index]);
625 if (unresolvedTokenIndex)
626 *unresolvedTokenIndex =
static_cast<size_t>(t -
tokens_);
637 const ValueType* Get(
const ValueType& root,
size_t* unresolvedTokenIndex = 0)
const {
638 return Get(
const_cast<ValueType&
>(root), unresolvedTokenIndex);
656 ValueType& GetWithDefault(ValueType& root,
const ValueType& defaultValue,
typename ValueType::AllocatorType& allocator)
const {
658 ValueType& v = Create(root, allocator, &alreadyExist);
659 return alreadyExist ? v : v.CopyFrom(defaultValue, allocator);
663 ValueType& GetWithDefault(ValueType& root,
const Ch* defaultValue,
typename ValueType::AllocatorType& allocator)
const {
665 ValueType& v = Create(root, allocator, &alreadyExist);
666 return alreadyExist ? v : v.SetString(defaultValue, allocator);
669#if RAPIDJSON_HAS_STDSTRING
671 ValueType& GetWithDefault(ValueType& root,
const std::basic_string<Ch>& defaultValue,
typename ValueType::AllocatorType& allocator)
const {
673 ValueType& v = Create(root, allocator, &alreadyExist);
674 return alreadyExist ? v : v.SetString(defaultValue, allocator);
682 template <
typename T>
684 GetWithDefault(ValueType& root, T defaultValue,
typename ValueType::AllocatorType& allocator)
const {
685 return GetWithDefault(root, ValueType(defaultValue).Move(), allocator);
689 template <
typename stackAllocator>
690 ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document,
const ValueType& defaultValue)
const {
691 return GetWithDefault(document, defaultValue, document.
GetAllocator());
695 template <
typename stackAllocator>
696 ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document,
const Ch* defaultValue)
const {
697 return GetWithDefault(document, defaultValue, document.
GetAllocator());
700#if RAPIDJSON_HAS_STDSTRING
702 template <
typename stackAllocator>
703 ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document,
const std::basic_string<Ch>& defaultValue)
const {
704 return GetWithDefault(document, defaultValue, document.
GetAllocator());
712 template <
typename T,
typename stackAllocator>
714 GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, T defaultValue)
const {
715 return GetWithDefault(document, defaultValue, document.
GetAllocator());
733 ValueType& Set(ValueType& root, ValueType& value,
typename ValueType::AllocatorType& allocator)
const {
734 return Create(root, allocator) = value;
738 ValueType& Set(ValueType& root,
const ValueType& value,
typename ValueType::AllocatorType& allocator)
const {
739 return Create(root, allocator).CopyFrom(value, allocator);
743 ValueType& Set(ValueType& root,
const Ch* value,
typename ValueType::AllocatorType& allocator)
const {
744 return Create(root, allocator) = ValueType(value, allocator).Move();
747#if RAPIDJSON_HAS_STDSTRING
749 ValueType& Set(ValueType& root,
const std::basic_string<Ch>& value,
typename ValueType::AllocatorType& allocator)
const {
750 return Create(root, allocator) = ValueType(value, allocator).Move();
758 template <
typename T>
760 Set(ValueType& root, T value,
typename ValueType::AllocatorType& allocator)
const {
761 return Create(root, allocator) = ValueType(value).Move();
765 template <
typename stackAllocator>
766 ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, ValueType& value)
const {
767 return Create(document) = value;
771 template <
typename stackAllocator>
772 ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document,
const ValueType& value)
const {
773 return Create(document).CopyFrom(value, document.
GetAllocator());
777 template <
typename stackAllocator>
778 ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document,
const Ch* value)
const {
779 return Create(document) = ValueType(value, document.
GetAllocator()).Move();
782#if RAPIDJSON_HAS_STDSTRING
784 template <
typename stackAllocator>
785 ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document,
const std::basic_string<Ch>& value)
const {
786 return Create(document) = ValueType(value, document.
GetAllocator()).Move();
794 template <
typename T,
typename stackAllocator>
796 Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, T value)
const {
797 return Create(document) = value;
815 ValueType&
Swap(ValueType& root, ValueType& value,
typename ValueType::AllocatorType& allocator)
const {
816 return Create(root, allocator).
Swap(value);
820 template <
typename stackAllocator>
821 ValueType&
Swap(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, ValueType& value)
const {
822 return Create(document).
Swap(value);
834 bool Erase(ValueType& root)
const {
839 ValueType* v = &root;
842 switch (v->GetType()) {
845 typename ValueType::MemberIterator m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
846 if (m == v->MemberEnd())
852 if (t->index == kPointerInvalidIndex || t->index >= v->Size())
854 v = &((*v)[t->index]);
861 switch (v->GetType()) {
863 return v->EraseMember(GenericStringRef<Ch>(last->name, last->length));
865 if (last->index == kPointerInvalidIndex || last->index >= v->Size())
867 v->Erase(v->Begin() + last->index);
882 Ch* CopyFromRaw(
const GenericPointer& rhs,
size_t extraToken = 0,
size_t extraNameBufferSize = 0) {
888 nameBufferSize += t->length;
896 if (nameBufferSize > 0) {
919 bool NeedPercentEncode(
Ch c)
const {
920 return !((c >=
'0' && c <=
'9') || (c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z') || c ==
'-' || c ==
'.' || c ==
'_' || c ==
'~');
931 void Parse(
const Ch* source,
size_t length) {
942 for (
const Ch* s = source; s != source + length; s++)
951 bool uriFragment =
false;
952 if (source[i] ==
'#') {
957 if (i != length && source[i] !=
'/') {
967 bool isNumber =
true;
969 while (i < length && source[i] !=
'/') {
974 PercentDecodeStream is(&source[i], source + length);
975 GenericInsituStringStream<EncodingType> os(name);
976 Ch* begin = os.PutBegin();
977 if (!Transcoder<UTF8<>,
EncodingType>().Validate(is, os) || !is.IsValid()) {
981 size_t len = os.PutEnd(begin);
992 else if (NeedPercentEncode(c)) {
1004 if (c ==
'0') c =
'~';
1005 else if (c ==
'1') c =
'/';
1019 if (c <
'0' || c >
'9')
1024 token->length =
static_cast<SizeType>(name - token->name);
1025 if (token->length == 0)
1030 if (isNumber && token->length > 1 && token->name[0] ==
'0')
1036 for (
size_t j = 0; j < token->length; j++) {
1046 token->index = isNumber ? n : kPointerInvalidIndex;
1069 template<
bool uriFragment,
typename OutputStream>
1070 bool Stringify(OutputStream& os)
const {
1078 for (
size_t j = 0; j < t->length; j++) {
1084 else if (c ==
'/') {
1088 else if (uriFragment && NeedPercentEncode(c)) {
1090 GenericStringStream<typename ValueType::EncodingType> source(&t->name[j]);
1092 if (!Transcoder<
EncodingType, UTF8<> >().Validate(source, target))
1094 j += source.Tell() - 1;
1109 class PercentDecodeStream {
1111 typedef typename ValueType::Ch Ch;
1118 PercentDecodeStream(
const Ch* source,
const Ch* end) : src_(source), head_(source), end_(end), valid_(true) {}
1121 if (*src_ !=
'%' || src_ + 3 > end_) {
1127 for (
int j = 0; j < 2; j++) {
1128 c =
static_cast<Ch
>(c << 4);
1130 if (h >=
'0' && h <=
'9') c =
static_cast<Ch
>(c + h -
'0');
1131 else if (h >=
'A' && h <=
'F') c =
static_cast<Ch
>(c + h -
'A' + 10);
1132 else if (h >=
'a' && h <=
'f') c =
static_cast<Ch
>(c + h -
'a' + 10);
1142 size_t Tell()
const {
return static_cast<size_t>(src_ - head_); }
1143 bool IsValid()
const {
return valid_; }
1153 template <
typename OutputStream>
1154 class PercentEncodeStream {
1156 PercentEncodeStream(OutputStream& os) : os_(os) {}
1158 unsigned char u =
static_cast<unsigned char>(c);
1159 static const char hexDigits[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' };
1161 os_.Put(
static_cast<typename OutputStream::Ch
>(hexDigits[u >> 4]));
1162 os_.Put(
static_cast<typename OutputStream::Ch
>(hexDigits[u & 15]));
1185template <
typename T>
1187 return pointer.Create(root, a);
1190template <
typename T,
typename CharType,
size_t N>
1191typename T::ValueType& CreateValueByPointer(T& root,
const CharType(&source)[N],
typename T::AllocatorType& a) {
1197template <
typename DocumentType>
1199 return pointer.Create(document);
1202template <
typename DocumentType,
typename CharType,
size_t N>
1203typename DocumentType::ValueType& CreateValueByPointer(DocumentType& document,
const CharType(&source)[N]) {
1209template <
typename T>
1211 return pointer.Get(root, unresolvedTokenIndex);
1214template <
typename T>
1216 return pointer.Get(root, unresolvedTokenIndex);
1219template <
typename T,
typename CharType,
size_t N>
1220typename T::ValueType* GetValueByPointer(T& root,
const CharType (&source)[N],
size_t* unresolvedTokenIndex = 0) {
1224template <
typename T,
typename CharType,
size_t N>
1225const typename T::ValueType* GetValueByPointer(
const T& root,
const CharType(&source)[N],
size_t* unresolvedTokenIndex = 0) {
1231template <
typename T>
1232typename T::ValueType& GetValueByPointerWithDefault(T& root,
const GenericPointer<typename T::ValueType>& pointer,
const typename T::ValueType& defaultValue,
typename T::AllocatorType& a) {
1233 return pointer.GetWithDefault(root, defaultValue, a);
1236template <
typename T>
1237typename T::ValueType& GetValueByPointerWithDefault(T& root,
const GenericPointer<typename T::ValueType>& pointer,
const typename T::Ch* defaultValue,
typename T::AllocatorType& a) {
1238 return pointer.GetWithDefault(root, defaultValue, a);
1241#if RAPIDJSON_HAS_STDSTRING
1242template <
typename T>
1243typename T::ValueType& GetValueByPointerWithDefault(T& root,
const GenericPointer<typename T::ValueType>& pointer,
const std::basic_string<typename T::Ch>& defaultValue,
typename T::AllocatorType& a) {
1244 return pointer.GetWithDefault(root, defaultValue, a);
1248template <
typename T,
typename T2>
1251 return pointer.GetWithDefault(root, defaultValue, a);
1254template <
typename T,
typename CharType,
size_t N>
1255typename T::ValueType& GetValueByPointerWithDefault(T& root,
const CharType(&source)[N],
const typename T::ValueType& defaultValue,
typename T::AllocatorType& a) {
1259template <
typename T,
typename CharType,
size_t N>
1260typename T::ValueType& GetValueByPointerWithDefault(T& root,
const CharType(&source)[N],
const typename T::Ch* defaultValue,
typename T::AllocatorType& a) {
1264#if RAPIDJSON_HAS_STDSTRING
1265template <
typename T,
typename CharType,
size_t N>
1266typename T::ValueType& GetValueByPointerWithDefault(T& root,
const CharType(&source)[N],
const std::basic_string<typename T::Ch>& defaultValue,
typename T::AllocatorType& a) {
1271template <
typename T,
typename CharType,
size_t N,
typename T2>
1273GetValueByPointerWithDefault(T& root,
const CharType(&source)[N], T2 defaultValue,
typename T::AllocatorType& a) {
1279template <
typename DocumentType>
1281 return pointer.GetWithDefault(document, defaultValue);
1284template <
typename DocumentType>
1286 return pointer.GetWithDefault(document, defaultValue);
1289#if RAPIDJSON_HAS_STDSTRING
1290template <
typename DocumentType>
1292 return pointer.GetWithDefault(document, defaultValue);
1296template <
typename DocumentType,
typename T2>
1297RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>,
internal::IsGenericValue<T2> >), (
typename DocumentType::ValueType&))
1299 return pointer.GetWithDefault(document, defaultValue);
1302template <
typename DocumentType,
typename CharType,
size_t N>
1303typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document,
const CharType(&source)[N],
const typename DocumentType::ValueType& defaultValue) {
1307template <
typename DocumentType,
typename CharType,
size_t N>
1308typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document,
const CharType(&source)[N],
const typename DocumentType::Ch* defaultValue) {
1312#if RAPIDJSON_HAS_STDSTRING
1313template <
typename DocumentType,
typename CharType,
size_t N>
1314typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document,
const CharType(&source)[N],
const std::basic_string<typename DocumentType::Ch>& defaultValue) {
1319template <
typename DocumentType,
typename CharType,
size_t N,
typename T2>
1320RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>,
internal::IsGenericValue<T2> >), (
typename DocumentType::ValueType&))
1321GetValueByPointerWithDefault(DocumentType& document,
const CharType(&source)[N], T2 defaultValue) {
1327template <
typename T>
1329 return pointer.Set(root, value, a);
1332template <
typename T>
1334 return pointer.Set(root, value, a);
1337template <
typename T>
1339 return pointer.Set(root, value, a);
1342#if RAPIDJSON_HAS_STDSTRING
1343template <
typename T>
1344typename T::ValueType& SetValueByPointer(T& root,
const GenericPointer<typename T::ValueType>& pointer,
const std::basic_string<typename T::Ch>& value,
typename T::AllocatorType& a) {
1345 return pointer.Set(root, value, a);
1349template <
typename T,
typename T2>
1352 return pointer.Set(root, value, a);
1355template <
typename T,
typename CharType,
size_t N>
1356typename T::ValueType& SetValueByPointer(T& root,
const CharType(&source)[N],
typename T::ValueType& value,
typename T::AllocatorType& a) {
1360template <
typename T,
typename CharType,
size_t N>
1361typename T::ValueType& SetValueByPointer(T& root,
const CharType(&source)[N],
const typename T::ValueType& value,
typename T::AllocatorType& a) {
1365template <
typename T,
typename CharType,
size_t N>
1366typename T::ValueType& SetValueByPointer(T& root,
const CharType(&source)[N],
const typename T::Ch* value,
typename T::AllocatorType& a) {
1370#if RAPIDJSON_HAS_STDSTRING
1371template <
typename T,
typename CharType,
size_t N>
1372typename T::ValueType& SetValueByPointer(T& root,
const CharType(&source)[N],
const std::basic_string<typename T::Ch>& value,
typename T::AllocatorType& a) {
1377template <
typename T,
typename CharType,
size_t N,
typename T2>
1379SetValueByPointer(T& root,
const CharType(&source)[N], T2 value,
typename T::AllocatorType& a) {
1385template <
typename DocumentType>
1387 return pointer.Set(document, value);
1390template <
typename DocumentType>
1392 return pointer.Set(document, value);
1395template <
typename DocumentType>
1397 return pointer.Set(document, value);
1400#if RAPIDJSON_HAS_STDSTRING
1401template <
typename DocumentType>
1403 return pointer.Set(document, value);
1407template <
typename DocumentType,
typename T2>
1408RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>,
internal::IsGenericValue<T2> >), (
typename DocumentType::ValueType&))
1410 return pointer.Set(document, value);
1413template <
typename DocumentType,
typename CharType,
size_t N>
1414typename DocumentType::ValueType& SetValueByPointer(DocumentType& document,
const CharType(&source)[N],
typename DocumentType::ValueType& value) {
1418template <
typename DocumentType,
typename CharType,
size_t N>
1419typename DocumentType::ValueType& SetValueByPointer(DocumentType& document,
const CharType(&source)[N],
const typename DocumentType::ValueType& value) {
1423template <
typename DocumentType,
typename CharType,
size_t N>
1424typename DocumentType::ValueType& SetValueByPointer(DocumentType& document,
const CharType(&source)[N],
const typename DocumentType::Ch* value) {
1428#if RAPIDJSON_HAS_STDSTRING
1429template <
typename DocumentType,
typename CharType,
size_t N>
1430typename DocumentType::ValueType& SetValueByPointer(DocumentType& document,
const CharType(&source)[N],
const std::basic_string<typename DocumentType::Ch>& value) {
1435template <
typename DocumentType,
typename CharType,
size_t N,
typename T2>
1436RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>,
internal::IsGenericValue<T2> >), (
typename DocumentType::ValueType&))
1437SetValueByPointer(DocumentType& document,
const CharType(&source)[N], T2 value) {
1443template <
typename T>
1445 return pointer.
Swap(root, value, a);
1448template <
typename T,
typename CharType,
size_t N>
1449typename T::ValueType& SwapValueByPointer(T& root,
const CharType(&source)[N],
typename T::ValueType& value,
typename T::AllocatorType& a) {
1453template <
typename DocumentType>
1455 return pointer.
Swap(document, value);
1458template <
typename DocumentType,
typename CharType,
size_t N>
1459typename DocumentType::ValueType& SwapValueByPointer(DocumentType& document,
const CharType(&source)[N],
typename DocumentType::ValueType& value) {
1465template <
typename T>
1467 return pointer.Erase(root);
1470template <
typename T,
typename CharType,
size_t N>
1471bool EraseValueByPointer(T& root,
const CharType(&source)[N]) {
1479#if defined(__clang__) || defined(_MSC_VER)
Allocator & GetAllocator()
Get the allocator of this document.
A helper stream to encode character (UTF-8 code unit) into percent-encoded sequence.
Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.
friend void swap(GenericPointer &a, GenericPointer &b) RAPIDJSON_NOEXCEPT
free-standing swap function helper
CrtAllocator * allocator_
GenericPointer(const GenericPointer &rhs, Allocator *allocator)
Copy constructor.
GenericPointer(const Ch *source, Allocator *allocator=0)
Constructor that parses a string or URI fragment representation.
Value::EncodingType EncodingType
GenericPointer(const Token *tokens, size_t tokenCount)
Constructor with user-supplied tokens.
GenericPointer(Allocator *allocator=0)
Default constructor.
GenericPointer(const GenericPointer &rhs)
Copy constructor.
PointerParseErrorCode parseErrorCode_
CrtAllocator * ownAllocator_
GenericPointer(const Ch *source, size_t length, Allocator *allocator=0)
Constructor that parses a string or URI fragment representation, with length of the source string.
GenericPointer Append(const Ch *name, SizeType length, Allocator *allocator=0) const
Append a name token with length, and return a new Pointer.
GenericPointer Append(const Token &token, Allocator *allocator=0) const
Append a token and return a new Pointer.
RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr< internal::IsSame< typename internal::RemoveConst< T >::Type, Ch > >),(GenericPointer)) Append(T *name
Append a name token without length, and return a new Pointer.
~GenericPointer()
Destructor.
GenericPointer & operator=(const GenericPointer &rhs)
Assignment operator.
GenericPointer & Swap(GenericPointer &other) RAPIDJSON_NOEXCEPT
Swap the content of this pointer with an other.
Concept for allocating, resizing and freeing memory block.
#define RAPIDJSON_ASSERT(x)
Assertion.
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
PointerParseErrorCode
Error code of JSON pointer parsing.
@ kPointerParseErrorInvalidEscape
Invalid escape.
@ kPointerParseErrorTokenMustBeginWithSolidus
A token must begin with a '/'.
@ kPointerParseErrorNone
The parse is successful.
@ kPointerParseErrorCharacterMustPercentEncode
A character must percent encoded in URI fragment.
@ kPointerParseErrorInvalidPercentEncoding
Invalid percent encoding in URI fragment.
Integer len(const char *s)
Retourne la longueur de la chaîne s.
bool operator<(const Item &item1, const Item &item2)
Compare deux entités.
#define RAPIDJSON_DELETE(x)
! customization point for global delete
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
A token is the basic units of internal representation.
SizeType index
A valid array index, if it is not equal to kPointerInvalidIndex.
SizeType length
Length of the name.
const Ch * name
Name of the token. It has null character at the end but it can contain null character.