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

Method asInt

Source/JSON/jsoncpp.cpp:2794–2814  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2792#endif
2793
2794Value::Int Value::asInt() const {
2795 switch (type_) {
2796 case intValue:
2797 JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range");
2798 return Int(value_.int_);
2799 case uintValue:
2800 JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range");
2801 return Int(value_.uint_);
2802 case realValue:
2803 JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt),
2804 "double out of Int range");
2805 return Int(value_.real_);
2806 case nullValue:
2807 return 0;
2808 case booleanValue:
2809 return value_.bool_ ? 1 : 0;
2810 default:
2811 break;
2812 }
2813 JSON_FAIL_MESSAGE("Value is not convertible to Int.");
2814}
2815
2816Value::UInt Value::asUInt() const {
2817 switch (type_) {

Callers 1

newCharReaderMethod · 0.45

Calls 1

InRangeFunction · 0.70

Tested by

no test coverage detected