AngelScript signature: uint64 parseUInt(const string &in val, uint base = 10, uint &out byteCount = 0)
| 624 | // AngelScript signature: |
| 625 | // uint64 parseUInt(const string &in val, uint base = 10, uint &out byteCount = 0) |
| 626 | static 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) |