Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
internal::Hasher< Encoding, Allocator > Class Template Reference

#include <schema.h>

Public Types

typedef Encoding::Ch Ch
 

Public Member Functions

 Hasher (Allocator *allocator=0, size_t stackCapacity=kDefaultSize)
 
bool Null ()
 
bool Bool (bool b)
 
bool Int (int i)
 
bool Uint (unsigned u)
 
bool Int64 (int64_t i)
 
bool Uint64 (uint64_t u)
 
bool Double (double d)
 
bool RawNumber (const Ch *str, SizeType len, bool)
 
bool String (const Ch *str, SizeType len, bool)
 
bool StartObject ()
 
bool Key (const Ch *str, SizeType len, bool copy)
 
bool EndObject (SizeType memberCount)
 
bool StartArray ()
 
bool EndArray (SizeType elementCount)
 
bool IsValid () const
 
uint64_t GetHashCode () const
 

Detailed Description

template<typename Encoding, typename Allocator>
class internal::Hasher< Encoding, Allocator >

Definition at line 220 of file schema.h.

Member Typedef Documentation

◆ Ch

template<typename Encoding , typename Allocator >
Encoding::Ch internal::Hasher< Encoding, Allocator >::Ch

Definition at line 222 of file schema.h.

Constructor & Destructor Documentation

◆ Hasher()

template<typename Encoding , typename Allocator >
internal::Hasher< Encoding, Allocator >::Hasher ( Allocator * allocator = 0,
size_t stackCapacity = kDefaultSize )
inline

Definition at line 224 of file schema.h.

224: stack_(allocator, stackCapacity) {}

Member Function Documentation

◆ Bool()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Bool ( bool b)
inline

Definition at line 227 of file schema.h.

227{ return WriteType(b ? kTrueType : kFalseType); }
@ kFalseType
false
Definition rapidjson.h:646
@ kTrueType
true
Definition rapidjson.h:647

◆ Double()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Double ( double d)
inline

Definition at line 232 of file schema.h.

232 {
233 Number n;
234 if (d < 0) n.u.i = static_cast<int64_t>(d);
235 else n.u.u = static_cast<uint64_t>(d);
236 n.d = d;
237 return WriteNumber(n);
238 }
const detail::Number Number
Check for a number.
Definition CLI11.hpp:2510
signed __int64 int64_t
Definition stdint.h:135
unsigned __int64 uint64_t
Definition stdint.h:136
CK_ULONG d

◆ EndArray()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::EndArray ( SizeType elementCount)
inline

Definition at line 262 of file schema.h.

262 {
263 uint64_t h = Hash(0, kArrayType);
264 uint64_t* e = stack_.template Pop<uint64_t>(elementCount);
265 for (SizeType i = 0; i < elementCount; i++)
266 h = Hash(h, e[i]); // Use hash to achieve element order sensitive
267 *stack_.template Push<uint64_t>() = h;
268 return true;
269 }
@ kArrayType
array
Definition rapidjson.h:649
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition rapidjson.h:384

◆ EndObject()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::EndObject ( SizeType memberCount)
inline

Definition at line 252 of file schema.h.

252 {
253 uint64_t h = Hash(0, kObjectType);
254 uint64_t* kv = stack_.template Pop<uint64_t>(memberCount * 2);
255 for (SizeType i = 0; i < memberCount; i++)
256 h ^= Hash(kv[i * 2], kv[i * 2 + 1]); // Use xor to achieve member order insensitive
257 *stack_.template Push<uint64_t>() = h;
258 return true;
259 }
@ kObjectType
object
Definition rapidjson.h:648

◆ GetHashCode()

template<typename Encoding , typename Allocator >
uint64_t internal::Hasher< Encoding, Allocator >::GetHashCode ( ) const
inline

Definition at line 273 of file schema.h.

273 {
275 return *stack_.template Top<uint64_t>();
276 }
bool IsValid() const
Definition schema.h:271
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:406
Here is the call graph for this function:

◆ Int()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Int ( int i)
inline

Definition at line 228 of file schema.h.

228{ Number n; n.u.i = i; n.d = static_cast<double>(i); return WriteNumber(n); }

◆ Int64()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Int64 ( int64_t i)
inline

Definition at line 230 of file schema.h.

230{ Number n; n.u.i = i; n.d = static_cast<double>(i); return WriteNumber(n); }

◆ IsValid()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::IsValid ( ) const
inline

Definition at line 271 of file schema.h.

271{ return stack_.GetSize() == sizeof(uint64_t); }
Here is the caller graph for this function:

◆ Key()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Key ( const Ch * str,
SizeType len,
bool copy )
inline

Definition at line 251 of file schema.h.

251{ return String(str, len, copy); }
bool String(const Ch *str, SizeType len, bool)
Definition schema.h:245
size_t len
Here is the call graph for this function:

◆ Null()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Null ( )
inline

Definition at line 226 of file schema.h.

226{ return WriteType(kNullType); }
@ kNullType
null
Definition rapidjson.h:645

◆ RawNumber()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::RawNumber ( const Ch * str,
SizeType len,
bool  )
inline

Definition at line 240 of file schema.h.

240 {
241 WriteBuffer(kNumberType, str, len * sizeof(Ch));
242 return true;
243 }
Encoding::Ch Ch
Definition schema.h:222
@ kNumberType
number
Definition rapidjson.h:651

◆ StartArray()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::StartArray ( )
inline

Definition at line 261 of file schema.h.

261{ return true; }

◆ StartObject()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::StartObject ( )
inline

Definition at line 250 of file schema.h.

250{ return true; }

◆ String()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::String ( const Ch * str,
SizeType len,
bool  )
inline

Definition at line 245 of file schema.h.

245 {
246 WriteBuffer(kStringType, str, len * sizeof(Ch));
247 return true;
248 }
@ kStringType
string
Definition rapidjson.h:650
Here is the caller graph for this function:

◆ Uint()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Uint ( unsigned u)
inline

Definition at line 229 of file schema.h.

229{ Number n; n.u.u = u; n.d = static_cast<double>(u); return WriteNumber(n); }

◆ Uint64()

template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Uint64 ( uint64_t u)
inline

Definition at line 231 of file schema.h.

231{ Number n; n.u.u = u; n.d = static_cast<double>(u); return WriteNumber(n); }

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