MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / pad_zeros

Method pad_zeros

modules/gui/gui/src/backend/text_server/ustring.cpp:5016–5050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5014}
5015
5016String String::pad_zeros(int p_digits) const
5017{
5018 String s = *this;
5019 int end = s.find(".");
5020
5021 if (end == -1)
5022 {
5023 end = s.length();
5024 }
5025
5026 if (end == 0)
5027 {
5028 return s;
5029 }
5030
5031 int begin = 0;
5032
5033 while (begin < end && !is_digit(s[begin]))
5034 {
5035 begin++;
5036 }
5037
5038 if (begin >= end)
5039 {
5040 return s;
5041 }
5042
5043 while (end - begin < p_digits)
5044 {
5045 s = s.insert(begin, "0");
5046 end++;
5047 }
5048
5049 return s;
5050}
5051
5052String String::trim_prefix(const String& p_prefix) const
5053{

Callers

nothing calls this directly

Calls 4

is_digitFunction · 0.85
findMethod · 0.45
lengthMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected