mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +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;
|
||||
}
|
||||
|
||||
bool hasBalancedQuotes(const QString &in, char quote)
|
||||
{
|
||||
if (in.isEmpty()) { return true; }
|
||||
const int c = in.count(quote);
|
||||
return (c % 2) == 0;
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
//! \endcond
|
||||
|
||||
@@ -208,6 +208,9 @@ namespace BlackMisc
|
||||
//! Return string in quotes
|
||||
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
|
||||
BLACKMISC_EXPORT QString removeSurroundingApostrophes(const QString &in);
|
||||
|
||||
@@ -328,7 +331,7 @@ namespace BlackMisc
|
||||
//! Operator << when there is no debug stream
|
||||
friend QNoDebug operator<<(QNoDebug nodebug, const Derived &obj)
|
||||
{
|
||||
Q_UNUSED(obj);
|
||||
Q_UNUSED(obj)
|
||||
return nodebug;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user