diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-24 13:26:13 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-24 13:28:51 +0200 |
commit | b6e02f4224975a6425f62095bc35478e8866db77 (patch) | |
tree | 51627eef813ebb670efca83aed7dd284cb738806 /libbutl/char-scanner.ixx | |
parent | eb3c27b8f47c793244436cd082512bb8235bea89 (diff) |
Various improvements to char_scanner
Diffstat (limited to 'libbutl/char-scanner.ixx')
-rw-r--r-- | libbutl/char-scanner.ixx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libbutl/char-scanner.ixx b/libbutl/char-scanner.ixx new file mode 100644 index 0000000..2d96207 --- /dev/null +++ b/libbutl/char-scanner.ixx @@ -0,0 +1,32 @@ +// file : libbutl/char-scanner.ixx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +namespace butl +{ + inline auto char_scanner:: + get () -> xchar + { + if (unget_) + { + unget_ = false; + return ungetc_; + } + else + { + xchar c (peek ()); + get (c); + return c; + } + } + + inline void char_scanner:: + unget (const xchar& c) + { + // Because iostream::unget cannot work once eos is reached, we have to + // provide our own implementation. + // + unget_ = true; + ungetc_ = c; + } +} |