.. index:: pair: class; EE::Network::URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i: class EE::Network::URI ====================== .. toctree:: :hidden: Overview ~~~~~~~~ A Uniform Resource Identifier, as specified in RFC 3986. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class URI { public: // construction :ref:`URI`(); :ref:`URI`(const std::string& uri); :ref:`URI`(const char* uri); :ref:`URI`(const std::string& scheme, const std::string& pathEtc); :ref:`URI`(const std::string& scheme, const std::string& authority, const std::string& pathEtc); :ref:`URI`(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query); :ref:`URI`(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query, const std::string& fragment); :ref:`URI`(const URI& uri); :ref:`URI`(const URI& baseURI, const std::string& relativeURI); :ref:`~URI`(); // methods URI& :ref:`operator=`(const URI& uri); URI& :ref:`operator=`(const std::string& uri); URI& :ref:`operator=`(const char* uri); bool :target:`operator<`(const URI& url) const; void :ref:`swap`(URI& uri); void :ref:`clear`(); std::string :ref:`toString`() const; const std::string& :ref:`getScheme`() const; void :ref:`setScheme`(const std::string& scheme); const std::string& :ref:`getUserInfo`() const; void :ref:`setUserInfo`(const std::string& userInfo); const std::string& :ref:`getHost`() const; void :ref:`setHost`(const std::string& host); unsigned short :ref:`getPort`() const; void :ref:`getPort`(unsigned short port); std::string :ref:`getAuthority`() const; void :ref:`setAuthority`(const std::string& authority); std::string :ref:`getSchemeAndAuthority`() const; const std::string& :ref:`getPath`() const; std::string :target:`getFSPath`() const; std::string :ref:`getLastPathSegment`() const; void :ref:`setPath`(const std::string& path); std::string :ref:`getQuery`() const; void :ref:`setQuery`(const std::string& query); const std::string& :ref:`getRawQuery`() const; void :ref:`setRawQuery`(const std::string& query); const std::string& :ref:`getFragment`() const; void :ref:`getFragment`(const std::string& fragment); void :ref:`setPathEtc`(const std::string& pathEtc); std::string :ref:`getPathEtc`() const; std::string :ref:`getPathAndQuery`() const; void :ref:`resolve`(const std::string& relativeURI); void :ref:`resolve`(const URI& relativeURI); bool :ref:`isRelative`() const; bool :ref:`empty`() const; bool :ref:`operator==`(const URI& uri) const; bool :ref:`operator==`(const std::string& uri) const; bool :ref:`operator!=`(const URI& uri) const; bool :ref:`operator!=`(const std::string& uri) const; void :ref:`normalize`(); void :ref:`getPathSegments`(std::vector& segments); std::string :ref:`getLastPathSegment`(); std::string :ref:`getAuthorityAndPath`() const; static void :ref:`encode`(const std::string& str, const std::string& reserved, std::string& encodedStr); static void :ref:`decode`(const std::string& str, std::string& decodedStr); static std::string :ref:`encode`(const std::string& str); static std::string :ref:`decode`(const std::string& str); }; .. _details-class_e_e_1_1_network_1_1_u_r_i: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ A Uniform Resource Identifier, as specified in RFC 3986. The :ref:`URI ` class provides methods for building URIs from their parts, as well as for splitting URIs into their parts. Furthermore, the class provides methods for resolving relative URIs against base URIs. The class automatically performs a few normalizations on all URIs and :ref:`URI ` parts passed to it: scheme identifiers are converted to lower case. percent-encoded characters are decoded optionally, dot segments are removed from paths (see Normalize()) Examples of :ref:`URI ` structure: .. ref-code-block:: cpp foo://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose \_/ \_______________/ \_________/ \__/ \___/ \_/ \______________________/ \__/ | | | | | | | | | userinfo hostname port | | query fragment | \________________________________/\_____________|____|/ \__/ \__/ | | | | | | | | | | | | | | scheme authority path | | interpretable as keys name \_______________________________________________|____|/ \____/ \_____/ | | | | | | | hierarchical part | | interpretable as values | | | | path interpretable as filename | | ___________|____________ | / \ / \ | urn:example:animal:ferret:nose interpretable as extension path _________|________ scheme / \ name userinfo hostname query _|__ ___|__ ____|____ _____|_____ / \ / \ / \ / \ mailto:username@example.com?subject=Topic This class is based on the Poco library :ref:`URI ` class. Construction ------------ .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ac797391c4161bebe51b946507daeaa7c: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI() Creates an empty :ref:`URI `. .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a08522aa69a5f0c3001bc1d6598b908b2: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI(const std::string& uri) Parses an :ref:`URI ` from the given string. .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ac96d8045160f51ff4c0ba0698d990fee: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI(const char* uri) Parses an :ref:`URI ` from the given string. .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a960d1bd03433c49e4523e66c0974d753: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI(const std::string& scheme, const std::string& pathEtc) Creates an :ref:`URI ` from its parts. .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a47ed612ad21f6d0b8847f29f8172a02f: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI(const std::string& scheme, const std::string& authority, const std::string& pathEtc) Creates an :ref:`URI ` from its parts. .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a29487f3418c608d7f12bcff4080e931b: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query) Creates an :ref:`URI ` from its parts. .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1af29facc8765f551269963cc8a63177c4: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query, const std::string& fragment) Creates an :ref:`URI ` from its parts. .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a41fa30282378a841523a20ab80fbe399: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI(const URI& uri) Copy constructor. Creates an :ref:`URI ` from another one. .. index:: pair: function; URI .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1af0ea68817c53bdbd8d1c3b1785f7dcce: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI(const URI& baseURI, const std::string& relativeURI) Creates an :ref:`URI ` from a base :ref:`URI ` and a relative :ref:`URI `, according to the algorithm in section 5.2 of RFC 3986. .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1abdc5539171750733c8ad5ab62700dee3: .. ref-code-block:: cpp :class: doxyrest-title-code-block ~URI() Destroys the :ref:`URI `. Methods ------- .. index:: pair: function; operator= .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1aa59857e6c73a602f33e492d6b8dc6e51: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI& operator=(const URI& uri) Assignment operator. .. index:: pair: function; operator= .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a75c086747422ad6cbecbb8c542d33cef: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI& operator=(const std::string& uri) Parses and assigns an :ref:`URI ` from the given string. .. index:: pair: function; operator= .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1adc5521d99cd953c4a7b17d96bce89abb: .. ref-code-block:: cpp :class: doxyrest-title-code-block URI& operator=(const char* uri) Parses and assigns an :ref:`URI ` from the given string. .. index:: pair: function; swap .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1af92ecaee9b13ad64ec7c16e478d4d6b6: .. ref-code-block:: cpp :class: doxyrest-title-code-block void swap(URI& uri) Swaps the :ref:`URI ` with another one. .. index:: pair: function; clear .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a0401da69d1d995f04e18cc05efd83b9d: .. ref-code-block:: cpp :class: doxyrest-title-code-block void clear() Clears all parts of the :ref:`URI `. .. index:: pair: function; toString .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1adb4ccf048bc63f44a9adc231e736173c: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string toString() const .. rubric:: Returns: a string representation of the :ref:`URI `. Characters in the path, query and fragment parts will be percent-encoded as necessary. .. index:: pair: function; getScheme .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ad07a889ff8c2cd7697e3be040d93f92d: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& getScheme() const .. rubric:: Returns: the scheme part of the :ref:`URI `. .. index:: pair: function; setScheme .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a5c4a78f34cd2eb01ced4d50ca8578304: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setScheme(const std::string& scheme) Sets the scheme part of the :ref:`URI `. The given scheme is converted to lower-case. A list of registered :ref:`URI ` schemes can be found at `http://www.iana.org/assignments/uri-schemes `__. .. index:: pair: function; getUserInfo .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a6e4c2991ad51edbfa13f58dc2f5f6d4b: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& getUserInfo() const .. rubric:: Returns: the user-info part of the :ref:`URI `. .. index:: pair: function; setUserInfo .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a1d6dc623dc3b19c9afe85d890b62cd42: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setUserInfo(const std::string& userInfo) Sets the user-info part of the :ref:`URI `. .. index:: pair: function; getHost .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a7d6167ed6d5ed541eb1cabd7d69a0f4a: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& getHost() const .. rubric:: Returns: the host part of the :ref:`URI `. .. index:: pair: function; setHost .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ab436bb2137ae6e2bf910d626b7ccd653: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setHost(const std::string& host) Sets the host part of the :ref:`URI `. .. index:: pair: function; getPort .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a86ba33b74f09381cae35929106f03c8c: .. ref-code-block:: cpp :class: doxyrest-title-code-block unsigned short getPort() const .. rubric:: Returns: the port number part of the :ref:`URI `. If no port number (0) has been specified, the well-known port number (e.g., 80 for http) for the given scheme is returned if it is known. Otherwise, 0 is returned. .. index:: pair: function; getPort .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a9050393dc913a175bc5a8aa6f1792ab4: .. ref-code-block:: cpp :class: doxyrest-title-code-block void getPort(unsigned short port) Sets the port number part of the :ref:`URI `. .. index:: pair: function; getAuthority .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ae222caf4b18c27c79dc26358d44d5e75: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string getAuthority() const .. rubric:: Returns: the authority part (userInfo, host and port) of the :ref:`URI `. If the port number is a well-known port number for the given scheme (e.g., 80 for http), it is not included in the authority. .. index:: pair: function; setAuthority .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a235bae6fcb42ff092351f0b6eef6a6c1: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setAuthority(const std::string& authority) Parses the given authority part for the :ref:`URI ` and sets the user-info, host, port components accordingly. .. index:: pair: function; getSchemeAndAuthority .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1adb20b7810c1fc06ce865545b5e345a76: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string getSchemeAndAuthority() const .. rubric:: Returns: The scheme and authority of the :ref:`URI `. .. index:: pair: function; getPath .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a20f013c0d4d793d0cf74a04ce0d851cd: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& getPath() const .. rubric:: Returns: The path part of the :ref:`URI `. .. index:: pair: function; getLastPathSegment .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a9f5951fde36d38c9d3d240c170a863ff: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string getLastPathSegment() const .. rubric:: Returns: The last path segment. .. index:: pair: function; setPath .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1aa78cb9dc9f3526ac98096b82376ee27e: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setPath(const std::string& path) Sets the path part of the :ref:`URI `. .. index:: pair: function; getQuery .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a4c11499a243be3bf4251b6bbb73d9c51: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string getQuery() const .. rubric:: Returns: the query part of the :ref:`URI `. .. index:: pair: function; setQuery .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a246dd36b0acbf101267c4affc885695d: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setQuery(const std::string& query) Sets the query part of the :ref:`URI `. .. index:: pair: function; getRawQuery .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a19c7f4e9728be50fece4f6b7309e2931: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& getRawQuery() const .. rubric:: Returns: the unencoded query part of the :ref:`URI `. .. index:: pair: function; setRawQuery .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a0f431fc1a3d53ea35d999203d536e0f1: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setRawQuery(const std::string& query) Sets the query part of the :ref:`URI `. .. index:: pair: function; getFragment .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a7fc83f9a5836aa95d5869add838b4152: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& getFragment() const .. rubric:: Returns: the fragment part of the :ref:`URI `. .. index:: pair: function; getFragment .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ac7ef090ba362238cb8322893939e2e71: .. ref-code-block:: cpp :class: doxyrest-title-code-block void getFragment(const std::string& fragment) Sets the fragment part of the :ref:`URI `. .. index:: pair: function; setPathEtc .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a9009acd8b9c51ea3a3d6f9033af31443: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setPathEtc(const std::string& pathEtc) Sets the path, query and fragment parts of the :ref:`URI `. .. index:: pair: function; getPathEtc .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a521df494d1aa20e4e254d324e419293d: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string getPathEtc() const .. rubric:: Returns: the path, query and fragment parts of the :ref:`URI `. .. index:: pair: function; getPathAndQuery .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a02cb83bb943c246bfabd6f31b3be508f: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string getPathAndQuery() const .. rubric:: Returns: the path and query parts of the :ref:`URI `. .. index:: pair: function; resolve .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ac7741a19282af18be7d35b3767ca526f: .. ref-code-block:: cpp :class: doxyrest-title-code-block void resolve(const std::string& relativeURI) Resolves the given relative :ref:`URI ` against the base :ref:`URI `. See section 5.2 of RFC 3986 for the algorithm used. .. index:: pair: function; resolve .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1abd282411d888b7502acd4fb4ecf1fc8d: .. ref-code-block:: cpp :class: doxyrest-title-code-block void resolve(const URI& relativeURI) Resolves the given relative :ref:`URI ` against the base :ref:`URI `. See section 5.2 of RFC 3986 for the algorithm used. .. index:: pair: function; isRelative .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ae0f728612d90cbe77baa7219c810e40e: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool isRelative() const .. rubric:: Returns: true if the :ref:`URI ` is a relative reference, false otherwise. A relative reference does not contain a scheme identifier. Relative references are usually resolved against an absolute base reference. .. index:: pair: function; empty .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ac024f7c382f6702138c15b474671c829: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool empty() const .. rubric:: Returns: true if the :ref:`URI ` is empty, false otherwise. .. index:: pair: function; operator== .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a361856a567a1465ff56699b412268126: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool operator==(const URI& uri) const .. rubric:: Returns: true if both URIs are identical, false otherwise. Two URIs are identical if their scheme, authority, path, query and fragment part are identical. .. index:: pair: function; operator== .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a25f58c96f9e233292bd980e7d76106f2: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool operator==(const std::string& uri) const Parses the given :ref:`URI ` and returns true if both URIs are identical, false otherwise. .. index:: pair: function; operator!= .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ae1bbfcc1bb8cb4ecac472c8e6878d65d: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool operator!=(const URI& uri) const .. rubric:: Returns: true if both URIs are identical, false otherwise. .. index:: pair: function; operator!= .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a5562a2fa88434b22658da1d3828e83c5: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool operator!=(const std::string& uri) const Parses the given :ref:`URI ` and returns true if both URIs are identical, false otherwise. .. index:: pair: function; normalize .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1aece3bf178696cd92509edfca97fee8b1: .. ref-code-block:: cpp :class: doxyrest-title-code-block void normalize() Normalizes the :ref:`URI ` by removing all but leading . and .. segments from the path. If the first path segment in a relative path contains a colon (:), such as in a Windows path containing a drive letter, a dot segment (./) is prepended in accordance with section 3.3 of RFC 3986. .. index:: pair: function; getPathSegments .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a9cd0275e2e61017c677bf2c933fd8b36: .. ref-code-block:: cpp :class: doxyrest-title-code-block void getPathSegments(std::vector& segments) Places the single path segments (delimited by slashes) into the given vector. .. index:: pair: function; getLastPathSegment .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1adc95e7a63cf88d6cf0099658151b4cf1: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string getLastPathSegment() .. rubric:: Returns: The last path segment if any .. index:: pair: function; getAuthorityAndPath .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a52e9c284695a77131938dca9d73d56fb: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string getAuthorityAndPath() const .. rubric:: Returns: The authority and path .. index:: pair: function; encode .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1a2e838229b976c890dc453b3b9264fd39: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void encode(const std::string& str, const std::string& reserved, std::string& encodedStr) URI-encodes the given string by escaping reserved and non-ASCII characters. The encoded string is appended to encodedStr. .. index:: pair: function; decode .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ae3042c489307c47778da5a2f23178c18: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void decode(const std::string& str, std::string& decodedStr) URI-decodes the given string by replacing percent-encoded characters with the actual character. The decoded string is appended to decodedStr. .. index:: pair: function; encode .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1ad11d4663f3eaeea30764edcee8a05485: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string encode(const std::string& str) :ref:`URI ` encodes the string. .. index:: pair: function; decode .. _doxid-class_e_e_1_1_network_1_1_u_r_i_1af5ff90c802a672398dab8845d8d29ecb: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string decode(const std::string& str) :ref:`URI ` decodes the string.