mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 15:15:39 +08:00
String utility function for balanced quotes
This commit is contained in:
committed by
Mat Sutcliffe
parent
09a3447047
commit
1238357749
@@ -484,6 +484,13 @@ namespace BlackMisc
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasBalancedQuotes(const QString &in, char quote)
|
||||||
|
{
|
||||||
|
if (in.isEmpty()) { return true; }
|
||||||
|
const int c = in.count(quote);
|
||||||
|
return (c % 2) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|||||||
@@ -208,6 +208,9 @@ namespace BlackMisc
|
|||||||
//! Return string in quotes
|
//! Return string in quotes
|
||||||
BLACKMISC_EXPORT QString inQuotes(const QString &in, bool ignoreEmpty = false);
|
BLACKMISC_EXPORT QString inQuotes(const QString &in, bool ignoreEmpty = false);
|
||||||
|
|
||||||
|
//! Has balanced quotes
|
||||||
|
BLACKMISC_EXPORT bool hasBalancedQuotes(const QString &in, char quote = '"');
|
||||||
|
|
||||||
//! Remove surrounding apostrophes 'foo' -> foo
|
//! Remove surrounding apostrophes 'foo' -> foo
|
||||||
BLACKMISC_EXPORT QString removeSurroundingApostrophes(const QString &in);
|
BLACKMISC_EXPORT QString removeSurroundingApostrophes(const QString &in);
|
||||||
|
|
||||||
@@ -328,7 +331,7 @@ namespace BlackMisc
|
|||||||
//! Operator << when there is no debug stream
|
//! Operator << when there is no debug stream
|
||||||
friend QNoDebug operator<<(QNoDebug nodebug, const Derived &obj)
|
friend QNoDebug operator<<(QNoDebug nodebug, const Derived &obj)
|
||||||
{
|
{
|
||||||
Q_UNUSED(obj);
|
Q_UNUSED(obj)
|
||||||
return nodebug;
|
return nodebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user