mirror of
https://github.com/Z3Prover/z3
synced 2025-06-07 06:33:23 +00:00
simplify string_buffer::append
This commit is contained in:
parent
fdeba2102c
commit
38d4418f94
1 changed files with 8 additions and 25 deletions
|
@ -16,8 +16,7 @@
|
||||||
Revision History:
|
Revision History:
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
#ifndef STRING_BUFFER_H_
|
#pragma once
|
||||||
#define STRING_BUFFER_H_
|
|
||||||
|
|
||||||
#include<cstdio>
|
#include<cstdio>
|
||||||
#include<string>
|
#include<string>
|
||||||
|
@ -44,8 +43,6 @@ class string_buffer {
|
||||||
m_buffer = new_buffer;
|
m_buffer = new_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unsigned c_buffer_size = 24;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string_buffer():
|
string_buffer():
|
||||||
m_buffer(m_initial_buffer),
|
m_buffer(m_initial_buffer),
|
||||||
|
@ -82,34 +79,22 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void append(int n) {
|
void append(int n) {
|
||||||
char buffer[c_buffer_size];
|
auto str = std::to_string(n);
|
||||||
SPRINTF_D(buffer, n);
|
append(str.c_str());
|
||||||
append(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void append(unsigned n) {
|
void append(unsigned n) {
|
||||||
char buffer[c_buffer_size];
|
auto str = std::to_string(n);
|
||||||
SPRINTF_U(buffer, n);
|
append(str.c_str());
|
||||||
append(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void append(long n) {
|
void append(long n) {
|
||||||
char buffer[c_buffer_size];
|
auto str = std::to_string(n);
|
||||||
#ifdef _WINDOWS
|
append(str.c_str());
|
||||||
sprintf_s(buffer, Z3_ARRAYSIZE(buffer), "%ld", n);
|
|
||||||
#else
|
|
||||||
sprintf(buffer, "%ld", n);
|
|
||||||
#endif
|
|
||||||
append(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void append(bool b) {
|
void append(bool b) {
|
||||||
if (b) {
|
append(b ? "true" : "false");
|
||||||
append("true");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
append("false");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned size() const {
|
unsigned size() const {
|
||||||
|
@ -171,5 +156,3 @@ inline string_buffer<SZ1> & operator<<(string_buffer<SZ1> & buffer1, const strin
|
||||||
buffer1.append(buffer2.c_str());
|
buffer1.append(buffer2.c_str());
|
||||||
return buffer1;
|
return buffer1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue