1 /* 2 * read_unicode.h -- declaration of the UnicodeReader class. 3 * 4 * Copyright (c) 2018-2019 YANDEX LLC, Andrey Logvin <andry@logvin.net> 5 * Karina Usmanova <usmanova.karin@yandex.ru> 6 * 7 * This file is part of Pire, the Perl Incompatible 8 * Regular Expressions library. 9 * 10 * Pire is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser Public License as published by 12 * the Free Software Foundation, either version 3 of the License, or 13 * (at your option) any later version. 14 * 15 * Pire is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser Public License for more details. 19 * You should have received a copy of the GNU Lesser Public License 20 * along with Pire. If not, see <http://www.gnu.org/licenses>. 21 */ 22 23 24 #ifndef PIRE_READ_UNICODE_H 25 #define PIRE_READ_UNICODE_H 26 27 28 #include <re_lexer.h> 29 30 namespace Pire { 31 class UnicodeReader : public Feature { 32 public: 33 wchar32 ReadUnicodeCharacter(); 34 35 private: 36 static const wchar32 MaxUnicode = 0x10FFFF; 37 38 bool IsHexDigit(wchar32 ch); 39 ystring ReadHexDigit(std::function<bool(wchar32, size_t)> shouldStop); 40 wchar32 HexToDec(const ystring& hexStr); 41 }; 42 } 43 44 #endif 45