Classes | Public Types | Public Attributes | List of all members
GenericPointer< ValueType, Allocator > Class Template Reference

#include <fwd.h>

Classes

class  PercentEncodeStream
 
struct  Token
 A token is the basic units of internal representation. More...
 

Public Types

typedef ValueType::Ch Ch
 Character type from Value. More...
 
typedef ValueType::EncodingType EncodingType
 Encoding type from Value. More...
 

Public Member Functions

Append token
GenericPointer Append (const Token &token, Allocator *allocator=0) const
 Append a token and return a new Pointer. More...
 
GenericPointer Append (const Ch *name, SizeType length, Allocator *allocator=0) const
 Append a name token with length, and return a new Pointer. More...
 
template<typename T >
 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. More...
 

Public Attributes

Allocator * allocator
 
Allocator * allocator_
 
ChnameBuffer_
 A buffer containing all names in tokens. More...
 
Allocator * ownAllocator_
 Allocator owned by this Pointer. More...
 
PointerParseErrorCode parseErrorCode_
 Parsing error code. More...
 
size_t parseErrorOffset_
 Offset in code unit when parsing fail. More...
 
size_t tokenCount_
 Number of tokens in tokens_. More...
 
Tokentokens_
 A list of tokens. More...
 

Constructors and destructor.

 GenericPointer (Allocator *allocator=0)
 Default constructor. More...
 
 GenericPointer (const Ch *source, Allocator *allocator=0)
 Constructor that parses a string or URI fragment representation. More...
 
 GenericPointer (const Ch *source, size_t length, Allocator *allocator=0)
 
 GenericPointer (const Token *tokens, size_t tokenCount)
 Constructor with user-supplied tokens. More...
 
 GenericPointer (const GenericPointer &rhs)
 Copy constructor. More...
 
 GenericPointer (const GenericPointer &rhs, Allocator *allocator)
 Copy constructor. More...
 
 ~GenericPointer ()
 Destructor. More...
 
GenericPointeroperator= (const GenericPointer &rhs)
 Assignment operator. More...
 
GenericPointerSwap (GenericPointer &other) RAPIDJSON_NOEXCEPT
 Swap the content of this pointer with an other. More...
 
void swap (GenericPointer &a, GenericPointer &b) RAPIDJSON_NOEXCEPT
 free-standing swap function helper More...
 

Detailed Description

template<typename ValueType, typename Allocator = CrtAllocator>
class GenericPointer< ValueType, Allocator >

Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.

This class implements RFC 6901 "JavaScript Object Notation (JSON) Pointer" (https://tools.ietf.org/html/rfc6901).

A JSON pointer is for identifying a specific value in a JSON document (GenericDocument). It can simplify coding of DOM tree manipulation, because it can access multiple-level depth of DOM tree with single API call.

After it parses a string representation (e.g. "/foo/0" or URI fragment representation (e.g. "#/foo/0") into its internal representation (tokens), it can be used to resolve a specific value in multiple documents, or sub-tree of documents.

Contrary to GenericValue, Pointer can be copy constructed and copy assigned. Apart from assignment, a Pointer cannot be modified after construction.

Although Pointer is very convenient, please aware that constructing Pointer involves parsing and dynamic memory allocation. A special constructor with user- supplied tokens eliminates these.

GenericPointer depends on GenericDocument and GenericValue.

Template Parameters
ValueTypeThe value type of the DOM tree. E.g. GenericValue<UTF8<> >
AllocatorThe allocator type for allocating memory for internal representation.
Note
GenericPointer uses same encoding of ValueType. However, Allocator of GenericPointer is independent of Allocator of Value.

Definition at line 144 of file fwd.h.

Member Typedef Documentation

template<typename ValueType, typename Allocator = CrtAllocator>
typedef ValueType::Ch GenericPointer< ValueType, Allocator >::Ch

Character type from Value.

Definition at line 94 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
typedef ValueType::EncodingType GenericPointer< ValueType, Allocator >::EncodingType

Encoding type from Value.

Definition at line 93 of file pointer.h.

Constructor & Destructor Documentation

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer< ValueType, Allocator >::GenericPointer ( Allocator *  allocator = 0)
inline

Default constructor.

Definition at line 123 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer< ValueType, Allocator >::GenericPointer ( const Ch source,
Allocator *  allocator = 0 
)
inlineexplicit

Constructor that parses a string or URI fragment representation.

Parameters
sourceA null-terminated, string or URI fragment representation of JSON pointer.
allocatorUser supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one.

Definition at line 138 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer< ValueType, Allocator >::GenericPointer ( const Ch source,
size_t  length,
Allocator *  allocator = 0 
)
inline

Constructor that parses a string or URI fragment representation, with length of the source string.

Parameters
sourceA string or URI fragment representation of JSON pointer.
lengthLength of source.
allocatorUser supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one.
Note
Slightly faster than the overload without length.

Definition at line 179 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer< ValueType, Allocator >::GenericPointer ( const Token tokens,
size_t  tokenCount 
)
inline

Constructor with user-supplied tokens.

This constructor let user supplies const array of tokens. This prevents the parsing process and eliminates allocation. This is preferred for memory constrained environments.

Parameters
tokensAn constant array of tokens representing the JSON pointer.
tokenCountNumber of tokens.

Example

#define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1, kPointerInvalidIndex }
#define INDEX(i) { #i, sizeof(#i) - 1, i }
static const Pointer::Token kTokens[] = { NAME("foo"), INDEX(123) };
static const Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));
// Equivalent to static const Pointer p("/foo/123");
#undef NAME
#undef INDEX

Definition at line 212 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer< ValueType, Allocator >::GenericPointer ( const GenericPointer< ValueType, Allocator > &  rhs)
inline

Copy constructor.

Definition at line 222 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer< ValueType, Allocator >::GenericPointer ( const GenericPointer< ValueType, Allocator > &  rhs,
Allocator *  allocator 
)
inline

Copy constructor.

Definition at line 234 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer< ValueType, Allocator >::~GenericPointer ( )
inline

Destructor.

Definition at line 246 of file pointer.h.

Member Function Documentation

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer GenericPointer< ValueType, Allocator >::Append ( const Token token,
Allocator *  allocator = 0 
) const
inline

Append a token and return a new Pointer.

Parameters
tokenToken to be appended.
allocatorAllocator for the newly return Pointer.
Returns
A new Pointer with appended token.

Definition at line 316 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer GenericPointer< ValueType, Allocator >::Append ( const Ch name,
SizeType  length,
Allocator *  allocator = 0 
) const
inline

Append a name token with length, and return a new Pointer.

Parameters
nameName to be appended.
lengthLength of name.
allocatorAllocator for the newly return Pointer.
Returns
A new Pointer with appended token.

Definition at line 334 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer& GenericPointer< ValueType, Allocator >::operator= ( const GenericPointer< ValueType, Allocator > &  rhs)
inline

Assignment operator.

Definition at line 255 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
template<typename T >
GenericPointer< ValueType, Allocator >::RAPIDJSON_DISABLEIF_RETURN ( (internal::NotExpr< internal::IsSame< typename internal::RemoveConst< T >::Type, Ch >>)  ,
(GenericPointer< ValueType, Allocator >)   
)

Append a name token without length, and return a new Pointer.

Parameters
nameName (const Ch*) to be appended.
allocatorAllocator for the newly return Pointer.
Returns
A new Pointer with appended token.
template<typename ValueType, typename Allocator = CrtAllocator>
GenericPointer& GenericPointer< ValueType, Allocator >::Swap ( GenericPointer< ValueType, Allocator > &  other)
inline

Swap the content of this pointer with an other.

Parameters
otherThe pointer to swap with.
Note
Constant complexity.

Definition at line 279 of file pointer.h.

Friends And Related Function Documentation

template<typename ValueType, typename Allocator = CrtAllocator>
void swap ( GenericPointer< ValueType, Allocator > &  a,
GenericPointer< ValueType, Allocator > &  b 
)
friend

free-standing swap function helper

Helper function to enable support for common swap implementation pattern based on std::swap: void swap(MyClass& a, MyClass& b) { using std::swap; swap(a.pointer, b.pointer); // ... }

See also
Swap()

Definition at line 300 of file pointer.h.

Member Data Documentation

template<typename ValueType, typename Allocator = CrtAllocator>
Allocator* GenericPointer< ValueType, Allocator >::allocator

Definition at line 351 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
Allocator* GenericPointer< ValueType, Allocator >::allocator_

The current allocator. It is either user-supplied or equal to ownAllocator_.

Definition at line 1254 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
Ch* GenericPointer< ValueType, Allocator >::nameBuffer_

A buffer containing all names in tokens.

Definition at line 1257 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
Allocator* GenericPointer< ValueType, Allocator >::ownAllocator_

Allocator owned by this Pointer.

Definition at line 1256 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
PointerParseErrorCode GenericPointer< ValueType, Allocator >::parseErrorCode_

Parsing error code.

Definition at line 1261 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
size_t GenericPointer< ValueType, Allocator >::parseErrorOffset_

Offset in code unit when parsing fail.

Definition at line 1260 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
size_t GenericPointer< ValueType, Allocator >::tokenCount_

Number of tokens in tokens_.

Definition at line 1259 of file pointer.h.

template<typename ValueType, typename Allocator = CrtAllocator>
Token* GenericPointer< ValueType, Allocator >::tokens_

A list of tokens.

Definition at line 1258 of file pointer.h.


The documentation for this class was generated from the following files:


livox_ros_driver
Author(s): Livox Dev Team
autogenerated on Mon Mar 15 2021 02:40:46