Added append_repeat to the string.

This commit is contained in:
Relintai 2021-11-18 13:49:41 +01:00
parent 2dac93662c
commit 1237d3da2a
2 changed files with 14 additions and 0 deletions

View File

@ -542,6 +542,17 @@ void String::append_str(const std::string &str) {
_data[_size] = '\0';
}
void String::append_repeat(const char *str, const int times) {
for (int i = 0; i < times; ++i) {
append_str(str);
}
}
void String::append_repeat(const String &other, const int times) {
for (int i = 0; i < times; ++i) {
append_str(other);
}
}
float String::to_float() const {
return atof(c_str());
}

View File

@ -62,6 +62,9 @@ public:
void append_str(const String &other);
void append_str(const std::string &str);
void append_repeat(const char* str, const int times);
void append_repeat(const String &other, const int times);
float to_float() const;
double to_double() const;
int to_int() const;