summaryrefslogtreecommitdiff
path: root/Kernel/KBufferBuilder.h
blob: a16c449a865a727ccca73ee0e3be1b171b67081d (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
#pragma once

#include <AK/String.h>
#include <Kernel/KBuffer.h>
#include <stdarg.h>

class KBufferBuilder {
public:
    using OutputType = KBuffer;

    explicit KBufferBuilder();
    ~KBufferBuilder() {}

    void append(const StringView&);
    void append(char);
    void append(const char*, int);
    void appendf(const char*, ...);
    void appendvf(const char*, va_list);

    KBuffer build();

private:
    bool can_append(size_t) const;
    u8* insertion_ptr() { return m_buffer.data() + m_size; }

    KBuffer m_buffer;
    size_t m_size { 0 };
};