Herqq
Public Member Functions | Friends | Related Functions

HProductToken Class Reference

This class represents a product token as defined in the RFC 2616, section 3.8. More...

#include <HProductToken>

List of all members.

Public Member Functions

 HProductToken ()
 HProductToken (const QString &token, const QString &productVersion)
 ~HProductToken ()
bool isValid (HValidityCheckLevel checkLevel) const
QString token () const
QString version () const
QString toString () const
qint32 minorVersion ()
qint32 majorVersion ()

Friends

H_UPNP_CORE_EXPORT bool operator== (const HProductToken &obj1, const HProductToken &obj2)

Related Functions

(Note that these are not member functions.)
H_UPNP_CORE_EXPORT bool operator!= (const HProductToken &, const HProductToken &)

Detailed Description

This class represents a product token as defined in the RFC 2616, section 3.8.

Remarks:
This class is not thread-safe.

Constructor & Destructor Documentation

Creates a new, empty instance.

An object created with the default constructor is invalid.

See also:
isValid()
HProductToken ( const QString &  token,
const QString &  productVersion 
)

Creates a new object based on the provided token data.

If the token data is invalid, the object will be invalid as well.

Parameters:
tokenspecifies the token part, which is supposed to identify a product. If this is empty, the created object will be invalid.
productVersionspecifies the version part. If this is empty, the created object will be invalid.
See also:
isValid()

Destroys the instance.


Member Function Documentation

bool isValid ( HValidityCheckLevel  checkLevel) const

Indicates if the object is valid, i.e both the token and the product version are defined.

Parameters:
checkLevelspecifies whether the contents of the object are checked for strict validity. Only an object that is strictly valid contains information as defined in the UDA. In other words, a strictly valid product token takes the form UPnP/majorVersion.minorVersion, where currently major version is always 1 and minor version is either 0 or 1.
Returns:
true in case both the token and product version are appropriately specified.
See also:
token(), productVersion()
QString token ( ) const [inline]

Returns the token part.

Returns:
The token part in case the object is valid. The token part is used to identify the product and an example of a token is for instance "Apache". An empty string is returned in case the object is invalid.
See also:
isValid()
QString version ( ) const [inline]

Returns the version part.

Returns:
The version part in case the object is valid. An example of a version part is "1.0". An empty string is returned in case the object is invalid.
See also:
isValid()
QString toString ( ) const

Returns a string representation of the object.

The format of the returned string is "token"/"version".

Returns:
a string representation of the object.
qint32 minorVersion ( )

Attempts to parse the version part of a product token to a major and minor component and returns the minor component if the function succeeded.

For the function to succeed the specified product token has to contain a version string that follows the format "major.minor". The function ignores any further "version information" after the "minor" component separated by a dot. The "minor" component has to be convertible to an integer.

Returns:
The minor version component of the specified product token or -1 if the specified token does not contain a minor version component that can be represented as an integer.
qint32 majorVersion ( )

Attempts to parse the version part of a product token to a major and minor component and returns the major component if the function succeeded.

For the function to succeed the specified product token has to contain a version string that either

  • can be directly converted to an integer or
  • contains information following the format "major.minor", where the major component can be converted to an integer. Any data following the "minor" component and separated from it by a dot is ignored.
Returns:
The major version component of the specified product token or -1 if the specified token does not contain a major version component that can be represented as an integer.

Friends And Related Function Documentation

H_UPNP_CORE_EXPORT bool operator== ( const HProductToken obj1,
const HProductToken obj2 
) [friend]

Compares the two objects for equality.

Returns:
true in case the object are logically equivalent.
H_UPNP_CORE_EXPORT bool operator!= ( const HProductToken ,
const HProductToken  
) [related]

Compares the two objects for inequality.

Returns:
true in case the objects are not logically equivalent.