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

Method asString

core/base/Value.cpp:720–763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

718}
719
720std::string Value::asString() const
721{
722 AXASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP,
723 "Only base type (bool, string, float, double, int) could be converted");
724
725 if (_type == Type::STRING)
726 {
727 return *_field.strVal;
728 }
729
730 constexpr auto NUMBER_MAX_DIGITS = 63;
731
732 std::string ret;
733 size_t n = 0;
734 switch (_type)
735 {
736 case Type::INT_I32:
737 ret = std::to_string(_field.intVal);
738 break;
739 case Type::INT_UI32:
740 ret = std::to_string(_field.uintVal);
741 break;
742 case Type::INT_I64:
743 ret = std::to_string(_field.int64Val);
744 break;
745 case Type::INT_UI64:
746 ret = std::to_string(_field.uint64Val);
747 break;
748 case Type::FLOAT:
749 ret.reserve(NUMBER_MAX_DIGITS);
750 fmt::format_to(ret, "{:.7g}", _field.floatVal);
751 break;
752 case Type::DOUBLE:
753 fmt::format_to(ret, "{:.17g}", _field.doubleVal);
754 break;
755 case Type::BOOLEAN:
756 ret = (_field.boolVal ? "true" : "false");
757 break;
758 default:
759 break;
760 }
761
762 return ret;
763}
764
765std::string_view Value::asStringRef() const
766{

Callers 15

initWithDictionaryMethod · 0.80
initWithStringMethod · 0.80
parseVersion1Method · 0.80
parseVersion2Method · 0.80
getObjectMethod · 0.80
loadMethod · 0.80
reloadMethod · 0.80
createMethod · 0.80

Calls 3

to_stringFunction · 0.50
format_toFunction · 0.50
reserveMethod · 0.45

Tested by 15

initMethod · 0.64
changeEndAngleMethod · 0.64
changeStartAngleMethod · 0.64
changeRotationMethod · 0.64
changeThicknessMethod · 0.64
initSlidersMethod · 0.64
initSpritesMethod · 0.64
changeEpsilonMethod · 0.64
updateLabelMethod · 0.64
makeSpriteMethod · 0.64
updateMethod · 0.64
onEnterMethod · 0.64