AngelScript signature: uint64 parseUInt(const string &in val, uint base = 10, uint &out byteCount = 0)
| 860 | // AngelScript signature: |
| 861 | // uint64 parseUInt(const string &in val, uint base = 10, uint &out byteCount = 0) |
| 862 | static asQWORD parseUInt(const string &val, asUINT base, asUINT *byteCount) |
| 863 | { |
| 864 | // Only accept base 10 and 16 |
| 865 | if (base != 10 && base != 16) |
| 866 | { |
| 867 | if (byteCount) *byteCount = 0; |
| 868 | return 0; |
| 869 | } |
| 870 | |
| 871 | const char *end = &val[0]; |
| 872 | |
| 873 | asQWORD res = 0; |
| 874 | if (base == 10) |
| 875 | { |
| 876 | while (*end >= '0' && *end <= '9') |
| 877 | { |
| 878 | res *= 10; |
| 879 | res += *end++ - '0'; |
| 880 | } |
| 881 | } |
| 882 | else if (base == 16) |
| 883 | { |
| 884 | while ((*end >= '0' && *end <= '9') || |
| 885 | (*end >= 'a' && *end <= 'f') || |
| 886 | (*end >= 'A' && *end <= 'F')) |
| 887 | { |
| 888 | res *= 16; |
| 889 | if (*end >= '0' && *end <= '9') |
| 890 | res += *end++ - '0'; |
| 891 | else if (*end >= 'a' && *end <= 'f') |
| 892 | res += *end++ - 'a' + 10; |
| 893 | else if (*end >= 'A' && *end <= 'F') |
| 894 | res += *end++ - 'A' + 10; |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | if (byteCount) |
| 899 | *byteCount = asUINT(size_t(end - val.c_str())); |
| 900 | |
| 901 | return res; |
| 902 | } |
| 903 | |
| 904 | // AngelScript signature: |
| 905 | // double parseFloat(const string &in val, uint &out byteCount = 0) |