Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef UTILS_H
5#define UTILS_H
6
7#include <QtCore/qglobal.h>
8#include <private/qtools_p.h>
9
10#include <algorithm>
11
13
14inline bool is_whitespace(char s)
15{
16 return (s == ' ' || s == '\t' || s == '\n');
17}
18
19inline bool is_space(char s)
20{
21 return (s == ' ' || s == '\t');
22}
23
24inline bool is_ident_start(char s)
25{
26 using namespace QtMiscUtils;
27 return isAsciiLower(s) || isAsciiUpper(s) || s == '_' || s == '$';
28}
29
30inline bool is_ident_char(char s)
31{
32 return QtMiscUtils::isAsciiLetterOrNumber(s) || s == '_' || s == '$';
33}
34
35inline bool is_identifier(const char *s, qsizetype len)
36{
37 if (len < 1)
38 return false;
39 return std::all_of(s, s + len, is_ident_char);
40}
41
42inline const char *skipQuote(const char *data)
43{
44 while (*data && (*data != '\"')) {
45 if (*data == '\\') {
46 ++data;
47 if (!*data) break;
48 }
49 ++data;
50 }
51
52 if (*data) //Skip last quote
53 ++data;
54 return data;
55}
56
57QT_END_NAMESPACE
58
59#endif // UTILS_H
static CborError callback(void *self, const void *ptr, size_t len, CborEncoderAppendType t)
Definition cbordevice.h:29
void nextItem(const char *comment=nullptr)
Definition cbordevice.h:22
CborDevice(FILE *out)
Definition cbordevice.h:20
qsizetype registeredStringsCount()
Definition generator.h:24
Generator(Moc *moc, ClassDef *classDef, const QList< QByteArray > &metaTypes, const QHash< QByteArray, QByteArray > &knownQObjectClasses, const QHash< QByteArray, QByteArray > &knownGadgets, FILE *outfile=nullptr, bool requireCompleteTypes=false)
Definition generator.cpp:61
void generateCode()
Definition moc.h:209
\inmodule QtCore\reentrant
Definition qjsonobject.h:20
Definition qlist.h:76
bool is_identifier(const char *s, qsizetype len)
Definition utils.h:35
bool is_ident_char(char s)
Definition utils.h:30
const char * skipQuote(const char *data)
Definition utils.h:42
bool is_space(char s)
Definition utils.h:19
QT_BEGIN_NAMESPACE bool is_whitespace(char s)
Definition utils.h:14
bool is_ident_start(char s)
Definition utils.h:24
Combined button and popup list for selecting options.
static QByteArray generateQualifiedClassNameIdentifier(const QByteArray &identifier)
static CborError jsonValueToCbor(CborEncoder *parent, const QJsonValue &v)
static bool qualifiedNameEquals(const QByteArray &qualifiedName, const QByteArray &name)
uint nameToBuiltinType(const QByteArray &name)
Definition generator.cpp:29
static CborError jsonArrayToCbor(CborEncoder *parent, const QJsonArray &a)
bool isBuiltinType(const QByteArray &type)
Definition generator.cpp:41
static const char * metaTypeEnumValueString(int type)
Definition generator.cpp:49
static void printStringWithIndentation(FILE *out, const QByteArray &s)
static qsizetype lengthOfEscapeSequence(const QByteArray &s, qsizetype i)
Definition generator.cpp:77
static CborError jsonObjectToCbor(CborEncoder *parent, const QJsonObject &o)
bool hasQObject
Definition moc.h:192
bool hasQGadget
Definition moc.h:193
bool requireCompleteMethodTypes
Definition moc.h:195
bool hasQNamespace
Definition moc.h:194
Definition moc.h:43
bool wasCloned
Definition moc.h:83
bool isRawSlot
Definition moc.h:96
bool isConst
Definition moc.h:79
bool isAbstract
Definition moc.h:95
bool isPrivateSignal
Definition moc.h:92
@ Private
Definition moc.h:75
bool isStatic
Definition moc.h:81
int notifyId
Definition moc.h:115
bool constant
Definition moc.h:119
Specification gspec
Definition moc.h:117
@ ReferenceSpec
Definition moc.h:116
@ PointerSpec
Definition moc.h:116