Add support for boolean printing

This commit is contained in:
Baptiste Wicht 2016-09-26 13:09:24 +02:00
parent 1a801ce93f
commit b511091728
No known key found for this signature in database
GPG Key ID: C5566B6C7F884532

View File

@ -165,6 +165,16 @@ std::string vsprintf(const std::string& format, va_list va){
s += "B";
}
}
// Boolean
else if(ch == 'b'){
bool value= va_arg(va, int);
if(value){
s += "true";
} else {
s += "false";
}
}
//String
else if(ch == 's'){
const char* arg = va_arg(va, const char*);
@ -376,6 +386,16 @@ void vsprintf_raw(char* out_buffer, size_t /*n*/, const char* format, va_list va
out_i += str_cat(out_buffer + out_i, "B");
}
}
// Boolean
else if(ch == 'b'){
bool value= va_arg(va, int);
if(value){
out_i += str_cat(out_buffer + out_i, "true");
} else {
out_i += str_cat(out_buffer + out_i, "false");
}
}
//String
else if(ch == 's'){
const char* arg = va_arg(va, const char*);