MCPcopy Create free account
hub / github.com/catboost/catboost / GetDoubleRobust

Method GetDoubleRobust

library/cpp/json/ordered_maps/json_value_ordered.cpp:637–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635 }
636
637 double TJsonValue::GetDoubleRobust() const noexcept {
638 switch (Type) {
639 case JSON_ARRAY:
640 return Value.Array->size();
641 case JSON_MAP:
642 return Value.Map->size();
643 case JSON_BOOLEAN:
644 return Value.Boolean;
645 case JSON_INTEGER:
646 return Value.Integer;
647 case JSON_UINTEGER:
648 return Value.UInteger;
649 case JSON_STRING:
650 try {
651 double res = 0;
652 if (Value.String && TryFromString(Value.String, res)) {
653 return res;
654 }
655 } catch (const yexception&) {
656 }
657 return 0;
658 case JSON_NULL:
659 case JSON_UNDEFINED:
660 default:
661 return 0;
662 case JSON_DOUBLE:
663 return Value.Double;
664 }
665 }
666
667 TString TJsonValue::GetStringRobust() const {
668 switch (Type) {

Callers 2

Y_UNIT_TESTFunction · 0.45
Y_UNIT_TESTFunction · 0.45

Calls 2

TryFromStringFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected