MCPcopy Create free account
hub / github.com/Snapchat/Valdi / hash

Method hash

valdi_core/src/valdi_core/cpp/Schema/ValueSchema.cpp:372–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370 return ValueSchemaParser::parse(str);
371}
372
373size_t ValueSchema::hash() const {
374 auto baseHash = static_cast<size_t>(_type);
375
376 visitNestedType(
377 *this,
378 [&](const ValueSchemaTypeReference& typeReference) { boost::hash_combine(baseHash, typeReference.hash()); },
379 [&](const GenericValueSchemaTypeReference& genericTypeReference) {
380 boost::hash_combine(baseHash, genericTypeReference.getType().hash());
381 for (size_t i = 0; i < genericTypeReference.getTypeArgumentsSize(); i++) {
382 boost::hash_combine(baseHash, genericTypeReference.getTypeArgument(i).hash());
383 }
384 },
385 [&](const ClassSchema& classSchema) { boost::hash_combine(baseHash, classSchema.hash()); },
386 [&](const EnumSchema& enumSchema) {
387 boost::hash_combine(baseHash, enumSchema.getName().hash());
388 boost::hash_combine(baseHash, enumSchema.getCaseSchema().hash());
389 for (size_t i = 0; i < enumSchema.getCasesSize(); i++) {
390 const auto& enumCase = enumSchema.getCase(i);
391 boost::hash_combine(baseHash, enumCase.name.hash());
392 boost::hash_combine(baseHash, enumCase.value.hash());
393 }
394 },
395 [&](const ValueFunctionSchema& functionSchema) {
396 const auto& attributes = functionSchema.getAttributes();
397 boost::hash_combine(baseHash, attributes.isMethod());
398 boost::hash_combine(baseHash, attributes.isSingleCall());
399 boost::hash_combine(baseHash, attributes.shouldDispatchToWorkerThread());
400 boost::hash_combine(baseHash, attributes.allowSyncCall());
401 boost::hash_combine(baseHash, functionSchema.getReturnValue().hash());
402 for (size_t i = 0; i < functionSchema.getParametersSize(); i++) {
403 boost::hash_combine(baseHash, functionSchema.getParameter(i).hash());
404 }
405 },
406 [&](const ArraySchema& arraySchema) { boost::hash_combine(baseHash, arraySchema.getElementSchema().hash()); },
407 [&](const MapSchema& mapSchema) {
408 boost::hash_combine(baseHash, mapSchema.getKey().hash());
409 boost::hash_combine(baseHash, mapSchema.getValue().hash());
410 },
411 [&](const ES6MapSchema& es6mapSchema) {
412 boost::hash_combine(baseHash, es6mapSchema.getKey().hash());
413 boost::hash_combine(baseHash, es6mapSchema.getValue().hash());
414 },
415 [&](const ES6SetSchema& es6setSchema) { boost::hash_combine(baseHash, es6setSchema.getKey().hash()); },
416 [&](const OutcomeSchema& outcomeSchema) {
417 boost::hash_combine(baseHash, outcomeSchema.getValue().hash());
418 boost::hash_combine(baseHash, outcomeSchema.getError().hash());
419 },
420 [&](const ProtoSchema& protoSchema) { boost::hash_combine(baseHash, protoSchema.hash()); },
421 [&](const PromiseSchema& promiseSchema) {
422 boost::hash_combine(baseHash, promiseSchema.getValueSchema().hash());
423 },
424 [&](const ValueSchemaReference& schemaReference) {
425 boost::hash_combine(baseHash, schemaReference.getKey().hash());
426 });
427
428 boost::hash_combine(baseHash, _flags);
429 return baseHash;

Callers 1

operator()Method · 0.45

Calls 15

visitNestedTypeFunction · 0.85
hash_combineFunction · 0.85
getTypeArgumentsSizeMethod · 0.80
getCasesSizeMethod · 0.80
isMethodMethod · 0.80
allowSyncCallMethod · 0.80
getParameterMethod · 0.80
getKeyMethod · 0.80
getAttributesMethod · 0.65
getValueMethod · 0.65
getTypeMethod · 0.45

Tested by

no test coverage detected