This class is used to parse the product tokens defined by HTTP/1.1. More...
#include <HProductTokens>
Public Member Functions | |
HProductTokens () | |
HProductTokens (const QString &arg) | |
HProductTokens (const HProductTokens &) | |
~HProductTokens () | |
HProductTokens & | operator= (const HProductTokens &) |
bool | isValid () const |
bool | isEmpty () const |
HProductToken | osToken () const |
HProductToken | upnpToken () const |
HProductToken | productToken () const |
QVector< HProductToken > | extraTokens () const |
bool | hasExtraTokens () const |
QVector< HProductToken > | tokens () const |
QString | toString () const |
Related Functions | |
(Note that these are not member functions.) | |
H_UPNP_CORE_EXPORT bool | operator== (const HProductTokens &, const HProductTokens &) |
H_UPNP_CORE_EXPORT bool | operator!= (const HProductTokens &, const HProductTokens &) |
According to the HTTP/1.1, Product tokens are used to allow communicating applications to identify themselves by software name and version. In UDA, the product tokens consist of three tokens, in which The first product token identifes the operating system in the form OS name/OS version, the second token represents the UPnP version and MUST be UPnP/1.1, and the third token identifes the product using the form product name/product version. For example, "SERVER: unix/5.1 UPnP/1.1 MyProduct/1.0".
Unfortunately, product tokens found in UPnP products are rarely conforming to the HTTP/1.1 and UDA specifications. Many products handle "product tokens" as a string that contains "key/value" pairs laid out and delimited arbitrarily. Because of this, HProductTokens
has to accept input that is not strictly standard-conformant. However, at absolute minimum UPnP devices have to provide the UPnP version token. Because of that, HProductTokens
instance is considered valid if the instance contains a valid UPnP version token. All other tokens are considered optional and they may not be present in a valid instance. In practice this means that if isValid() returns true the instance contains a valid UPnP version token, which can be retrieved using upnpToken(). In that case the tokens() returns a list at least of size one. In addition, the instance may contain other data that could not be parsed following the HTTP/1.1 and UDA specifications. This data cannot be retrieved using any of the functions that return HProductToken instances, but you can retrieve the full unparsed product tokens string using toString().
HProductTokens | ( | ) |
HProductTokens | ( | const QString & | arg ) | [explicit] |
Creates a new instance based on the provided argument.
arg | specifies the product tokens. In case the specified argument does not contain a valid UPnP version token the created object will be invalid. However, the object will not be empty and the provided string is returned when toString() is called. |
HProductTokens | ( | const HProductTokens & | other ) |
Copy constructor.
Creates a copy of the other object.
~HProductTokens | ( | ) |
Destroys the instance.
HProductTokens & operator= | ( | const HProductTokens & | other ) |
Assigns the contents of the other to this.
bool isValid | ( | ) | const |
Indicates whether the object contains at least the UPnP version token defined in the UDA.
bool isEmpty | ( | ) | const |
Indicates whether the object contains any information at all.
HProductToken osToken | ( | ) | const |
Returns the product token that defines information of an operating system.
HProductToken upnpToken | ( | ) | const |
Returns the product token that defines UPnP version.
HProductToken productToken | ( | ) | const |
Returns the product token that defines the actual product in the form product name/product version.
QVector< HProductToken > extraTokens | ( | ) | const |
Returns the extra tokens.
A valid HProductTokens
object contains at least the upnpToken(). A strictly valid HProductTokens
object contains at least the osToken(), upnpToken() and producToken(). However, a HProductTokens
instance may contain more than these three tokens, which are called extra tokens in this context.
bool hasExtraTokens | ( | ) | const |
Indicates if the object contains extra tokens in addition to osToken(), upnpToken() and producToken().
QVector< HProductToken > tokens | ( | ) | const |
Returns all product tokens the instance contains.
A valid HProductTokens
object will return a vector that contains at least one entry, the upnpToken(). A strictly valid HProductTokens
object will return a vector that contains at least three entries, the osToken(), upnpToken() and producToken(). If the object contains extra tokens the extra tokens are appended to the returned vector.
QString toString | ( | ) | const |
Returns a string representation of the object.
H_UPNP_CORE_EXPORT bool operator== | ( | const HProductTokens & | , |
const HProductTokens & | |||
) | [related] |
Compares the two objects for equality.
H_UPNP_CORE_EXPORT bool operator!= | ( | const HProductTokens & | , |
const HProductTokens & | |||
) | [related] |
Compares the two objects for inequality.