xtd 0.2.0
Loading...
Searching...
No Matches
uri.h
Go to the documentation of this file.
1
4#pragma once
5#include "iequatable.h"
6#include "uri_components.h"
7#include "uri_format.h"
9#include "uri_kind.h"
10#include "uri_partial.h"
11#include "ustring.h"
12
14namespace xtd {
103 class core_export_ uri : public xtd::iequatable<uri>, public xtd::object {
104 public:
106
120 inline static const xtd::ustring scheme_delimiter = "://";
121
130 inline static const xtd::ustring uri_scheme_file = "file";
131
140 inline static const xtd::ustring uri_scheme_ftp = "ftp";
141
150 inline static const xtd::ustring uri_scheme_gopher = "gopher";
151
165 inline static const xtd::ustring uri_scheme_http = "http";
166
175 inline static const xtd::ustring uri_scheme_https = "https";
176
185 inline static const xtd::ustring uri_scheme_mailto = "mailto";
186
188 inline static const xtd::ustring uri_scheme_net_pipe = "net.pipe";
189
191 inline static const xtd::ustring uri_scheme_net_tcp = "net.tcp";
192
201 inline static const xtd::ustring uri_scheme_news = "news";
202
211 inline static const xtd::ustring 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::ustring& uri_string);
237
244
261 uri(const uri& base_uri, const xtd::ustring& 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
494 std::vector<xtd::ustring> segments() const;
495
502
504
506
517
539
559 bool is_base_of(const xtd::uri& uri) const;
560
577
578 bool equals(const xtd::uri& uri) const noexcept override;
579
583 xtd::ustring to_string() const noexcept override;
585
587
594 static bool check_scheme_name(const xtd::ustring& scheme);
595
605 static xtd::ustring escape_data_string(const xtd::ustring& value);
606
617 static xtd::ustring escape_uri_string(const xtd::ustring& value);
618
624 static int32 from_hex(char digit);
625
630 static xtd::ustring hex_escape(char character);
631
637 static char hex_unescape(const xtd::ustring& pattern, size_t& index);
638
643 static bool is_hex_digit(char character);
644
650 static bool is_hex_encoding(const xtd::ustring& pattern, size_t index);
651
667 static bool is_well_formed_uri_string(const xtd::ustring& uri_string, xtd::uri_kind uri_kind);
668
675 static xtd::ustring unescape_data_string(const xtd::ustring& value);
677
678 private:
679 static ustring format_componant(const ustring& str, uri_format format);
680 static ustring format_host_componant(const ustring& str, uri_format format);
681 static bool need_to_escape_data_char(char character);
682 static bool need_to_escape_uri_char(char character);
683 void set_fragment(xtd::ustring& escapeUri);
684 void set_host(xtd::ustring& escapeUri);
685 void set_path(xtd::ustring& escapeUri);
686 void set_port(xtd::ustring& escapeUri);
687 void set_query(xtd::ustring& escapeUri);
688 void set_scheme(xtd::ustring& escapeUri);
689 void set_uri(const xtd::ustring& uri, xtd::uri_kind kind);
690 void set_user_info(xtd::ustring& escapeUri);
691
692 xtd::ustring original_uri_;
693 xtd::ustring scheme_;
694 xtd::ustring scheme_delimiter_;
695 xtd::ustring user_info_;
696 xtd::ustring host_;
697 xtd::ustring port_;
698 xtd::ustring path_;
699 xtd::ustring query_;
700 xtd::ustring fragment_;
701 xtd::uri_kind kind_ = xtd::uri_kind::absolute;
702 };
703}
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:18
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
Definition uri.h:103
xtd::ustring fragment() const
Gets the escaped URI fragment.
const xtd::ustring & original_string() const
Gets the original URI string that was passed to the xtd::uri constructor.
bool is_absolute_uri() const
Gets whether the xtd::uri instance is absolute.
std::vector< xtd::ustring > segments() const
Gets an array containing the path segments that make up the specified URI.
xtd::ustring 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...
uri()=default
Initializes a new instance of the xtd::uri class.
xtd::ustring path_and_query() const
Gets the absolute_path and query properties separated by a question mark (?).
bool is_loopback() const
Gets whether the specified xtd::uri references the local host.
uri(const uri &base_uri, const xtd::ustring &relative_uri)
Initializes a new instance of the xtd::uri class based on the specified base URI and relative URI str...
xtd::ustring authority() const
Gets the Domain Name System (DNS) host name or IP address and the port number for a server.
xtd::ustring absolute_path() const
Gets the absolute path of the URI.
xtd::ustring idn_host() const
Gets the RFC 3490 compliant International Domain Name of the host, using Punycode as appropriate....
xtd::ustring host() const
Gets the host component of this instance.
xtd::ustring get_left_part(xtd::uri_partial part) const
Gets the specified portion of a xtd::uri instance.
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...
uri(const xtd::ustring &uri, xtd::uri_kind uri_kind)
Initializes a new instance of the xtd::uri class with the specified URI. This constructor allows you ...
bool is_default_port() const
Gets whether the port value of the URI is the default for this scheme.
xtd::ustring scheme() const
Gets the scheme name for this URI.
xtd::ustring query() const
Gets any query information included in the specified URI.
bool equals(const xtd::uri &uri) const noexcept override
Indicates whether the current object is equal to another object of the same type.
bool is_file() const
Gets a value indicating whether the specified xtd::uri is a file URI.
xtd::ustring dns_safe_host() const
Gets an unescaped host name that is safe to use for DNS resolution.
xtd::ustring local_path() const
Gets the original URI string that was passed to the xtd::uri constructor.
xtd::ustring absolute_uri()
Gets the absolute URI.
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.
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...
xtd::ustring user_info() const
Gets the user name, password, or other user-specific information associated with the specified URI.
int32 port() const
Gets the port number of this URI.
uri(const xtd::ustring &uri_string)
Initializes a new instance of the xtd::uri class with the specified URI.
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.
xtd::ustring to_string() const noexcept override
Gets a canonical string representation for the specified xtd::uri instance.
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
#define core_export_
Define shared library export.
Definition core_export.h:13
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
uri_components
This enumeration has a Flags attribute that allows a bitwise combination of its member values.
Definition uri_components.h:15
uri_format
Controls how URI information is escaped.
Definition uri_format.h:17
uri_partial
Defines the parts of a URI for the xtd::uri::get_left_part method.
Definition uri_partial.h: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.h:19
uri_host_name_type
Defines host name types for the xtd::uri::check_host_name method.
Definition uri_host_name_type.h:15
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
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.
Contains xtd::ustring class.