diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-06-23 14:14:16 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-06-23 14:14:16 +0200 |
commit | c36042925c8d52e3899ea310018cb7243d191306 (patch) | |
tree | 1878230d84e479078862099e06feec807c670041 /libbutl/fdstream.hxx | |
parent | 5d50c0499b30650deafc291a3872a386d08a3200 (diff) |
Add support for querying position in fdbuf
Diffstat (limited to 'libbutl/fdstream.hxx')
-rw-r--r-- | libbutl/fdstream.hxx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libbutl/fdstream.hxx b/libbutl/fdstream.hxx index 771d242..27530e2 100644 --- a/libbutl/fdstream.hxx +++ b/libbutl/fdstream.hxx @@ -10,7 +10,7 @@ #include <istream> #include <ostream> #include <utility> // move() -#include <cstdint> // uint16_t +#include <cstdint> // uint16_t, uint64_t #include <libbutl/export.hxx> @@ -143,6 +143,11 @@ namespace butl using base::egptr; using base::gbump; + // Return the (logical) position of the next byte to be read. + // + uint64_t + tellg () const {return off_ - (egptr () - gptr ());} + private: bool load (); @@ -159,12 +164,18 @@ namespace butl virtual std::streamsize xsputn (const char_type*, std::streamsize); + // Return the (logical) position of the next byte to be written. + // + uint64_t + tellp () const {return off_ + (pptr () - buf_);} + private: bool save (); private: auto_fd fd_; + uint64_t off_; char buf_[8192]; bool non_blocking_ = false; }; |