xtd 0.2.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
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::string> segments() const;
495
502
504
506
517
539
559 bool is_base_of(const xtd::uri& uri) const;
560
577
578 using object::equals;
579 bool equals(const xtd::uri& uri) const noexcept override;
580
584 xtd::string to_string() const noexcept override;
586
588
595 static bool check_scheme_name(const xtd::string& scheme);
596
606 static xtd::string escape_data_string(const xtd::string& value);
607
618 static xtd::string escape_uri_string(const xtd::string& value);
619
625 static int32 from_hex(char digit);
626
631 static xtd::string hex_escape(char character);
632
638 static char hex_unescape(const xtd::string& pattern, size_t& index);
639
644 static bool is_hex_digit(char character);
645
651 static bool is_hex_encoding(const xtd::string& pattern, size_t index);
652
668 static bool is_well_formed_uri_string(const xtd::string& uri_string, xtd::uri_kind uri_kind);
669
676 static xtd::string unescape_data_string(const xtd::string& value);
678
679 private:
680 static string format_componant(const string& str, uri_format format);
681 static string format_host_componant(const string& str, uri_format format);
682 static bool need_to_escape_data_char(char character);
683 static bool need_to_escape_uri_char(char character);
684 void set_fragment(xtd::string& escapeUri);
685 void set_host(xtd::string& escapeUri);
686 void set_path(xtd::string& escapeUri);
687 void set_port(xtd::string& escapeUri);
688 void set_query(xtd::string& escapeUri);
689 void set_scheme(xtd::string& escapeUri);
690 void set_uri(const xtd::string& uri, xtd::uri_kind kind);
691 void set_user_info(xtd::string& escapeUri);
692
693 xtd::string original_uri_;
694 xtd::string scheme_;
695 xtd::string scheme_delimiter_;
696 xtd::string user_info_;
697 xtd::string host_;
698 xtd::string port_;
699 xtd::string path_;
700 xtd::string query_;
701 xtd::string fragment_;
702 xtd::uri_kind kind_ = xtd::uri_kind::absolute;
703 };
704}
Represents text as a sequence of character units.
Definition basic_string.hpp:79
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:42
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
Definition uri.hpp:103
xtd::string local_path() 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.
xtd::string dns_safe_host() const
Gets an unescaped host name that is safe to use for DNS resolution.
xtd::string user_info() const
Gets the user name, password, or other user-specific information associated with the specified URI.
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.
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...
xtd::string get_left_part(xtd::uri_partial part) const
Gets the specified portion of a xtd::uri instance.
xtd::string query() const
Gets any query information included in the specified URI.
xtd::string fragment() const
Gets the escaped URI fragment.
xtd::string to_string() const noexcept override
Gets a canonical string representation for the specified xtd::uri instance.
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....
xtd::string path_and_query() const
Gets the absolute_path and query properties separated by a question mark (?).
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...
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
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::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...
std::vector< xtd::string > segments() const
Gets an array containing the path segments that make up the specified URI.
xtd::string scheme() const
Gets the scheme name for this URI.
int32 port() const
Gets the port number of this URI.
const xtd::string & original_string() const
Gets the original URI string that was passed to the xtd::uri constructor.
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 ...
#define core_export_
Define shared library export.
Definition core_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
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
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
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
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.