File indexing completed on 2024-05-12 04:02:21
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 * Initialize with a default delimiters. 0031 */ 0032 explicit WordDelimiters(QStringView str); 0033 0034 /** 0035 * Returns @c true if @p c is a word delimiter; otherwise returns @c false. 0036 */ 0037 bool contains(QChar c) const; 0038 0039 /** 0040 * Appends each character of @p s to word delimiters. 0041 */ 0042 void append(QStringView s); 0043 0044 /** 0045 * Removes each character of @p s from word delimiters. 0046 */ 0047 void remove(QStringView c); 0048 0049 private: 0050 /** 0051 * An array which represents ascii characters for very fast lookup. 0052 * The character is used as an index and the value @c true indicates a word delimiter. 0053 */ 0054 std::bitset<128> asciiDelimiters; 0055 0056 /** 0057 * Contains characters that are not ascii and is empty for most syntax definition. 0058 */ 0059 QString notAsciiDelimiters; 0060 }; 0061 } 0062 0063 #endif