MCPcopy Create free account
hub / github.com/axmolengine/axmol / asDouble

Method asDouble

core/base/Value.cpp:656–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654}
655
656double Value::asDouble(double defaultValue) const
657{
658 AXASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP,
659 "Only base type (bool, string, float, double, int) could be converted");
660 switch (_type)
661 {
662 case Type::DOUBLE:
663 return _field.doubleVal;
664
665 case Type::STRING:
666 return static_cast<double>(utils::atof(_field.strVal->c_str()));
667
668 case Type::INT_I32:
669 return static_cast<double>(_field.intVal);
670 case Type::INT_UI32:
671 return static_cast<double>(_field.uintVal);
672 case Type::INT_I64:
673 return static_cast<double>(_field.int64Val);
674 case Type::INT_UI64:
675 return static_cast<double>(_field.uint64Val);
676
677 case Type::FLOAT:
678 return static_cast<double>(_field.floatVal);
679
680 case Type::BOOLEAN:
681 return _field.boolVal ? 1.0 : 0.0;
682
683 default:
684 return defaultValue;
685 }
686}
687
688bool Value::asBool(bool defaultValue) const
689{

Callers 7

startElementMethod · 0.80
FileUtilsTests.cppFile · 0.80
onEnterMethod · 0.80
ccvalue_to_luavalFunction · 0.80
ccvaluemap_to_luavalFunction · 0.80
ccvaluevector_to_luavalFunction · 0.80

Calls 2

atofFunction · 0.85
c_strMethod · 0.45

Tested by 1

onEnterMethod · 0.64