MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / asInt

Method asInt

Libraries/jsoncpp-0.y.z/src/lib_json/json_value.cpp:636–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

634#endif
635
636Value::Int Value::asInt() const {
637 switch (type_) {
638 case intValue:
639 JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range");
640 return Int(value_.int_);
641 case uintValue:
642 JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range");
643 return Int(value_.uint_);
644 case realValue:
645 JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt),
646 "double out of Int range");
647 return Int(value_.real_);
648 case nullValue:
649 return 0;
650 case booleanValue:
651 return value_.bool_ ? 1 : 0;
652 default:
653 break;
654 }
655 JSON_FAIL_MESSAGE("Value is not convertible to Int.");
656}
657
658Value::UInt Value::asUInt() const {
659 switch (type_) {

Callers 2

newCharReaderMethod · 0.45
JSONTEST_FIXTUREFunction · 0.45

Calls 1

InRangeFunction · 0.70

Tested by

no test coverage detected