MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / pad_zeros

Method pad_zeros

core/string/ustring.cpp:4939–4964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4937}
4938
4939String String::pad_zeros(int p_digits) const {
4940 String s = *this;
4941 int end = s.find_char('.');
4942
4943 if (end == -1) {
4944 end = s.length();
4945 }
4946
4947 if (end == 0) {
4948 return s;
4949 }
4950
4951 int begin = 0;
4952
4953 while (begin < end && !is_digit(s[begin])) {
4954 begin++;
4955 }
4956
4957 int zeros_to_add = p_digits - (end - begin);
4958
4959 if (zeros_to_add <= 0) {
4960 return s;
4961 } else {
4962 return s.insert(begin, String("0").repeat(zeros_to_add));
4963 }
4964}
4965
4966String String::trim_prefix(const String &p_prefix) const {
4967 String s = *this;

Callers 5

_serialize_imagesMethod · 0.80
_fix_config_fileMethod · 0.80
test_string.hFile · 0.80
add_frameMethod · 0.80
endMethod · 0.80

Calls 6

is_digitFunction · 0.85
find_charMethod · 0.80
repeatMethod · 0.80
StringClass · 0.70
lengthMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected