xtd 0.2.0
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
309
322
336
357
364
370
375
383
387 bool is_absolute_uri() const;
388
392 bool is_default_port() const;
393
398 bool is_file() const;
399
404 bool is_loopback() const;
405
410 bool is_unc() const;
411
421
431
439
444 int32 port() const;
445
453
475
495
502
504
506
517
539
559 bool is_base_of(const xtd::uri& uri) const;
560
577
581 bool equals(const xtd::object& obj) const noexcept override;
585 bool equals(const xtd::uri& uri) const noexcept override;
586
589 xtd::size get_hash_code() const noexcept override;
590
594 xtd::string to_string() const noexcept override;
596
598
605 static bool check_scheme_name(const xtd::string& scheme);
606
616 static xtd::string escape_data_string(const xtd::string& value);
617
628 static xtd::string escape_uri_string(const xtd::string& value);
629
635 static int32 from_hex(char digit);
636
641 static xtd::string hex_escape(char character);
642
648 static char hex_unescape(const xtd::string& pattern, size_t& index);
649
654 static bool is_hex_digit(char character);
655
661 static bool is_hex_encoding(const xtd::string& pattern, size_t index);
662
678 static bool is_well_formed_uri_string(const xtd::string& uri_string, xtd::uri_kind uri_kind);
679
686 static xtd::string unescape_data_string(const xtd::string& value);
688
689 private:
690 static string format_componant(const string& str, uri_format format);
691 static string format_host_componant(const string& str, uri_format format);
692 static bool need_to_escape_data_char(char character);
693 static bool need_to_escape_uri_char(char character);
694 void set_fragment(xtd::string& escapeUri);
695 void set_host(xtd::string& escapeUri);
696 void set_path(xtd::string& escapeUri);
697 void set_port(xtd::string& escapeUri);
698 void set_query(xtd::string& escapeUri);
699 void set_scheme(xtd::string& escapeUri);
700 void set_uri(const xtd::string& uri, xtd::uri_kind kind);
701 void set_user_info(xtd::string& escapeUri);
702
703 struct data {
704 xtd::string original_uri;
714 };
715 ptr<data> data_ = new_ptr<data>();
716 };
717}
718
719#include "literals/uri.hpp"
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
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
xtd::string local_path() const
Gets the original URI string that was passed to the xtd::uri constructor.
static xtd::string hex_escape(char character)
Converts a specified character into its hexadecimal equivalent.
bool is_absolute_uri() const
Gets whether the xtd::uri instance is absolute.
xtd::string dns_safe_host() const
Gets an unescaped host name that is safe to use for DNS resolution.
bool equals(const xtd::object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
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
xtd::string user_info() const
Gets the user name, password, or other user-specific information associated with the specified URI.
static xtd::string escape_data_string(const xtd::string &value)
Converts a string to its escaped representation.
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
uri()=default
Initializes a new instance of the xtd::uri class.
bool is_loopback() const
Gets whether the specified xtd::uri references the local host.
static xtd::string unescape_data_string(const xtd::string &value)
Converts a string to its unescaped representation.
xtd::string absolute_uri()
Gets the absolute URI.
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 const xtd::string scheme_delimiter
Specifies the characters that separate the communication protocol scheme from the address portion of ...
Definition uri.hpp:120
xtd::string get_left_part(xtd::uri_partial part) const
Gets the specified portion of a xtd::uri instance.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
xtd::string query() const
Gets any query information included in the specified URI.
xtd::string fragment() const
Gets the escaped URI fragment.
static bool is_hex_digit(char character)
Determines whether a specified character is a valid hexadecimal digit.
static bool check_scheme_name(const xtd::string &scheme)
Determines whether the specified scheme name is valid.
xtd::string to_string() const noexcept override
Gets a canonical string representation for the specified xtd::uri instance.
static bool is_hex_encoding(const xtd::string &pattern, size_t index)
Determines whether a character in a string is hexadecimal encoded.
xtd::string authority() const
Gets the Domain Name System (DNS) host name or IP address and the port number for a server.
uri(const xtd::string &uri_string)
Initializes a new instance of the xtd::uri class with the specified URI.
xtd::string absolute_path() const
Gets the absolute path of the URI.
xtd::string idn_host() const
Gets the RFC 3490 compliant International Domain Name of the host, using Punycode as appropriate....
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
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
xtd::string path_and_query() const
Gets the absolute_path and query properties separated by a question mark (?).
xtd::array< xtd::string > segments() const
Gets an array containing the path segments that make up the specified URI.
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...
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
bool is_default_port() const
Gets whether the port value of the URI is the default for this scheme.
bool equals(const xtd::uri &uri) const noexcept override
Determines whether the specified object is equal to the current object.
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
bool is_file() const
Gets a value indicating whether the specified xtd::uri is a file URI.
xtd::string get_components(xtd::uri_components components, xtd::uri_format format) const
Gets the specified components of the current instance using the specified escaping for special charac...
bool is_base_of(const xtd::uri &uri) const
Determines whether the current xtd::uri instance is a base of the specified xtd::uri instance.
xtd::string host() const
Gets the host component of this instance.
bool is_well_formed_original_string()
Indicates whether the string used to construct this xtd::uri was well-formed and is not required to b...
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 int32 from_hex(char digit)
Gets the decimal value of a hexadecimal digit.
xtd::string scheme() const
Gets the scheme name for this URI.
static bool is_well_formed_uri_string(const xtd::string &uri_string, xtd::uri_kind uri_kind)
Indicates whether the string is well-formed by attempting to construct a URI with the string and ensu...
static char hex_unescape(const xtd::string &pattern, size_t &index)
Converts a specified hexadecimal representation of a character to the character.
int32 port() const
Gets the port number of this URI.
static const xtd::string uri_scheme_https
Specifies that the URI is accessed through the Hypertext Transfer Protocol (HTTPS)....
Definition uri.hpp:175
const xtd::string & original_string() const
Gets the original URI string that was passed to the xtd::uri constructor.
static const xtd::string uri_scheme_http
Specifies that the URI is accessed through the Hypertext Transfer Protocol (HTTP)....
Definition uri.hpp:165
static xtd::string escape_uri_string(const xtd::string &value)
Converts a URI string to its escaped representation.
bool is_unc() const
Gets whether the specified xtd::uri is a universal naming convention (UNC) path.
xtd::uri_host_name_type host_name_type() const
Gets the type of the host name specified in the URI.
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 ...
xtd::string format(const xtd::string &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:20
#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
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
uri_components
This enumeration has a Flags attribute that allows a bitwise combination of its member values.
Definition uri_components.hpp:15
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
uri_format
Controls how URI information is escaped.
Definition uri_format.hpp:17
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.