Poco::UPnP

class URN

Library: UPnP
Package: Core
Header: Poco/UPnP/URN.h

Description

A Uniform Resource Name, or URN, is a variant of an URI that stores a structured name used to identify an entity. In UPnP, URNs are used to identify devices, device types and service types, as well as SSDP notification types.

This class is used to create and parse the different kinds of URNs used by UPnP:

  • UUID-based URNs (uuid:<device-UUID>[...]), as used for USNs.
  • Root Device (upnp:rootdevice), for announcing a root device with SSDP.
  • URNs containing device or service name, type and version (urn:<domain-name>:<name>:<type>:<version>)
  • Service IDs (urn:upnp-org:serviceId:serviceID), as used in XML device descriptions.

URN supports full value semantics, including comparison operators. Note, however, that copying URN values may be expensive.

Note: some device manufacturers use strings like "uuid:UPnP_Thomson TG585 v7-1_00-1F-9F-E9-24-14" for their UUIDs. Since these are not valid UUIDs we don't use the Poco::UUID class for storing them.

Member Summary

Member Functions: clear, domain, empty, majorVersion, matches, minorVersion, name, operator !=, operator <, operator <=, operator =, operator ==, operator >, operator >=, scheme, swap, toString, type, uuid, version

Enumerations

Type

URN_UUID = 0

uuid:<device-UUID>

URN_ROOT_DEVICE

upnp:rootdevice

URN_DEVICE

urn:<domain-name>:device:<type>:<version>

URN_SERVICE

urn:<domain-name>:service:<type>:<version>

URN_SERVICEID

urn:upnp-org:serviceId:<serviceId>

Constructors

URN

URN();

Creates an empty URN.

URN

URN(
    Type type
);

Creates a root device URN.

Note: type must always be URN_ROOT_DEVICE.

URN

URN(
    const URN & urn
);

Creates a URN by copying another one.

URN

explicit URN(
    const std::string & urn
);

Creates a URN by parsing the given string.

URN

explicit URN(
    const Poco::UUID & uuid
);

Creates a URN of type URN_UUID, using the given UUID.

URN

URN(
    Type type,
    const std::string & serviceId
);

Creates a URN of type URN_SERVICEID using the given serviceId.

Type must be URN_SERVICEID.

URN

URN(
    Type type,
    const std::string & name,
    const std::string & version
);

Creates a URN of type URN_DEVICE or URN_SERVICE, using the given name and version. The domain is set to "schemas-upnp-org".

Type must be URN_DEVICE or URN_SERVICE.

URN

URN(
    Type type,
    const std::string & domain,
    const std::string & name,
    const std::string & version
);

Creates a URN of type URN_DEVICE or URN_SERVICE, using the given domain, name and version.

Type must be URN_DEVICE or URN_SERVICE.

Destructor

~URN

~URN();

Destroys the URN.

Member Functions

clear

void clear();

Clears the URN.

domain inline

const std::string & domain() const;

Returns the URN domain part (e.g. "schemas-upnp-org").

empty inline

bool empty() const;

Returns true iff the URN is empty.

majorVersion inline

int majorVersion() const;

Returns the major version number.

A version is set for types URN_DEVICE and URN_SERVICE only.

matches

bool matches(
    const URN & urn
) const;

Compares type, scheme, domain and name and checks whether this URN's version is greater or equal to urn's version.

matches

bool matches(
    const std::string & urn
) const;

Compares type, scheme, domain and name and checks whether this URN's version is greater or equal to urn's version.

minorVersion inline

int minorVersion() const;

Returns the minor version number.

A version is set for types URN_DEVICE and URN_SERVICE only.

name inline

const std::string & name() const;

Returns the name of the service/device.

operator != inline

bool operator != (
    const URN & urn
) const;

operator !=

bool operator != (
    const std::string & urn
) const;

operator < inline

bool operator < (
    const URN & urn
) const;

operator <

bool operator < (
    const std::string & urn
) const;

operator <= inline

bool operator <= (
    const URN & urn
) const;

operator <=

bool operator <= (
    const std::string & urn
) const;

operator =

URN & operator = (
    const URN & urn
);

Assignment operator.

operator =

URN & operator = (
    const std::string & urn
);

Parses an URN from the given string and assigns it.

operator == inline

bool operator == (
    const URN & urn
) const;

operator ==

bool operator == (
    const std::string & urn
) const;

operator > inline

bool operator > (
    const URN & urn
) const;

operator >

bool operator > (
    const std::string & urn
) const;

operator >= inline

bool operator >= (
    const URN & urn
) const;

operator >=

bool operator >= (
    const std::string & urn
) const;

scheme inline

const std::string & scheme() const;

Returns the URN scheme part, which will be one of "uuid", "upnp" or "urn".

swap

void swap(
    URN & urn
);

Exchanges the URN with another one.

toString inline

const std::string & toString() const;

Converts a URN to a string.

type inline

URN::Type type() const;

Returns the type of the URN.

uuid inline

const std::string & uuid() const;

Returns the UUID value for a URN of type URN_UUID. Throws an exception if the URN has a wrong type.

version inline

const std::string & version() const;

Returns the version string (<major>.<minor>).

A version is set for types URN_DEVICE and URN_SERVICE only.

Variables

DEVICE static

static const std::string DEVICE;

ROOTDEVICE static

static const std::string ROOTDEVICE;

SCHEMAS_UPNP_ORG static

static const std::string SCHEMAS_UPNP_ORG;

SERVICE static

static const std::string SERVICE;

SERVICEID static

static const std::string SERVICEID;

UPNP_ORG static

static const std::string UPNP_ORG;

UPNP_SCHEME static

static const std::string UPNP_SCHEME;

URN_SCHEME static

static const std::string URN_SCHEME;

UUID_SCHEME static

static const std::string UUID_SCHEME;

Securely control IoT edge devices from anywhere   Connect a Device