ladybird/AK/StringBuilder.h
Andreas Kling f6998b1817 JSON: Templatize the JSON serialization code
This makes it possible to use something other than a StringBuilder for
serialization (and to produce something other than a String.) :^)
2019-08-07 21:29:32 +02:00

37 lines
627 B
C++

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