Files
ladybird/AK/StringBuilder.h
Andreas Kling 027d26cd5d Add a String::format() and use that in place of ksprintf() in the Kernel.
You're never gonna be right 100% of the time when guessing how much buffer
space you need. This avoids having to make that type of decision in a bunch
of cases. :^)
2019-01-30 16:28:51 +01:00

34 lines
562 B
C++

#pragma once
#include "AKString.h"
#include "Vector.h"
#include <LibC/stdarg.h>
namespace AK {
class StringBuilder {
public:
explicit StringBuilder(size_t initial_capacity = 16);
~StringBuilder() { }
void append(const String&);
void append(char);
void append(const char*, size_t);
void appendf(const char*, ...);
void appendvf(const char*, va_list);
String build();
ByteBuffer to_byte_buffer();
private:
void will_append(size_t);
ByteBuffer m_buffer;
size_t m_length { 0 };
};
}
using AK::StringBuilder;