xtd 1.0.0
Loading...
Searching...
No Matches
uri.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "iequatable.hpp"
6#include "uri_components.hpp"
7#include "uri_format.hpp"
9#include "uri_kind.hpp"
10#include "uri_partial.hpp"
11#include "string.hpp"
12
14namespace xtd {
103 class core_export_ uri : public xtd::iequatable<uri>, public xtd::object {
104 public:
106
120 inline static const xtd::string scheme_delimiter = "://";
121
130 inline static const xtd::string uri_scheme_file = "file";
131
140 inline static const xtd::string uri_scheme_ftp = "ftp";
141
150 inline static const xtd::string uri_scheme_gopher = "gopher";
151
165 inline static const xtd::string uri_scheme_http = "http";
166
175 inline static const xtd::string uri_scheme_https = "https";
176
185 inline static const xtd::string uri_scheme_mailto = "mailto";
186
188 inline static const xtd::string uri_scheme_net_pipe = "net.pipe";
189
191 inline static const xtd::string uri_scheme_net_tcp = "net.tcp";
192
201 inline static const xtd::string uri_scheme_news = "news";
202
211 inline static const xtd::string uri_scheme_nntp = "nntp";
213
215
218 uri() = default;
219
221 uri(const xtd::uri& uri) = default;
222 uri& operator =(const uri&) = default;
224
236 explicit uri(const xtd::string& uri_string);
237
244
261 uri(const uri& base_uri, const xtd::string& relative_uri);
262
289 uri(const uri& base_uri, const uri& relative_uri);
291
293
308 [[nodiscard]] auto absolute_path() const -> xtd::string;
309
321 [[nodiscard]] auto absolute_uri() -> xtd::string;
322
335 [[nodiscard]] auto authority() const -> xtd::string;
336
356 [[nodiscard]] auto dns_safe_host() const -> xtd::string;
357
363 [[nodiscard]] auto fragment() const -> xtd::string;
364
369 [[nodiscard]] auto host() const -> xtd::string;
370
374 [[nodiscard]] auto host_name_type() const -> xtd::uri_host_name_type;
375
382 [[nodiscard]] auto idn_host() const -> xtd::string;
383
387 [[nodiscard]] auto is_absolute_uri() const -> bool;
388
392 [[nodiscard]] auto is_default_port() const -> bool;
393
398 [[nodiscard]] auto is_file() const -> bool;
399
404 [[nodiscard]] auto is_loopback() const -> bool;
405
410 [[nodiscard]] auto is_unc() const -> bool;
411
420 [[nodiscard]] auto local_path() const -> xtd::string;
421
430 [[nodiscard]] auto original_string() const -> const xtd::string&;
431
438 [[nodiscard]] auto path_and_query() const -> xtd::string;
439
444 [[nodiscard]] auto port() const -> xtd::int32;
445
452 [[nodiscard]] auto query() const -> xtd::string;
453
474 [[nodiscard]] auto scheme() const -> xtd::string;
475
494 [[nodiscard]] auto segments() const -> xtd::array<xtd::string>;
495
500 [[nodiscard]] auto user_info() const -> xtd::string;
502
504
506
516 [[nodiscard]] auto get_components(xtd::uri_components components, xtd::uri_format format) const -> xtd::string;
517
538 [[nodiscard]] auto get_left_part(xtd::uri_partial part) const -> xtd::string;
539
558 [[nodiscard]] auto is_base_of(const xtd::uri& uri) const -> bool;
559
575 [[nodiscard]] auto is_well_formed_original_string() -> bool;
576
580 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
584 [[nodiscard]] auto equals(const xtd::uri& uri) const noexcept -> bool override;
585
588 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
589
593 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
595
597
604 [[nodiscard]] static auto check_scheme_name(const xtd::string& scheme) -> bool;
605
614 [[nodiscard]] static auto escape_data_string(const xtd::string& value) -> xtd::string;
615
625 [[nodiscard]] static auto escape_uri_string(const xtd::string& value) -> xtd::string;
626
632 [[nodiscard]] static auto from_hex(char digit) -> xtd::int32;
633
638 [[nodiscard]] static auto hex_escape(char character) -> xtd::string;
639
645 [[nodiscard]] static auto hex_unescape(const xtd::string& pattern, xtd::usize& index) -> char;
646
651 [[nodiscard]] static auto is_hex_digit(char character) -> bool;
652
658 [[nodiscard]] static auto is_hex_encoding(const xtd::string& pattern, xtd::usize index) -> bool;
659
675 [[nodiscard]] static auto is_well_formed_uri_string(const xtd::string& uri_string, xtd::uri_kind uri_kind) -> bool;
676
682 [[nodiscard]] static auto unescape_data_string(const xtd::string& value) -> xtd::string;
684
685 private:
686 [[nodiscard]] static auto format_componant(const xtd::string& str, xtd::uri_format format) -> xtd::string;
687 [[nodiscard]] static auto format_host_componant(const xtd::string& str, xtd::uri_format format) -> xtd::string;
688 [[nodiscard]] static auto need_to_escape_data_char(char character) -> bool;
689 [[nodiscard]] static auto need_to_escape_uri_char(char character) -> bool;
690 auto set_fragment(xtd::string& escapeUri) -> void;
691 auto set_host(xtd::string& escapeUri) -> void;
692 auto set_path(xtd::string& escapeUri) -> void;
693 auto set_port(xtd::string& escapeUri) -> void;
694 auto set_query(xtd::string& escapeUri) -> void;
695 auto set_scheme(xtd::string& escapeUri) -> void;
696 auto set_uri(const xtd::string& uri, xtd::uri_kind kind) -> void;
697 auto set_user_info(xtd::string& escapeUri) -> void;
698
699 struct data {
700 xtd::string original_uri;
710 };
711 ptr<data> data_ = new_ptr<data>();
712 };
713}
714
715#include "literals/uri.hpp"
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
Definition uri.hpp:103
static const xtd::string uri_scheme_net_tcp
Specifies that the URI is accessed through the NetTcp scheme used by Windows Communication Foundation...
Definition uri.hpp:191
auto is_base_of(const xtd::uri &uri) const -> bool
Determines whether the current xtd::uri instance is a base of the specified xtd::uri instance.
static auto is_well_formed_uri_string(const xtd::string &uri_string, xtd::uri_kind uri_kind) -> bool
Indicates whether the string is well-formed by attempting to construct a URI with the string and ensu...
auto idn_host() const -> xtd::string
Gets the RFC 3490 compliant International Domain Name of the host, using Punycode as appropriate....
auto dns_safe_host() const -> xtd::string
Gets an unescaped host name that is safe to use for DNS resolution.
static auto check_scheme_name(const xtd::string &scheme) -> bool
Determines whether the specified scheme name is valid.
auto get_components(xtd::uri_components components, xtd::uri_format format) const -> xtd::string
Gets the specified components of the current instance using the specified escaping for special charac...
static const xtd::string uri_scheme_nntp
Specifies that the URI is an Internet news group and is accessed through the Network News Transport P...
Definition uri.hpp:211
auto local_path() const -> xtd::string
Gets the original URI string that was passed to the xtd::uri constructor.
auto path_and_query() const -> xtd::string
Gets the absolute_path and query properties separated by a question mark (?).
auto host() const -> xtd::string
Gets the host component of this instance.
auto original_string() const -> const xtd::string &
Gets the original URI string that was passed to the xtd::uri constructor.
auto is_well_formed_original_string() -> bool
Indicates whether the string used to construct this xtd::uri was well-formed and is not required to b...
auto to_string() const noexcept -> xtd::string override
Gets a canonical string representation for the specified xtd::uri instance.
auto host_name_type() const -> xtd::uri_host_name_type
Gets the type of the host name specified in the URI.
static const xtd::string uri_scheme_ftp
Specifies that the URI is accessed through the File Transfer Protocol (FTP). This field is read-only.
Definition uri.hpp:140
auto absolute_uri() -> xtd::string
Gets the absolute URI.
uri()=default
Initializes a new instance of the xtd::uri class.
static auto hex_escape(char character) -> xtd::string
Converts a specified character into its hexadecimal equivalent.
uri(const uri &base_uri, const xtd::string &relative_uri)
Initializes a new instance of the xtd::uri class based on the specified base URI and relative URI str...
static auto is_hex_digit(char character) -> bool
Determines whether a specified character is a valid hexadecimal digit.
auto is_file() const -> bool
Gets a value indicating whether the specified xtd::uri is a file URI.
static auto from_hex(char digit) -> xtd::int32
Gets the decimal value of a hexadecimal digit.
static const xtd::string scheme_delimiter
Specifies the characters that separate the communication protocol scheme from the address portion of ...
Definition uri.hpp:120
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto is_loopback() const -> bool
Gets whether the specified xtd::uri references the local host.
auto user_info() const -> xtd::string
Gets the user name, password, or other user-specific information associated with the specified URI.
auto query() const -> xtd::string
Gets any query information included in the specified URI.
uri(const xtd::string &uri_string)
Initializes a new instance of the xtd::uri class with the specified URI.
auto port() const -> xtd::int32
Gets the port number of this URI.
static const xtd::string uri_scheme_net_pipe
Specifies that the URI is accessed through the NetPipe scheme used by Windows Communication Foundatio...
Definition uri.hpp:188
auto equals(const xtd::object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
static const xtd::string uri_scheme_file
Specifies that the URI is a pointer to a file. This field is read-only.
Definition uri.hpp:130
uri(const uri &base_uri, const uri &relative_uri)
Initializes a new instance of the xtd::uri class based on the combination of a specified base xtd::ur...
auto scheme() const -> xtd::string
Gets the scheme name for this URI.
auto get_left_part(xtd::uri_partial part) const -> xtd::string
Gets the specified portion of a xtd::uri instance.
static const xtd::string uri_scheme_news
Specifies that the URI is an Internet news group and is accessed through the Network News Transport P...
Definition uri.hpp:201
static const xtd::string uri_scheme_mailto
Specifies that the URI is an e-mail address and is accessed through the Simple Mail Transport Protoco...
Definition uri.hpp:185
auto authority() const -> xtd::string
Gets the Domain Name System (DNS) host name or IP address and the port number for a server.
static auto unescape_data_string(const xtd::string &value) -> xtd::string
Converts a string to its unescaped representation.
static auto escape_data_string(const xtd::string &value) -> xtd::string
Converts a string to its escaped representation.
static const xtd::string uri_scheme_gopher
Specifies that the URI is accessed through the Gopher protocol. This field is read-only.
Definition uri.hpp:150
static auto hex_unescape(const xtd::string &pattern, xtd::usize &index) -> char
Converts a specified hexadecimal representation of a character to the character.
static auto escape_uri_string(const xtd::string &value) -> xtd::string
Converts a URI string to its escaped representation.
auto absolute_path() const -> xtd::string
Gets the absolute path of the URI.
auto is_unc() const -> bool
Gets whether the specified xtd::uri is a universal naming convention (UNC) path.
auto is_absolute_uri() const -> bool
Gets whether the xtd::uri instance is absolute.
auto is_default_port() const -> bool
Gets whether the port value of the URI is the default for this scheme.
static const xtd::string uri_scheme_https
Specifies that the URI is accessed through the Hypertext Transfer Protocol (HTTPS)....
Definition uri.hpp:175
auto fragment() const -> xtd::string
Gets the escaped URI fragment.
static const xtd::string uri_scheme_http
Specifies that the URI is accessed through the Hypertext Transfer Protocol (HTTP)....
Definition uri.hpp:165
auto segments() const -> xtd::array< xtd::string >
Gets an array containing the path segments that make up the specified URI.
static auto is_hex_encoding(const xtd::string &pattern, xtd::usize index) -> bool
Determines whether a character in a string is hexadecimal encoded.
uri(const xtd::string &uri, xtd::uri_kind uri_kind)
Initializes a new instance of the xtd::uri class with the specified URI. This constructor allows you ...
Definition character.hpp:17
auto format(const xtd::string &fmt, args_t &&... args) -> xtd::string
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:21
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
uri_components
This enumeration has a Flags attribute that allows a bitwise combination of its member values.
Definition uri_components.hpp:15
uri_format
Controls how URI information is escaped.
Definition uri_format.hpp:17
auto new_ptr(args_t &&... args) -> xtd::ptr< type_t >
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
uri_partial
Defines the parts of a URI for the xtd::uri::get_left_part method.
Definition uri_partial.hpp:15
uri_kind
Defines the kinds of Uris for the xtd::uri::is_well_formed_uri_string and several xtd::uri methods.
Definition uri_kind.hpp:19
uri_host_name_type
Defines host name types for the xtd::uri::check_host_name method.
Definition uri_host_name_type.hpp:15
@ path
The xtd::uri::local_path data.
Definition uri_components.hpp:27
@ absolute
The xtd::uri is an absolute xtd::uri.
Definition uri_kind.hpp:23
Contains xtd::iequatable interface.
Contains xtd::uri suffix.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::string alias.
Contains xtd::uri_components enum.
Contains xtd::uri_format enum.
Contains xtd::uri_host_name_type enum.
Contains xtd::uri_kind enum.
Contains xtd::uri_partial enum.