Qt 4.8
Enumerations | Functions
QDBusUtil Namespace Reference

The QDBusUtil namespace contains a few functions that are of general use when dealing with D-Bus strings. More...

Enumerations

enum  AllowEmptyFlag { EmptyAllowed, EmptyNotAllowed }
 

Functions

QString argumentToString (const QVariant &arg)
 Dumps the contents of a QtDBus argument from arg into a string. More...
 
bool checkBusName (const QString &name, AllowEmptyFlag empty, QDBusError *error)
 
bool checkErrorName (const QString &name, AllowEmptyFlag empty, QDBusError *error)
 
bool checkInterfaceName (const QString &name, AllowEmptyFlag empty, QDBusError *error)
 
bool checkMemberName (const QString &name, AllowEmptyFlag empty, QDBusError *error, const char *nameType=0)
 
bool checkObjectPath (const QString &path, AllowEmptyFlag empty, QDBusError *error)
 
bool isValidBasicType (int c)
 Returns true if c is a valid, basic D-Bus type. More...
 
bool isValidBusName (const QString &busName)
 Returns true if busName is a valid bus name. More...
 
bool isValidErrorName (const QString &errorName)
 Returns true if errorName is a valid error name. More...
 
bool isValidFixedType (int c)
 Returns true if c is a valid, fixed D-Bus type. More...
 
bool isValidInterfaceName (const QString &ifaceName)
 Returns true if this is ifaceName is a valid interface name. More...
 
bool isValidMemberName (const QString &memberName)
 Returns true if memberName is a valid member name. More...
 
bool isValidObjectPath (const QString &path)
 Returns true if path is valid object path. More...
 
bool isValidPartOfObjectPath (const QString &part)
 
bool isValidSignature (const QString &signature)
 Returns true if signature is a valid D-Bus type signature for one or more types. More...
 
bool isValidSingleSignature (const QString &signature)
 Returns true if signature is a valid D-Bus type signature for exactly one full type. More...
 
bool isValidUniqueConnectionName (const QString &connName)
 Returns true if connName is a valid unique connection name. More...
 

Detailed Description

The QDBusUtil namespace contains a few functions that are of general use when dealing with D-Bus strings.

Attention
Module: QtDBus
Warning
This function is not part of the public interface.

Enumeration Type Documentation

◆ AllowEmptyFlag

Enumerator
EmptyAllowed 
EmptyNotAllowed 

Definition at line 94 of file qdbusutil_p.h.

Function Documentation

◆ argumentToString()

Q_DBUS_EXPORT QString QDBusUtil::argumentToString ( const QVariant arg)

Dumps the contents of a QtDBus argument from arg into a string.

Warning
This function is not part of the public interface.
Since
4.5

Definition at line 324 of file qdbusutil.cpp.

Referenced by debugVariantList().

325  {
326  QString out;
327 
328  variantToString(arg, out);
329 
330  return out;
331  }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static bool variantToString(const QVariant &arg, QString &out)
Definition: qdbusutil.cpp:81

◆ checkBusName()

bool QDBusUtil::checkBusName ( const QString name,
AllowEmptyFlag  empty,
QDBusError error 
)
inline

Definition at line 111 of file qdbusutil_p.h.

Referenced by QDBusAbstractInterfacePrivate::canMakeCalls(), checkIfValid(), and QDBusMessagePrivate::toDBusMessage().

112  {
113  if (name.isEmpty()) {
114  if (empty == EmptyAllowed) return true;
115  *error = QDBusError(QDBusError::InvalidService, QLatin1String("Service name cannot be empty"));
116  return false;
117  }
118  if (isValidBusName(name)) return true;
119  *error = QDBusError(QDBusError::InvalidService, QString::fromLatin1("Invalid service name: %1").arg(name));
120  return false;
121  }
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
bool isValidBusName(const QString &busName)
Returns true if busName is a valid bus name.
Definition: qdbusutil.cpp:435

◆ checkErrorName()

bool QDBusUtil::checkErrorName ( const QString name,
AllowEmptyFlag  empty,
QDBusError error 
)
inline

Definition at line 149 of file qdbusutil_p.h.

Referenced by QDBusMessagePrivate::toDBusMessage().

150  {
151  if (name.isEmpty()) {
152  if (empty == EmptyAllowed) return true;
153  *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Error name cannot be empty"));
154  return false;
155  }
156  if (isValidErrorName(name)) return true;
157  *error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid error name: %1").arg(name));
158  return false;
159  }
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool isValidErrorName(const QString &errorName)
Returns true if errorName is a valid error name.
Definition: qdbusutil.cpp:494
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

◆ checkInterfaceName()

bool QDBusUtil::checkInterfaceName ( const QString name,
AllowEmptyFlag  empty,
QDBusError error 
)
inline

Definition at line 99 of file qdbusutil_p.h.

Referenced by checkIfValid(), and QDBusMessagePrivate::toDBusMessage().

100  {
101  if (name.isEmpty()) {
102  if (empty == EmptyAllowed) return true;
103  *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Interface name cannot be empty"));
104  return false;
105  }
106  if (isValidInterfaceName(name)) return true;
107  *error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid interface class: %1").arg(name));
108  return false;
109  }
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isValidInterfaceName(const QString &ifaceName)
Returns true if this is ifaceName is a valid interface name.
Definition: qdbusutil.cpp:367
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

◆ checkMemberName()

bool QDBusUtil::checkMemberName ( const QString name,
AllowEmptyFlag  empty,
QDBusError error,
const char *  nameType = 0 
)
inline

Definition at line 135 of file qdbusutil_p.h.

Referenced by QDBusMessagePrivate::toDBusMessage().

136  {
137  if (!nameType) nameType = "member";
138  if (name.isEmpty()) {
139  if (empty == EmptyAllowed) return true;
140  *error = QDBusError(QDBusError::InvalidMember, QLatin1String(nameType) + QLatin1String(" name cannot be empty"));
141  return false;
142  }
143  if (isValidMemberName(name)) return true;
144  *error = QDBusError(QDBusError::InvalidMember, QString::fromLatin1("Invalid %1 name: %2")
145  .arg(QString::fromLatin1(nameType), name));
146  return false;
147  }
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool isValidMemberName(const QString &memberName)
Returns true if memberName is a valid member name.
Definition: qdbusutil.cpp:472
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

◆ checkObjectPath()

bool QDBusUtil::checkObjectPath ( const QString path,
AllowEmptyFlag  empty,
QDBusError error 
)
inline

Definition at line 123 of file qdbusutil_p.h.

Referenced by QDBusAbstractInterfacePrivate::canMakeCalls(), checkIfValid(), and QDBusMessagePrivate::toDBusMessage().

124  {
125  if (path.isEmpty()) {
126  if (empty == EmptyAllowed) return true;
127  *error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
128  return false;
129  }
130  if (isValidObjectPath(path)) return true;
131  *error = QDBusError(QDBusError::InvalidObjectPath, QString::fromLatin1("Invalid object path: %1").arg(path));
132  return false;
133  }
bool isValidObjectPath(const QString &path)
Returns true if path is valid object path.
Definition: qdbusutil.cpp:515
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

◆ isValidBasicType()

Q_DBUS_EXPORT bool QDBusUtil::isValidBasicType ( int  c)

Returns true if c is a valid, basic D-Bus type.

Definition at line 542 of file qdbusutil.cpp.

Referenced by QDBusMarshaller::appendCrossMarshalling(), and QDBusMarshaller::beginMap().

543  {
544  return isBasicType(c);
545  }
unsigned char c[8]
Definition: qnumeric_p.h:62
static bool isBasicType(int c)
Definition: qdbusutil.cpp:246

◆ isValidBusName()

Q_DBUS_EXPORT bool QDBusUtil::isValidBusName ( const QString busName)

Returns true if busName is a valid bus name.

A valid bus name is either a valid unique connection name or follows the rules:

  • is not empty
  • does not exceed 255 characters in length
  • be composed of dot-separated string components that contain only ASCII letters, digits, hyphens or underscores ("_"), but don't start with a digit
  • contains at least two such elements
See also
isValidUniqueConnectionName()

Definition at line 435 of file qdbusutil.cpp.

Referenced by checkBusName(), and QDBusConnection::connect().

436  {
437  if (busName.isEmpty() || busName.length() > DBUS_MAXIMUM_NAME_LENGTH)
438  return false;
439 
440  if (busName.startsWith(QLatin1Char(':')))
441  return isValidUniqueConnectionName(busName);
442 
443  QStringList parts = busName.split(QLatin1Char('.'));
444  if (parts.count() < 1)
445  return false;
446 
447  for (int i = 0; i < parts.count(); ++i) {
448  const QString &part = parts.at(i);
449  if (part.isEmpty())
450  return false;
451 
452  const QChar *c = part.unicode();
453  if (isValidNumber(c[0]))
454  return false;
455  for (int j = 0; j < part.length(); ++j)
456  if (!isValidCharacter(c[j]))
457  return false;
458  }
459 
460  return true;
461  }
static bool isValidCharacter(const QChar &c)
Definition: qdbusutil.cpp:64
unsigned char c[8]
Definition: qnumeric_p.h:62
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
static bool isValidNumber(const QChar &c)
Definition: qdbusutil.cpp:73
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool isValidUniqueConnectionName(const QString &connName)
Returns true if connName is a valid unique connection name.
Definition: qdbusutil.cpp:393
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ isValidErrorName()

Q_DBUS_EXPORT bool QDBusUtil::isValidErrorName ( const QString errorName)

Returns true if errorName is a valid error name.

Valid error names are valid interface names and vice-versa, so this function is actually an alias for isValidInterfaceName.

Definition at line 494 of file qdbusutil.cpp.

Referenced by checkErrorName().

495  {
496  return isValidInterfaceName(errorName);
497  }
bool isValidInterfaceName(const QString &ifaceName)
Returns true if this is ifaceName is a valid interface name.
Definition: qdbusutil.cpp:367

◆ isValidFixedType()

Q_DBUS_EXPORT bool QDBusUtil::isValidFixedType ( int  c)

Returns true if c is a valid, fixed D-Bus type.

Definition at line 554 of file qdbusutil.cpp.

Referenced by QDBusMarshaller::appendCrossMarshalling().

555  {
556  return isFixedType(c);
557  }
static bool isFixedType(int c)
Definition: qdbusutil.cpp:251
unsigned char c[8]
Definition: qnumeric_p.h:62

◆ isValidInterfaceName()

Q_DBUS_EXPORT bool QDBusUtil::isValidInterfaceName ( const QString ifaceName)

Returns true if this is ifaceName is a valid interface name.

Valid interface names must:

  • not be empty
  • not exceed 255 characters in length
  • be composed of dot-separated string components that contain only ASCII letters, digits and the underscore ("_") character
  • contain at least two such components

Definition at line 367 of file qdbusutil.cpp.

Referenced by checkInterfaceName(), QDBusConnection::connect(), QDBusConnection::disconnect(), QDBusXmlParser::interfaces(), isValidErrorName(), QDBusXmlParser::object(), and parseAnnotations().

368  {
369  if (ifaceName.isEmpty() || ifaceName.length() > DBUS_MAXIMUM_NAME_LENGTH)
370  return false;
371 
372  QStringList parts = ifaceName.split(QLatin1Char('.'));
373  if (parts.count() < 2)
374  return false; // at least two parts
375 
376  for (int i = 0; i < parts.count(); ++i)
377  if (!isValidMemberName(parts.at(i)))
378  return false;
379 
380  return true;
381  }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool isValidMemberName(const QString &memberName)
Returns true if memberName is a valid member name.
Definition: qdbusutil.cpp:472
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ isValidMemberName()

Q_DBUS_EXPORT bool QDBusUtil::isValidMemberName ( const QString memberName)

Returns true if memberName is a valid member name.

A valid member name does not exceed 255 characters in length, is not empty, is composed only of ASCII letters, digits and underscores, but does not start with a digit.

Definition at line 472 of file qdbusutil.cpp.

Referenced by checkMemberName(), QDBusXmlParser::interfaces(), and isValidInterfaceName().

473  {
474  if (memberName.isEmpty() || memberName.length() > DBUS_MAXIMUM_NAME_LENGTH)
475  return false;
476 
477  const QChar* c = memberName.unicode();
478  if (isValidNumber(c[0]))
479  return false;
480  for (int j = 0; j < memberName.length(); ++j)
481  if (!isValidCharacterNoDash(c[j]))
482  return false;
483  return true;
484  }
unsigned char c[8]
Definition: qnumeric_p.h:62
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static bool isValidNumber(const QChar &c)
Definition: qdbusutil.cpp:73
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static bool isValidCharacterNoDash(const QChar &c)
Definition: qdbusutil.cpp:55
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704

◆ isValidObjectPath()

Q_DBUS_EXPORT bool QDBusUtil::isValidObjectPath ( const QString path)

Returns true if path is valid object path.

Valid object paths follow the rules:

  • start with the slash character ("/")
  • do not end in a slash, unless the path is just the initial slash
  • do not contain any two slashes in sequence
  • contain slash-separated parts, each of which is composed of ASCII letters, digits and underscores ("_")

Definition at line 515 of file qdbusutil.cpp.

Referenced by QDBusObjectPath::check(), checkObjectPath(), QDBusConnection::connect(), QDBusXmlParser::object(), QDBusConnection::objectRegisteredAt(), QDBusConnection::registerObject(), and QDBusConnection::unregisterObject().

516  {
517  if (path == QLatin1String("/"))
518  return true;
519 
520  if (!path.startsWith(QLatin1Char('/')) || path.indexOf(QLatin1String("//")) != -1 ||
521  path.endsWith(QLatin1Char('/')))
522  return false;
523 
524  QStringList parts = path.split(QLatin1Char('/'));
525  Q_ASSERT(parts.count() >= 1);
526  parts.removeFirst(); // it starts with /, so we get an empty first part
527 
528  for (int i = 0; i < parts.count(); ++i)
529  if (!isValidPartOfObjectPath(parts.at(i)))
530  return false;
531 
532  return true;
533  }
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
void removeFirst()
Removes the first item in the list.
Definition: qlist.h:286
bool isValidPartOfObjectPath(const QString &part)
Definition: qdbusutil.cpp:338
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ isValidPartOfObjectPath()

Q_DBUS_EXPORT bool QDBusUtil::isValidPartOfObjectPath ( const QString part)
Warning
This function is not part of the public interface.

See QDBusUtil::isValidObjectPath

Definition at line 338 of file qdbusutil.cpp.

Referenced by generateSubObjectXml(), and isValidObjectPath().

339  {
340  if (part.isEmpty())
341  return false; // can't be valid if it's empty
342 
343  const QChar *c = part.unicode();
344  for (int i = 0; i < part.length(); ++i)
345  if (!isValidCharacterNoDash(c[i]))
346  return false;
347 
348  return true;
349  }
unsigned char c[8]
Definition: qnumeric_p.h:62
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static bool isValidCharacterNoDash(const QChar &c)
Definition: qdbusutil.cpp:55
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704

◆ isValidSignature()

Q_DBUS_EXPORT bool QDBusUtil::isValidSignature ( const QString signature)

Returns true if signature is a valid D-Bus type signature for one or more types.

This function returns true if it can all of signature into valid, individual types and no characters remain in signature.

See also
isValidSingleSignature()

Definition at line 571 of file qdbusutil.cpp.

Referenced by QDBusSignature::check().

572  {
573  QByteArray ba = signature.toLatin1();
574  const char *data = ba.constData();
575  while (true) {
576  data = validateSingleType(data);
577  if (!data)
578  return false;
579  if (*data == '\0')
580  return true;
581  }
582  }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static const char * validateSingleType(const char *signature)
Definition: qdbusutil.cpp:258
static const char * data(const QByteArray &arr)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433

◆ isValidSingleSignature()

Q_DBUS_EXPORT bool QDBusUtil::isValidSingleSignature ( const QString signature)

Returns true if signature is a valid D-Bus type signature for exactly one full type.

This function tries to convert the type signature into a D-Bus type and, if it succeeds and no characters remain in the signature, it returns true.

Definition at line 593 of file qdbusutil.cpp.

Referenced by QDBusArgumentPrivate::createSignature(), QDBusXmlParser::interfaces(), and parseArgs().

594  {
595  QByteArray ba = signature.toLatin1();
596  const char *data = validateSingleType(ba.constData());
597  return data && *data == '\0';
598  }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static const char * validateSingleType(const char *signature)
Definition: qdbusutil.cpp:258
static const char * data(const QByteArray &arr)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433

◆ isValidUniqueConnectionName()

Q_DBUS_EXPORT bool QDBusUtil::isValidUniqueConnectionName ( const QString connName)

Returns true if connName is a valid unique connection name.

Unique connection names start with a colon (":") and are followed by a list of dot-separated components composed of ASCII letters, digits, the hyphen or the underscore ("_") character.

Definition at line 393 of file qdbusutil.cpp.

Referenced by QDBusConnectionPrivate::getNameOwner(), and isValidBusName().

394  {
395  if (connName.isEmpty() || connName.length() > DBUS_MAXIMUM_NAME_LENGTH ||
396  !connName.startsWith(QLatin1Char(':')))
397  return false;
398 
399  QStringList parts = connName.mid(1).split(QLatin1Char('.'));
400  if (parts.count() < 1)
401  return false;
402 
403  for (int i = 0; i < parts.count(); ++i) {
404  const QString &part = parts.at(i);
405  if (part.isEmpty())
406  return false;
407 
408  const QChar* c = part.unicode();
409  for (int j = 0; j < part.length(); ++j)
410  if (!isValidCharacter(c[j]))
411  return false;
412  }
413 
414  return true;
415  }
static bool isValidCharacter(const QChar &c)
Definition: qdbusutil.cpp:64
unsigned char c[8]
Definition: qnumeric_p.h:62
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55