diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2018-02-22 13:13:51 +0100 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2018-02-25 20:56:27 +0100 |
commit | f37090ccf4f699800a43878273b8b94b5906f4bc (patch) | |
tree | 2ae483b9c89320bacd7e6ad1939448d9741ba0d9 /core | |
parent | 125fc8cc4432d28e63da76c3a2aff655b1a7cc6b (diff) |
Mono: Better versioning and gracefully unloading of Godot API assemblies
Diffstat (limited to 'core')
-rw-r--r-- | core/ustring.cpp | 30 | ||||
-rw-r--r-- | core/ustring.h | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index d445e4ed47..a7a7810837 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1135,6 +1135,36 @@ String String::num_int64(int64_t p_num, int base, bool capitalize_hex) { return s; } +String String::num_uint64(uint64_t p_num, int base, bool capitalize_hex) { + + uint64_t n = p_num; + + int chars = 0; + do { + n /= base; + chars++; + } while (n); + + String s; + s.resize(chars + 1); + CharType *c = s.ptrw(); + c[chars] = 0; + n = p_num; + do { + int mod = ABS(n % base); + if (mod >= 10) { + char a = (capitalize_hex ? 'A' : 'a'); + c[--chars] = a + (mod - 10); + } else { + c[--chars] = '0' + mod; + } + + n /= base; + } while (n); + + return s; +} + String String::num_real(double p_num) { String s; diff --git a/core/ustring.h b/core/ustring.h index 90496b71b6..bb676ce623 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -146,6 +146,7 @@ public: static String num_scientific(double p_num); static String num_real(double p_num); static String num_int64(int64_t p_num, int base = 10, bool capitalize_hex = false); + static String num_uint64(uint64_t p_num, int base = 10, bool capitalize_hex = false); static String chr(CharType p_char); static String md5(const uint8_t *p_md5); static String hex_encode_buffer(const uint8_t *p_buffer, int p_len); |