3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-10 19:27:06 +00:00

simplify string_buffer::append

This commit is contained in:
Nuno Lopes 2020-06-18 19:55:34 +01:00
parent fdeba2102c
commit 38d4418f94

View file

@ -16,8 +16,7 @@
Revision History:
--*/
#ifndef STRING_BUFFER_H_
#define STRING_BUFFER_H_
#pragma once
#include<cstdio>
#include<string>
@ -44,8 +43,6 @@ class string_buffer {
m_buffer = new_buffer;
}
static const unsigned c_buffer_size = 24;
public:
string_buffer():
m_buffer(m_initial_buffer),
@ -82,34 +79,22 @@ public:
}
void append(int n) {
char buffer[c_buffer_size];
SPRINTF_D(buffer, n);
append(buffer);
auto str = std::to_string(n);
append(str.c_str());
}
void append(unsigned n) {
char buffer[c_buffer_size];
SPRINTF_U(buffer, n);
append(buffer);
auto str = std::to_string(n);
append(str.c_str());
}
void append(long n) {
char buffer[c_buffer_size];
#ifdef _WINDOWS
sprintf_s(buffer, Z3_ARRAYSIZE(buffer), "%ld", n);
#else
sprintf(buffer, "%ld", n);
#endif
append(buffer);
auto str = std::to_string(n);
append(str.c_str());
}
void append(bool b) {
if (b) {
append("true");
}
else {
append("false");
}
append(b ? "true" : "false");
}
unsigned size() const {
@ -171,5 +156,3 @@ inline string_buffer<SZ1> & operator<<(string_buffer<SZ1> & buffer1, const strin
buffer1.append(buffer2.c_str());
return buffer1;
}
#endif