MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / HashRapidValue

Function HashRapidValue

rapidjsonwrapper.h:69–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68
69static inline uint64_t HashRapidValue(const rapidjson::Value& val)
70{
71 const auto type = static_cast<std::size_t>(val.GetType());
72 switch (val.GetType())
73 {
74 case rapidjson::kNullType:
75 case rapidjson::kFalseType:
76 {
77 return combine(type, 0);
78 }
79 case rapidjson::kObjectType:
80 {
81 auto seed = combine(type, val.MemberCount());
82 for (const auto& element : val.GetObj())
83 {
84 const auto h = HashBytes(element.name.GetString(), element.name.GetStringLength());
85 seed = combine(seed, h);
86 seed = combine(seed, HashRapidValue(element.value));
87 }
88 return seed;
89 }
90 case rapidjson::kArrayType:
91 {
92 auto seed = combine(type, val.Size());
93 for (const auto& element : val.GetArray())
94 {
95 seed = combine(seed, HashRapidValue(element));
96 }
97 return seed;
98 }
99 case rapidjson::kStringType:
100 {
101 return combine(type, HashBytes(val.GetString(), val.GetStringLength()));
102 }
103 case rapidjson::kTrueType:
104 {
105 return combine(type, 1);
106 }
107 case rapidjson::kNumberType:
108 {
109 if (val.IsInt64())
110 {
111 return combine(type, static_cast<size_t>(val.GetInt64()));
112 }
113 else if (val.IsUint64())
114 {
115 return combine(type, val.GetUint64());
116 }
117 else if (val.IsUint())
118 {
119 return combine(type, static_cast<size_t>(val.GetUint()));
120 }
121 else if (val.IsInt())
122 {
123 return combine(type, static_cast<size_t>(val.GetInt()));
124 }
125 else
126 {

Callers

nothing calls this directly

Calls 8

combineFunction · 0.85
HashBytesFunction · 0.85
MemberCountMethod · 0.80
GetArrayMethod · 0.80
GetDoubleMethod · 0.80
GetTypeMethod · 0.45
GetStringMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected