aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/walk.cpp
blob: 02439393980cd778a8cfda25a0cde6744751f19d (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;
}