aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/walk.cpp
blob: 280f7e9f108f91170efc907193e30f64973cbc2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "walk.h"

#include <util/generic/string.h> 

void IWalkInput::DoUndo(size_t len) {
    Len_ += len;
    Buf_ = static_cast<const char*>(Buf_) - len;
}

size_t IWalkInput::DoNext(const void** ptr, size_t len) {
    if (!Len_) {
        Len_ = DoUnboundedNext(&Buf_);
    }

    len = Min(Len_, len);
    *ptr = Buf_;

    Buf_ = static_cast<const char*>(Buf_) + len;
    Len_ -= len;

    return len;
}