1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QUNICODETOOLS_P_H
5#define QUNICODETOOLS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19#include <QtCore/qchar.h>
20#include <QtCore/qvarlengtharray.h>
21
22QT_BEGIN_NAMESPACE
23
24struct QCharAttributes
25{
26 uchar graphemeBoundary : 1;
27 uchar wordBreak : 1;
28 uchar sentenceBoundary : 1;
29 uchar lineBreak : 1;
30 uchar whiteSpace : 1;
31 uchar wordStart : 1;
32 uchar wordEnd : 1;
33 uchar mandatoryBreak : 1;
34};
35Q_DECLARE_TYPEINFO(QCharAttributes, Q_PRIMITIVE_TYPE);
36
37namespace QUnicodeTools {
38
39struct ScriptItem
40{
41 qsizetype position;
42 QChar::Script script;
43};
44
45using ScriptItemArray = QVarLengthArray<ScriptItem, 64>;
46
47} // namespace QUnicodeTools
48Q_DECLARE_TYPEINFO(QUnicodeTools::ScriptItem, Q_PRIMITIVE_TYPE);
49namespace QUnicodeTools {
50
51enum CharAttributeOption {
52 GraphemeBreaks = 0x01,
53 WordBreaks = 0x02,
54 SentenceBreaks = 0x04,
55 LineBreaks = 0x08,
56 WhiteSpaces = 0x10,
57 HangulLineBreakTailoring = 0x20,
58
59 DontClearAttributes = 0x1000
60};
61Q_DECLARE_FLAGS(CharAttributeOptions, CharAttributeOption)
62
63// attributes buffer has to have a length of string length + 1
64Q_CORE_EXPORT void initCharAttributes(QStringView str,
65 const ScriptItem *items, qsizetype numItems,
66 QCharAttributes *attributes, CharAttributeOptions options);
67
68
69Q_CORE_EXPORT void initScripts(QStringView str, ScriptItemArray *scripts);
70
71} // namespace QUnicodeTools
72
73QT_END_NAMESPACE
74
75#endif // QUNICODETOOLS_P_H
76

source code of qtbase/src/corelib/text/qunicodetools_p.h