mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
7bce096afd
We should work towards a pattern where we take StringView as function arguments, and store String as member, to push the String construction to the last possible moment.
32 lines
572 B
C++
32 lines
572 B
C++
#pragma once
|
|
|
|
#include "AKString.h"
|
|
#include "Vector.h"
|
|
#include <LibC/stdarg.h>
|
|
|
|
namespace AK {
|
|
|
|
class StringBuilder {
|
|
public:
|
|
explicit StringBuilder(ssize_t initial_capacity = 16);
|
|
~StringBuilder() {}
|
|
|
|
void append(const StringView&);
|
|
void append(char);
|
|
void append(const char*, ssize_t);
|
|
void appendf(const char*, ...);
|
|
void appendvf(const char*, va_list);
|
|
|
|
String to_string();
|
|
ByteBuffer to_byte_buffer();
|
|
|
|
private:
|
|
void will_append(ssize_t);
|
|
|
|
ByteBuffer m_buffer;
|
|
ssize_t m_length { 0 };
|
|
};
|
|
|
|
}
|
|
|
|
using AK::StringBuilder;
|