File indexing completed on 2024-05-12 15:50:07
0001 /* 0002 SPDX-FileCopyrightText: 2020 Jonathan Poelen <jonathan.poelen@gmail.com> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KSYNTAXHIGHLIGHTING_WORDDELIMITERS_P_H 0008 #define KSYNTAXHIGHLIGHTING_WORDDELIMITERS_P_H 0009 0010 #include <QString> 0011 0012 #include <bitset> 0013 0014 namespace KSyntaxHighlighting 0015 { 0016 /** 0017 * Represents a list of character that separates 2 words. 0018 * 0019 * Default delimiters are .():!+*,-<=>%&/;?[]^{|}~\, space (' ') and tabulator ('\t'). 0020 * 0021 * @see Rule 0022 * @since 5.74 0023 */ 0024 class WordDelimiters 0025 { 0026 public: 0027 WordDelimiters(); 0028 0029 /** 0030 * Returns @c true if @p c is a word delimiter; otherwise returns @c false. 0031 */ 0032 bool contains(QChar c) const; 0033 0034 /** 0035 * Appends each character of @p s to word delimiters. 0036 */ 0037 void append(QStringView s); 0038 0039 /** 0040 * Removes each character of @p s from word delimiters. 0041 */ 0042 void remove(QStringView c); 0043 0044 private: 0045 /** 0046 * An array which represents ascii characters for very fast lookup. 0047 * The character is used as an index and the value @c true indicates a word delimiter. 0048 */ 0049 std::bitset<128> asciiDelimiters; 0050 0051 /** 0052 * Contains characters that are not ascii and is empty for most syntax definition. 0053 */ 0054 QString notAsciiDelimiters; 0055 }; 0056 } 0057 0058 #endif