forked from qt-creator/qt-creator
Utils: Make CommandLine related operators hidden friends
Change-Id: Ifb81bb565f7343739883c06817f3e304bdc5b963 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -13,13 +13,6 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
QDebug operator<<(QDebug dbg, const Utils::CommandLine &cmd)
|
|
||||||
{
|
|
||||||
return dbg << cmd.toUserOutput();
|
|
||||||
}
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
// The main state of the Unix shell parser
|
// The main state of the Unix shell parser
|
||||||
enum MxQuoting { MxBasic, MxSingleQuote, MxDoubleQuote, MxParen, MxSubst, MxGroup, MxMath };
|
enum MxQuoting { MxBasic, MxSingleQuote, MxDoubleQuote, MxParen, MxSubst, MxGroup, MxMath };
|
||||||
|
|
||||||
@@ -1531,4 +1524,14 @@ QStringList CommandLine::splitArguments() const
|
|||||||
return ProcessArgs::splitArgs(m_arguments, m_executable.osType());
|
return ProcessArgs::splitArgs(m_arguments, m_executable.osType());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
QTCREATOR_UTILS_EXPORT bool operator==(const CommandLine &first, const CommandLine &second)
|
||||||
|
{
|
||||||
|
return first.m_executable == second.m_executable && first.m_arguments == second.m_arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug dbg, const CommandLine &cmd)
|
||||||
|
{
|
||||||
|
return dbg << cmd.toUserOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Utils
|
||||||
|
@@ -64,7 +64,8 @@ public:
|
|||||||
* Assumes that the name of the actual command is *not* part of the line.
|
* Assumes that the name of the actual command is *not* part of the line.
|
||||||
* Terminates after the first command if the command line is complex.
|
* Terminates after the first command if the command line is complex.
|
||||||
*/
|
*/
|
||||||
class QTCREATOR_UTILS_EXPORT ArgIterator {
|
class QTCREATOR_UTILS_EXPORT ArgIterator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
ArgIterator(QString *str, OsType osType = HostOsInfo::hostOs())
|
ArgIterator(QString *str, OsType osType = HostOsInfo::hostOs())
|
||||||
: m_str(str), m_osType(osType)
|
: m_str(str), m_osType(osType)
|
||||||
@@ -80,6 +81,7 @@ public:
|
|||||||
//! Insert argument into the command line after the last one fetched via next().
|
//! Insert argument into the command line after the last one fetched via next().
|
||||||
//! This may be used before the first call to next() to insert at the front.
|
//! This may be used before the first call to next() to insert at the front.
|
||||||
void appendArg(const QString &str);
|
void appendArg(const QString &str);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString *m_str, m_value;
|
QString *m_str, m_value;
|
||||||
int m_pos = 0;
|
int m_pos = 0;
|
||||||
@@ -88,7 +90,8 @@ public:
|
|||||||
OsType m_osType;
|
OsType m_osType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT ConstArgIterator {
|
class QTCREATOR_UTILS_EXPORT ConstArgIterator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
ConstArgIterator(const QString &str, OsType osType = HostOsInfo::hostOs())
|
ConstArgIterator(const QString &str, OsType osType = HostOsInfo::hostOs())
|
||||||
: m_str(str), m_ait(&m_str, osType)
|
: m_str(str), m_ait(&m_str, osType)
|
||||||
@@ -96,6 +99,7 @@ public:
|
|||||||
bool next() { return m_ait.next(); }
|
bool next() { return m_ait.next(); }
|
||||||
bool isSimple() const { return m_ait.isSimple(); }
|
bool isSimple() const { return m_ait.isSimple(); }
|
||||||
QString value() const { return m_ait.value(); }
|
QString value() const { return m_ait.value(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_str;
|
QString m_str;
|
||||||
ArgIterator m_ait;
|
ArgIterator m_ait;
|
||||||
@@ -148,19 +152,14 @@ public:
|
|||||||
|
|
||||||
bool isEmpty() const { return m_executable.isEmpty(); }
|
bool isEmpty() const { return m_executable.isEmpty(); }
|
||||||
|
|
||||||
friend bool operator==(const CommandLine &first, const CommandLine &second) {
|
|
||||||
return first.m_executable == second.m_executable && first.m_arguments == second.m_arguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend QTCREATOR_UTILS_EXPORT bool operator==(const CommandLine &first, const CommandLine &second);
|
||||||
|
friend QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug dbg, const CommandLine &cmd);
|
||||||
|
|
||||||
FilePath m_executable;
|
FilePath m_executable;
|
||||||
QString m_arguments;
|
QString m_arguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Utils
|
} // Utils
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug dbg, const Utils::CommandLine &cmd);
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Utils::CommandLine)
|
Q_DECLARE_METATYPE(Utils::CommandLine)
|
||||||
|
Reference in New Issue
Block a user