19#ifdef PROPARSER_THREAD_SAFE
20typedef QAtomicInt ProItemRefCount;
25 bool ref() {
return ++m_cnt != 0; }
26 bool deref() {
return --m_cnt != 0; }
34# define PROITEM_EXPLICIT explicit
36# define PROITEM_EXPLICIT
48 template<
typename A,
typename B>
50 {
return *
this = QString(str); }
54 template<
typename A,
typename B>
58 ProString(
const QString &str,
int offset,
int length);
60 void clear() { m_string.clear(); m_length = 0; }
68 template<
typename A,
typename B>
76 template<
typename A,
typename B>
82 void chop(
int n) { Q_ASSERT(n <= m_length); m_length -= n; }
83 void chopFront(
int n) { Q_ASSERT(n <= m_length); m_offset += n; m_length -= n; }
85 bool operator==(
const ProString &other)
const {
return toQStringView() == other.toQStringView(); }
86 bool operator==(
const QString &other)
const {
return toQStringView() == other; }
87 bool operator==(QStringView other)
const {
return toQStringView() == other; }
88 bool operator==(QLatin1String other)
const {
return toQStringView() == other; }
89 bool operator==(
const char *other)
const {
return toQStringView() == QLatin1String(other); }
91 bool operator!=(
const QString &other)
const {
return !(*
this == other); }
92 bool operator!=(QLatin1String other)
const {
return !(*
this == other); }
93 bool operator!=(
const char *other)
const {
return !(*
this == other); }
94 bool operator<(
const ProString &other)
const {
return toQStringView() < other.toQStringView(); }
95 bool isNull()
const {
return m_string.isNull(); }
96 bool isEmpty()
const {
return !m_length; }
97 int length()
const {
return m_length; }
98 int size()
const {
return m_length; }
99 QChar at(
int i)
const { Q_ASSERT((uint)i < (uint)m_length);
return constData()[i]; }
106 int compare(
const QString &sub, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().compare(sub, cs); }
107 int compare(
const char *sub, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().compare(QLatin1String(sub), cs); }
110 bool startsWith(
const char *sub, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().startsWith(QLatin1String(sub), cs); }
112 template<
typename A,
typename B>
113 bool startsWith(
const QStringBuilder<A, B> &str) {
return startsWith(QString(str)); }
115 bool endsWith(
const QString &sub, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().endsWith(sub, cs); }
116 bool endsWith(
const char *sub, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().endsWith(QLatin1String(sub), cs); }
117 template<
typename A,
typename B>
118 bool endsWith(
const QStringBuilder<A, B> &str) {
return endsWith(QString(str)); }
120 int indexOf(
const QString &s,
int from = 0, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().indexOf(s, from, cs); }
121 int indexOf(
const char *s,
int from = 0, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().indexOf(QLatin1String(s), from, cs); }
122 int indexOf(QChar c,
int from = 0, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().indexOf(c, from, cs); }
123 int lastIndexOf(
const QString &s,
int from = -1, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().lastIndexOf(s, from, cs); }
124 int lastIndexOf(
const char *s,
int from = -1, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().lastIndexOf(QLatin1String(s), from, cs); }
125 int lastIndexOf(QChar c,
int from = -1, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return toQStringView().lastIndexOf(c, from, cs); }
127 bool contains(
const char *s, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
const {
return indexOf(QLatin1String(s), 0, cs) >= 0; }
129 qlonglong toLongLong(
bool *ok =
nullptr,
int base = 10)
const {
return toQStringView().toLongLong(ok, base); }
130 int toInt(
bool *ok =
nullptr,
int base = 10)
const {
return toQStringView().toInt(ok, base); }
131 short toShort(
bool *ok =
nullptr,
int base = 10)
const {
return toQStringView().toShort(ok, base); }
147 ProString(
const ProKey &other);
150 enum OmitPreHashing { NoHash };
151 ProString(
const ProString &other, OmitPreHashing);
153 enum DoPreHashing { DoHash };
156 ALWAYS_INLINE ProString(
const QString &str,
int offset,
int length, DoPreHashing);
157 ALWAYS_INLINE ProString(
const QString &str,
int offset,
int length, uint hash);
160 int m_offset, m_length;
162 mutable size_t m_hash;
163 size_t updatedHash()
const;
174 explicit ProKey(
const QString &str);
175 template<
typename A,
typename B>
180 ProKey(
const QString &str,
int off,
int len);
181 ProKey(
const QString &str,
int off,
int len, uint hash);
202template <>
struct QConcatenable<ProString>
213 memcpy(out, a.toQStringView().data(),
sizeof(QChar) * n);
218template <>
struct QConcatenable<ProKey>
221 typedef QString ConvertTo;
222 enum { ExactSize =
true };
223 static int size(
const ProKey &a) {
return a.length(); }
224 static inline void appendTo(
const ProKey &a, QChar *&out)
226 const auto n = a.size();
229 memcpy(out, a.toQStringView().data(),
sizeof(QChar) * n);
238 {
return that += other.toQStringView(); }
240QTextStream &operator<<(QTextStream &t,
const ProString &str);
241template<
typename A,
typename B>
242QTextStream &operator<<(QTextStream &t,
const QStringBuilder<A, B> &str) {
return t << QString(str); }
283 if (other.m_ps && s.isSharedWith(*other
.m_rs))
300 { QList<ProString>::operator<<(str);
return *
this; }
305 QString
join(
const QString &sep)
const;
306 QString
join(QChar sep)
const;
307 template<
typename A,
typename B>
308 QString
join(
const QStringBuilder<A, B> &str) {
return join(QString(str)); }
322 {
return contains(ProString(str), cs); }
408 ProFile(
int id,
const QString &fileName);
411 int id()
const {
return m_id; }
414 const QString &
items()
const {
return m_proitems; }
416 const ushort *
tokPtr()
const {
return (
const ushort *)m_proitems.constData(); }
417 const ushort *
tokPtrEnd()
const {
return (
const ushort *)m_proitems.constData() + m_proitems.size(); }
422 bool isOk()
const {
return m_ok; }
435 QString m_directoryName;
446 : m_pro(other.m_pro), m_offset(other.m_offset) { other.m_pro =
nullptr; }
455 m_offset = o.m_offset;
467 qSwap(m_pro, other.m_pro);
468 qSwap(m_offset, other.m_offset);
int main(int argc, char *argv[])
[2]
void message(int type, const QString &msg, const QString &fileName, int lineNo) override
void fileMessage(int type, const QString &msg) override
void doneWithEval(ProFile *) override
void aboutToEval(ProFile *, ProFile *, EvalFileType) override
ProFileEvaluator::TemplateType templateType() const
ProFileEvaluator(ProFileGlobals *option, QMakeParser *parser, QMakeVfs *vfs, QMakeHandler *handler)
void setExtraConfigs(const QStringList &extraConfigs)
void setExtraVars(const QHash< QString, QStringList > &extraVars)
QStringList values(const QString &variableName, const ProFile *pro) const
QString value(const QString &variableName) const
bool contains(const QString &variableName) const
QString resolvedMkSpec() const
bool accept(ProFile *pro, QMakeEvaluator::LoadFlags flags=QMakeEvaluator::LoadAll)
QStringList absoluteFileValues(const QString &variable, const QString &baseDirectory, const QStringList &searchDirs, const ProFile *pro) const
void setOutputDir(const QString &dir)
QStringList absolutePathValues(const QString &variable, const QString &baseDirectory) const
QStringList values(const QString &variableName) const
QString propertyValue(const QString &val) const
bool loadNamedSpec(const QString &specDir, bool hostSpec)
const ushort * tokPtrEnd() const
ProFile(int id, const QString &fileName)
const ushort * tokPtr() const
QString directoryName() const
ProString getStr(const ushort *&tPtr)
const QString & items() const
ProKey getHashStr(const ushort *&tPtr)
void setHostBuild(bool host_build)
const ushort * tokPtr() const
ProFunctionDef(ProFunctionDef &&other) noexcept
ProFunctionDef(ProFile *pro, int offset)
void swap(ProFunctionDef &other) noexcept
ProFunctionDef & operator=(ProFunctionDef &&other) noexcept
ProFunctionDef(const ProFunctionDef &o)
ProFunctionDef & operator=(const ProFunctionDef &o)
ProItemRefCount(int cnt=0)
ProItemRefCount & operator=(int value)
void setValue(const QString &str)
ProKey(const QString &str, int off, int len, uint hash)
ALWAYS_INLINE const ProString & toString() const
ProKey(const QStringBuilder< A, B > &str)
ProKey(const QString &str)
ALWAYS_INLINE ProString & toString()
PROITEM_EXPLICIT ProKey(const char *str)
ProKey(const QString &str, int off, int len)
void removeAll(const ProString &str)
bool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString join(QChar sep) const
QString join(const ProString &sep) const
bool contains(const char *str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void removeAll(const char *str)
void insertUnique(const ProStringList &value)
QString join(const QStringBuilder< A, B > &str)
QString join(const QString &sep) const
bool contains(QStringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void removeEach(const ProStringList &value)
ProStringList(const ProString &str)
ProStringList(const QStringList &list)
bool contains(const ProString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QStringList toQStringList() const
ProStringRoUser(const ProString &ps, QString &rs)
ProStringRoUser(QString &rs)
QString & set(const ProString &ps)
ProStringRwUser(QString &rs)
ProString extract(const QString &s) const
QString & set(const ProString &ps)
ProStringRwUser(const ProString &ps, QString &rs)
ProString extract(const QString &s, const ProStringRwUser &other) const
ProString & operator+=(const QLatin1String other)
ProString & setSource(const ProString &other)
QString & toQString(QString &tmp) const
ProString & operator=(const ProString &)=default
bool startsWith(const ProString &sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
ALWAYS_INLINE const ProKey & toKey() const
bool startsWith(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
friend size_t qHash(const ProString &str)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool contains(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
ProString & append(QChar other)
ProString & operator=(const QStringBuilder< A, B > &str)
QByteArray toLatin1() const
bool operator<(const ProString &other) const
ProString mid(int off, int len=-1) const
bool operator==(const ProString &other) const
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString toQString() const
ProString(const QString &str)
bool operator!=(const QString &other) const
bool endsWith(const QStringBuilder< A, B > &str)
ProString & append(const QLatin1String other)
ALWAYS_INLINE QStringView toQStringView() const
int toInt(bool *ok=nullptr, int base=10) const
int indexOf(const QString &s, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void setValue(const QString &str)
bool operator==(const char *other) const
int compare(const QString &sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
ProString(const QString &str, int offset, int length)
ProString & operator+=(QChar other)
ProString & operator+=(const ProString &other)
int compare(const char *sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool operator!=(QLatin1String other) const
int compare(const ProString &sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
ProString right(int len) const
static size_t hash(const QChar *p, int n)
ProString & prepend(const ProString &other)
ALWAYS_INLINE ProKey & toKey()
int indexOf(const char *s, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
qlonglong toLongLong(bool *ok=nullptr, int base=10) const
ProString & append(const char *other)
PROITEM_EXPLICIT ProString(QStringView str)
int lastIndexOf(const QString &s, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool endsWith(const QString &sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool operator!=(const char *other) const
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
const QChar * constData() const
bool operator==(const QString &other) const
ProString(const QStringBuilder< A, B > &str)
bool startsWith(const QStringBuilder< A, B > &str)
bool startsWith(const char *sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int lastIndexOf(const char *s, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
friend QString operator+(const ProString &one, const ProString &two)
ProString & operator+=(const QString &other)
ProString trimmed() const
ProString & operator+=(const char *other)
bool endsWith(const char *sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
ProString left(int len) const
ProString & append(const ProString &other, bool *pending=nullptr)
bool endsWith(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
ProString & append(const QString &other)
ProString & append(const QStringBuilder< A, B > &other)
bool contains(const char *s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool operator!=(const ProString &other) const
ProString & operator+=(const QStringBuilder< A, B > &other)
PROITEM_EXPLICIT ProString(const char *str)
bool operator==(QStringView other) const
bool endsWith(const ProString &sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
ProString & setSource(int id)
ProString & append(const ProStringList &other, bool *pending=nullptr, bool skipEmpty1st=false)
bool startsWith(const QString &sub, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
short toShort(bool *ok=nullptr, int base=10) const
ProString(const ProString &other)
QMakeEvaluator * evaluator
QMakeBaseKey(const QString &_root, const QString &_stash, bool _hostBuild)
QMakeCmdLineParserState(const QString &_pwd)
QString user_template_prefix
QStringList splitPathList(const QString &value) const
void setCommandLineArguments(const QString &pwd, const QStringList &args)
void setProperties(const QHash< ProKey, ProString > &props)
void setDirectories(const QString &input_dir, const QString &output_dir)
QString expandEnvVars(const QString &str) const
QStringList qmake_extra_args
QString qmake_abslocation
void commitCommandLineArguments(QMakeCmdLineParserState &state)
ArgumentReturn addCommandLineArguments(QMakeCmdLineParserState &state, QStringList &args, int *pos)
QString shadowedPath(const QString &fileName) const
static void parseProperties(const QByteArray &data, QHash< ProKey, ProString > &props)
ProString propertyValue(const ProKey &name) const
ReadResult readFile(int id, QString *contents, QString *errStr)
Combined button and popup list for selecting options.
const QString & asString(const QString &s)
Q_DECLARE_TYPEINFO(ProString, Q_RELOCATABLE_TYPE)
QString & operator+=(QString &that, const ProString &other)
QDebug operator<<(QDebug debug, const ProString &str)
Q_DECLARE_TYPEINFO(ProStringList, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ProFunctionDef, Q_RELOCATABLE_TYPE)
QMap< ProKey, ProStringList > ProValueMap
Q_DECLARE_TYPEINFO(ProKey, Q_RELOCATABLE_TYPE)
ProStringList operator+(const ProStringList &one, const ProStringList &two)
bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two)
size_t qHash(const QMakeBaseKey &key)
#define qPrintable(string)
static void printOut(const QString &out)
QStringList getExcludes(const ProFileEvaluator &visitor, const QString &projectDirPath)
static QStringList getSources(const ProFileEvaluator &visitor, const QString &projectDir, QMakeVfs *vfs)
static void excludeProjects(const ProFileEvaluator &visitor, QStringList *subProjects)
void setValue(QJsonObject &obj, const char *key, T value)
static void print(const QString &fileName, int lineNo, const QString &msg)
static QJsonValue toJsonValue(const QString &s)
static QJsonObject processProject(const QString &proFile, const QStringList &translationsVariables, ProFileGlobals *option, QMakeVfs *vfs, QMakeParser *parser, ProFileEvaluator &visitor)
static EvalHandler evalHandler
static QJsonValue toJsonValue(const QJsonValue &v)
static QStringList getSources(const char *var, const char *vvar, const QStringList &baseVPaths, const QString &projectDir, const ProFileEvaluator &visitor)
static QJsonArray processProjects(bool topLevel, const QStringList &proFiles, const QStringList &translationsVariables, const QHash< QString, QString > &outDirMap, ProFileGlobals *option, QMakeVfs *vfs, QMakeParser *parser, bool *fail)
static QStringList getResources(const QString &resourceFile, QMakeVfs *vfs)
static void printErr(const QString &out)
QHash< ProKey, ProFunctionDef > replaceFunctions
QHash< ProKey, ProFunctionDef > testFunctions
static void appendTo(const ProString &a, QChar *&out)
static int size(const ProString &a)