Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
internal::Hasher< Encoding, Allocator > Class Template Reference

#include <schema.h>

Classes

struct  Number
 

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
 

Private Member Functions

bool WriteType (Type type)
 
bool WriteNumber (const Number &n)
 
bool WriteBuffer (Type type, const void *data, size_t len)
 

Static Private Member Functions

static uint64_t Hash (uint64_t h, uint64_t d)
 

Private Attributes

Stack< Allocator > stack_
 

Static Private Attributes

static const size_t kDefaultSize = 256
 

Detailed Description

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

Definition at line 220 of file schema.h.

Member Typedef Documentation

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

Definition at line 222 of file schema.h.

Constructor & Destructor Documentation

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) {}
Stack< Allocator > stack_
Definition: schema.h:309

Member Function Documentation

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); }
bool WriteType(Type type)
Definition: schema.h:288
false
Definition: rapidjson.h:620
static bool * b
Definition: config.cpp:1043
true
Definition: rapidjson.h:621
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  }
std::void_t< T > n
unsigned __int64 uint64_t
Definition: stdint.h:136
signed __int64 int64_t
Definition: stdint.h:135
bool WriteNumber(const Number &n)
Definition: schema.h:290
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  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
array
Definition: rapidjson.h:623
Stack< Allocator > stack_
Definition: schema.h:309
const double e
unsigned __int64 uint64_t
Definition: stdint.h:136
static uint64_t Hash(uint64_t h, uint64_t d)
Definition: schema.h:302
h
training ###############################
Definition: train_cnn.py:186
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  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
object
Definition: rapidjson.h:622
Stack< Allocator > stack_
Definition: schema.h:309
unsigned __int64 uint64_t
Definition: stdint.h:136
static uint64_t Hash(uint64_t h, uint64_t d)
Definition: schema.h:302
h
training ###############################
Definition: train_cnn.py:186
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  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Stack< Allocator > stack_
Definition: schema.h:309
bool IsValid() const
Definition: schema.h:271
template<typename Encoding , typename Allocator >
static uint64_t internal::Hasher< Encoding, Allocator >::Hash ( uint64_t  h,
uint64_t  d 
)
inlinestaticprivate

Definition at line 302 of file schema.h.

302  {
303  static const uint64_t kPrime = RAPIDJSON_UINT64_C2(0x00000100, 0x000001b3);
304  h ^= d;
305  h *= kPrime;
306  return h;
307  }
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:289
unsigned __int64 uint64_t
Definition: stdint.h:136
h
training ###############################
Definition: train_cnn.py:186
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); }
std::void_t< T > n
bool WriteNumber(const Number &n)
Definition: schema.h:290
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); }
std::void_t< T > n
bool WriteNumber(const Number &n)
Definition: schema.h:290
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); }
Stack< Allocator > stack_
Definition: schema.h:309
unsigned __int64 uint64_t
Definition: stdint.h:136
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
T copy(T const &v)
static QCString str
template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::Null ( )
inline

Definition at line 226 of file schema.h.

226 { return WriteType(kNullType); }
bool WriteType(Type type)
Definition: schema.h:288
null
Definition: rapidjson.h:619
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
bool WriteBuffer(Type type, const void *data, size_t len)
Definition: schema.h:292
number
Definition: rapidjson.h:625
static QCString str
template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::StartArray ( )
inline

Definition at line 261 of file schema.h.

261 { return true; }
template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::StartObject ( )
inline

Definition at line 250 of file schema.h.

250 { return true; }
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  }
Encoding::Ch Ch
Definition: schema.h:222
bool WriteBuffer(Type type, const void *data, size_t len)
Definition: schema.h:292
string
Definition: rapidjson.h:624
static QCString str
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); }
std::void_t< T > n
bool WriteNumber(const Number &n)
Definition: schema.h:290
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); }
std::void_t< T > n
bool WriteNumber(const Number &n)
Definition: schema.h:290
template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::WriteBuffer ( Type  type,
const void *  data,
size_t  len 
)
inlineprivate

Definition at line 292 of file schema.h.

292  {
293  // FNV-1a from http://isthe.com/chongo/tech/comp/fnv/
294  uint64_t h = Hash(RAPIDJSON_UINT64_C2(0x84222325, 0xcbf29ce4), type);
295  const unsigned char* d = static_cast<const unsigned char*>(data);
296  for (size_t i = 0; i < len; i++)
297  h = Hash(h, d[i]);
298  *stack_.template Push<uint64_t>() = h;
299  return true;
300  }
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:289
Stack< Allocator > stack_
Definition: schema.h:309
unsigned __int64 uint64_t
Definition: stdint.h:136
static uint64_t Hash(uint64_t h, uint64_t d)
Definition: schema.h:302
h
training ###############################
Definition: train_cnn.py:186
template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::WriteNumber ( const Number n)
inlineprivate

Definition at line 290 of file schema.h.

290 { return WriteBuffer(kNumberType, &n, sizeof(n)); }
bool WriteBuffer(Type type, const void *data, size_t len)
Definition: schema.h:292
std::void_t< T > n
number
Definition: rapidjson.h:625
template<typename Encoding , typename Allocator >
bool internal::Hasher< Encoding, Allocator >::WriteType ( Type  type)
inlineprivate

Definition at line 288 of file schema.h.

288 { return WriteBuffer(type, 0, 0); }
bool WriteBuffer(Type type, const void *data, size_t len)
Definition: schema.h:292

Member Data Documentation

template<typename Encoding , typename Allocator >
const size_t internal::Hasher< Encoding, Allocator >::kDefaultSize = 256
staticprivate

Definition at line 279 of file schema.h.

template<typename Encoding , typename Allocator >
Stack<Allocator> internal::Hasher< Encoding, Allocator >::stack_
private

Definition at line 309 of file schema.h.


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