aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/util/slime_output_raw_buf_adapter.h
blob: 49fc3e5054970baa5fb04feab62938d04c91fd38 (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "rawbuf.h"
#include <vespa/vespalib/data/output.h>

namespace search {

class SlimeOutputRawBufAdapter : public vespalib::Output
{
private:
    RawBuf &_buf;

public:
    SlimeOutputRawBufAdapter(RawBuf &buf) : _buf(buf) {}
    vespalib::WritableMemory reserve(size_t reserve) override {
        return vespalib::WritableMemory(_buf.GetWritableFillPos(reserve), reserve);
    }
    Output &commit(size_t commit) override {
        _buf.Fill(commit);
        return *this;
    }
};

} // namespace search