GUI: U32: Allow vformat to take in a pointer to a translated string

- Fix signed/unsigned comparision in U32String::contains(U32String)
This commit is contained in:
aryanrawlani28 2020-08-20 00:03:54 +05:30 committed by Eugene Sandulenko
parent 6fa5d7ee2f
commit 140eddf90a
2 changed files with 20 additions and 1 deletions

View file

@ -234,7 +234,7 @@ bool U32String::contains(const U32String &otherString) const {
return false;
}
int size = 0;
uint32 size = 0;
U32String::const_iterator itr = otherString.begin();
for (U32String::const_iterator itr2 = begin(); itr != otherString.end() && itr2 != end(); itr2++) {
@ -268,6 +268,12 @@ void U32String::insertString(String s, uint32 p) {
}
}
void U32String::insertString(uint *s, uint32 p) {
while (*s != '\0') {
U32String::insertChar(*s++, p++);
}
}
void U32String::deleteChar(uint32 p) {
assert(p < _size);
@ -605,9 +611,11 @@ int U32String::vformat(U32String::const_iterator fmt, const U32String::const_ite
char *string_temp;
value_type ch;
value_type *u32string_temp;
int length = 0;
int len = 0;
int pos = 0;
int tempPos = 0;
char buffer[512];
@ -615,6 +623,16 @@ int U32String::vformat(U32String::const_iterator fmt, const U32String::const_ite
ch = *fmt++;
if (ch == '%') {
switch (ch = *fmt++) {
case 'S':
u32string_temp = va_arg(args, uint *);
tempPos = output.size();
output.insertString(u32string_temp, pos);
len = output.size() - tempPos;
length += len;
pos += len - 1;
break;
case 's':
string_temp = va_arg(args, char *);
len = strlen(string_temp);

View file

@ -173,6 +173,7 @@ public:
/** Insert character c before position p. */
void insertChar(value_type c, uint32 p);
void insertString(String s, uint32 p);
void insertString(uint *s, uint32 p);
/**
* Removes the value at position p from the string.