aboutsummaryrefslogtreecommitdiff
path: root/libbutl/char-scanner.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-11-09 18:17:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-11-09 18:17:16 +0200
commit5ffc678109310f90f9eaa2b86a98900703ac60ae (patch)
tree80ce525b23edbb91602cf223c37de02e144b958e /libbutl/char-scanner.ixx
parent182f28f9afb993600c3cefe3d289d1600222c14e (diff)
Add ability to save data in char_scanner
Diffstat (limited to 'libbutl/char-scanner.ixx')
-rw-r--r--libbutl/char-scanner.ixx23
1 files changed, 21 insertions, 2 deletions
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<char_type> (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;
}
}