From 5ffc678109310f90f9eaa2b86a98900703ac60ae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Nov 2017 18:17:16 +0200 Subject: Add ability to save data in char_scanner --- libbutl/char-scanner.ixx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'libbutl/char-scanner.ixx') diff --git a/libbutl/char-scanner.ixx b/libbutl/char-scanner.ixx index 0e00dfd..c32b034 100644 --- a/libbutl/char-scanner.ixx +++ b/libbutl/char-scanner.ixx @@ -52,12 +52,31 @@ namespace butl inline void char_scanner:: get_ () { + int_type c; + if (gptr_ != egptr_) { buf_->gbump (1); - ++gptr_; + c = *gptr_++; } else - is_.get (); // About as fast as ignore() and way faster than tellg(). + c = is_.get (); // About as fast as ignore() and way faster than tellg(). + + if (save_ != nullptr && c != xchar::traits_type::eof ()) + save_->push_back (static_cast (c)); + } + + inline void char_scanner:: + save_start (std::string& b) + { + assert (save_ == nullptr); + save_ = &b; + } + + inline void char_scanner:: + save_stop () + { + assert (save_ != nullptr); + save_ = nullptr; } } -- cgit v1.1