summaryrefslogtreecommitdiff
path: root/AK/StringBuilder.h
blob: a01f5504c4e8901cc5d39d8ef91210d6af0a5eff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#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;