| 4937 | } |
| 4938 | |
| 4939 | String 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 | |
| 4966 | String String::trim_prefix(const String &p_prefix) const { |
| 4967 | String s = *this; |
no test coverage detected