MCPcopy Create free account
hub / github.com/CytopiaTeam/Cytopia / parseUInt

Function parseUInt

external/as_add_on/scriptstdstring/scriptstdstring.cpp:626–666  ·  view source on GitHub ↗

AngelScript signature: uint64 parseUInt(const string &in val, uint base = 10, uint &out byteCount = 0)

Source from the content-addressed store, hash-verified

624// AngelScript signature:
625// uint64 parseUInt(const string &in val, uint base = 10, uint &out byteCount = 0)
626static asQWORD parseUInt(const string &val, asUINT base, asUINT *byteCount)
627{
628 // Only accept base 10 and 16
629 if (base != 10 && base != 16)
630 {
631 if (byteCount) *byteCount = 0;
632 return 0;
633 }
634
635 const char *end = &val[0];
636
637 asQWORD res = 0;
638 if (base == 10)
639 {
640 while (*end >= '0' && *end <= '9')
641 {
642 res *= 10;
643 res += *end++ - '0';
644 }
645 }
646 else if (base == 16)
647 {
648 while ((*end >= '0' && *end <= '9') ||
649 (*end >= 'a' && *end <= 'f') ||
650 (*end >= 'A' && *end <= 'F'))
651 {
652 res *= 16;
653 if (*end >= '0' && *end <= '9')
654 res += *end++ - '0';
655 else if (*end >= 'a' && *end <= 'f')
656 res += *end++ - 'a' + 10;
657 else if (*end >= 'A' && *end <= 'F')
658 res += *end++ - 'A' + 10;
659 }
660 }
661
662 if (byteCount)
663 *byteCount = asUINT(size_t(end - val.c_str()));
664
665 return res;
666}
667
668// AngelScript signature:
669// double parseFloat(const string &in val, uint &out byteCount = 0)

Callers 1

parseUInt_GenericFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected