From 5ae9686adac1508873f2d980e84becd3496244c2 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 26 Feb 2020 17:16:45 +0300 Subject: Add notion of validator to char_scanner and make sure manifest is UTF-8 This involves implementing utf8_validator and UTF-8 utility functions and using them during the manifest parsing, serialization, and rewriting. --- libbutl/manifest-parser.ixx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libbutl/manifest-parser.ixx') diff --git a/libbutl/manifest-parser.ixx b/libbutl/manifest-parser.ixx index e616ad9..bc5246c 100644 --- a/libbutl/manifest-parser.ixx +++ b/libbutl/manifest-parser.ixx @@ -3,6 +3,37 @@ namespace butl { + + inline auto manifest_parser:: + get (const char* what) -> xchar + { + xchar c (base::get (ebuf_)); + + if (invalid (c)) + throw manifest_parsing (name_, + c.line, c.column, + std::string ("invalid ") + what + ": " + ebuf_); + return c; + } + + inline void manifest_parser:: + get (const xchar& peeked) + { + base::get (peeked); + } + + inline auto manifest_parser:: + peek (const char* what) -> xchar + { + xchar c (base::peek (ebuf_)); + + if (invalid (c)) + throw manifest_parsing (name_, + c.line, c.column, + std::string ("invalid ") + what + ": " + ebuf_); + return c; + } + inline manifest_name_value manifest_parser:: next () { -- cgit v1.1