MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / operator_partial

Method operator_partial

src/Variant.cpp:984–1154  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Partial match is mostly a clone of operator==, but with some overrides: date date --> same day check string string --> leftmost

Source from the content-addressed store, hash-verified

982// string <partial> string --> leftmost
983//
984bool Variant::operator_partial(const Variant& other) const {
985 Variant left(*this);
986 Variant right(other);
987
988 if (left._type == type_string) Lexer::dequote(left._string);
989
990 if (right._type == type_string) Lexer::dequote(right._string);
991
992 switch (left._type) {
993 case type_boolean:
994 switch (right._type) {
995 case type_boolean:
996 return left._bool == right._bool;
997 case type_integer:
998 left.cast(type_integer);
999 return left._integer == right._integer;
1000 case type_real:
1001 left.cast(type_real);
1002 return left._real == right._real;
1003 case type_string:
1004 left.cast(type_string);
1005 return left._string == right._string;
1006
1007 // Same-day comparison.
1008 case type_date: {
1009 left.cast(type_date);
1010 Datetime left_date(left._date);
1011 Datetime right_date(right._date);
1012 return left_date.sameDay(right_date);
1013 }
1014
1015 case type_duration:
1016 left.cast(type_duration);
1017 return left._duration == right._duration;
1018 }
1019 break;
1020
1021 case type_integer:
1022 switch (right._type) {
1023 case type_boolean:
1024 right.cast(type_integer);
1025 return left._integer == right._integer;
1026 case type_integer:
1027 return left._integer == right._integer;
1028 case type_real:
1029 left.cast(type_real);
1030 return left._real == right._real;
1031 case type_string:
1032 left.cast(type_string);
1033 return left._string == right._string;
1034
1035 // Same-day comparison.
1036 case type_date: {
1037 left.cast(type_date);
1038 Datetime left_date(left._date);
1039 Datetime right_date(right._date);
1040 return left_date.sameDay(right_date);
1041 }

Callers 2

TEST_NAMEFunction · 0.80
evaluatePostfixStackMethod · 0.80

Calls 3

castMethod · 0.80
sourceMethod · 0.80
trivialMethod · 0.80

Tested by 1

TEST_NAMEFunction · 0.64