diff options
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; + } +} |