MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / Compare

Method Compare

include/cpp/Variant.h:495–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493
494
495 int Variant::Compare(hx::Object *inPtr) const
496 {
497 if (!inPtr)
498 return isNull() ? 0 : 1;
499
500 switch(type)
501 {
502 case typeInt:
503 {
504 double diff = valInt - inPtr->__ToDouble();
505 return diff<0 ? -1 : diff==0 ? 0 : 1;
506 }
507 case typeDouble:
508 {
509 double diff = valDouble - inPtr->__ToDouble();
510 return diff<0 ? -1 : diff==0 ? 0 : 1;
511 }
512 case typeInt64:
513 {
514 cpp::Int64 diff = valInt64 - inPtr->__ToInt64();
515 return diff<0 ? -1 : diff==0 ? 0 : 1;
516 }
517 case typeBool:
518 if (!inPtr) return 1;
519 return valBool==(bool)(inPtr->__ToInt()) ? 1 : 0;
520 case typeString:
521 if (!inPtr) return valStringPtr ? 1 : 0;
522 if (inPtr->__GetType()!=vtString)
523 return 1;
524 return String(valStringPtr, valStringLen)==inPtr->toString() ? 1 : 0;
525 case typeObject:
526 return valObject->__Compare( inPtr );
527 default: ;
528
529 }
530 return 0;
531 }
532 int Variant::Compare(const Dynamic &inD) const { return Compare(inD.mPtr); }
533 int Variant::Compare(const cpp::Variant &inVar) const
534 {

Callers 2

operator==Method · 0.80
operator!=Method · 0.80

Calls 11

isNullFunction · 0.85
CompareFunction · 0.85
asDoubleMethod · 0.80
asStringMethod · 0.80
StringClass · 0.50
__ToDoubleMethod · 0.45
__ToInt64Method · 0.45
__ToIntMethod · 0.45
__GetTypeMethod · 0.45
toStringMethod · 0.45
__CompareMethod · 0.45

Tested by

no test coverage detected