summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-10-21 17:22:29 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2018-01-10 09:56:24 +0100
commit9c78dc6483c5998dcda7a34315dbf1c4504ac04f (patch)
treef33c7d6f83a3d269c63d2b06afe5fd5a33fec5e5 /vespalib
parent4c8c90f9ef909041e0066ac9b4ada817c495c5ba (diff)
Also use encode for write path
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/objects/nbostream.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.h b/vespalib/src/vespa/vespalib/objects/nbostream.h
index 70a590f79d1..8eb42ddfd53 100644
--- a/vespalib/src/vespa/vespalib/objects/nbostream.h
+++ b/vespalib/src/vespa/vespalib/objects/nbostream.h
@@ -20,7 +20,7 @@ class nbostream
public:
using Buffer = Array<char>;
using Alloc = alloc::Alloc;
- enum State { ok=0, eof=0x01};
+ enum State { ok=0, eof=0x01, oob=0x02};
nbostream(size_t initialSize=1024);
protected:
nbostream(const void * buf, size_t sz, bool longLivedBuffer);
@@ -145,6 +145,7 @@ public:
const char * peek() const { return &_rbuf[_rp]; }
size_t rp() const { return _rp; }
nbostream & rp(size_t pos) { if (pos > _wp) fail(eof); _rp = pos; return *this; }
+ nbostream & wp(size_t pos) { if (pos > _wbuf.size()) fail(oob); _wp = pos; return *this; }
size_t wp() const { return _wp; }
State state() const { return _state; }
bool good() const { return _state == ok; }