17 #ifndef COM_BORA_SOFTWARE__BALAU_RESOURCE__HTTPS 18 #define COM_BORA_SOFTWARE__BALAU_RESOURCE__HTTPS 34 public:
Https() =
default;
39 public:
explicit Https(std::string uri_) :
Url(
std::move(uri_)) {}
44 public:
explicit Https(std::string_view uri_) :
Url(uri_) {}
49 public:
explicit Https(
const char * uri_) :
Url(uri_) {}
61 public: std::unique_ptr<Uri>
clone()
const override {
62 return std::unique_ptr<Uri>(
new Https(*
this));
65 public: std::unique_ptr<Uri>
append(
const std::string & pathComponent)
const override {
66 return std::unique_ptr<Uri>(
new Https(appendPathComponent(pathComponent)));
69 public: std::unique_ptr<Uri>
resolve(std::string_view path)
const override {
70 static const std::regex scheme {
"[a-zA-Z][a-zA-Z0-9+-\\.]*:" };
73 auto str = std::string(cleanPath);
76 std::unique_ptr<Uri> uri;
86 return std::unique_ptr<Uri>(
new Https(url));
91 return std::unique_ptr<Uri>(
new Https(url));
96 const auto * o =
dynamic_cast<const Https *
>(&rhs);
97 return o !=
nullptr && uri == o->uri;
109 return ::toString<AllocatorT>(uri);
154 public: std::unique_ptr<UriIterator>
iterator()
const override {
168 template <
typename AllocatorT>
175 #endif // COM_BORA_SOFTWARE__BALAU_RESOURCE__HTTPS Https(std::string uri_)
Create an HTTPS URI from the supplied URI string.
Definition: Https.hpp:39
Https(Https &&rhs) noexcept
Create an HTTPS URI by moving the contents of the supplied instance.
Definition: Https.hpp:59
bool operator==(const Uri &rhs) const override
Compare the supplied URI to the current URI.
Definition: Https.hpp:95
std::unique_ptr< UriIterator > iterator() const override
Get a (non-recursive) iterator.
Definition: Https.hpp:154
virtual void dispatch(const File &object)=0
Visit a File URI.
std::unique_ptr< ByteReadResource > byteReadResource() const override
Get a byte read resource for the URI.
Definition: Https.hpp:126
std::unique_ptr< Utf8To32ReadResource > utf8To32ReadResource() const override
Get a UTF-8 to UTF-32 read resource for the URI.
Definition: Https.hpp:130
void dispatch(UriDispatcher &dispatcher) const override
Visitor pattern dispatching.
Definition: Https.hpp:158
An HTTPS URL.
Definition: Https.hpp:30
std::unique_ptr< RecursiveUriIterator > recursiveIterator() const override
Get a recursive iterator.
Definition: Https.hpp:150
#define ThrowBalauException(ExceptionClass,...)
Throw a Balau style exception, with implicit file and line number, and optional stacktrace.
Definition: BalauException.hpp:45
void fromString(File &destination, std::string_view value)
Overwrite the supplied file URI by assignment by converting the supplied UTF-8 string to a file URI...
Definition: File.hpp:733
bool canWriteTo() const override
Can data be written to the URI via a write resource.
Definition: Https.hpp:104
An abstract universal resource identifier.
Definition: Uri.hpp:131
A read-only HTTPS resource which is read as bytes.
std::unique_ptr< Utf32To8WriteResource > utf32To8WriteResource() override
Get a UTF-32 to UTF-8 write resource for the URI.
Definition: Https.hpp:138
std::unique_ptr< Uri > clone() const override
Clone the concrete Uri.
Definition: Https.hpp:61
A read-only HTTPS UTF-8 resource which is read as UTF-32 characters.
Https(const char *uri_)
Create an HTTPS URI from the supplied URI string.
Definition: Https.hpp:49
bool canReadFrom() const override
Can data be read from the URI via a read resource.
Definition: Https.hpp:100
The unified resource class hierarchy.
Definition: ByteReadResource.hpp:24
Thrown when a feature is not yet implemented.
Definition: BalauException.hpp:162
Balau::U8String< AllocatorT > toRawString() const
Get a string representing the raw URI.
Definition: Https.hpp:108
std::string_view host() const
Obtain a string view to the host.
Definition: UriComponents.hpp:205
HttpsUtf8To32ReadResource getUtf8To32ReadResource()
Get a UTF-8 to UTF-32 read resource for the HTTPS source.
Definition: Https.hpp:122
A read-only HTTP UTF-8 resource which is read as UTF-32 characters.
Definition: HttpsUtf8To32ReadResource.hpp:35
Https(std::string_view uri_)
Create an HTTPS URI from the supplied URI string.
Definition: Https.hpp:44
Https()=default
Create a null HTTPS URI.
bool isIterable() const override
Does the URI have a non-recursive iterator (examples: file and zip archive URIs). ...
Definition: Https.hpp:146
Balau::U8String< AllocatorT > toString(const File &file)
Print the file URI as a UTF-8 string.
Definition: File.hpp:724
An abstract Url (either http or https).
HttpsByteReadResource getByteReadResource()
Get a byte read resource for the HTTPS source.
Definition: Https.hpp:115
static bool startsWith(const StringT< CharT, T ... > &str, const PrefixT &prefix)
Does the string start with the specified prefix?
Definition: Strings.hpp:46
static std::string_view trim(const std::string_view &input)
Trim whitespace from the beginning and end of the supplied UTF-8 string.
Definition: Strings.hpp:706
std::unique_ptr< Uri > resolve(std::string_view path) const override
Resolve the relative or absolute path, in reference to the current URI.
Definition: Https.hpp:69
bool isRecursivelyIterable() const override
Does the URI have a recursive iterator (examples: file and zip archive URIs).
Definition: Https.hpp:142
Base Balau exception classes.
std::basic_string< char, std::char_traits< char >, AllocatorT > U8String
UTF-8 string type with selectable allocator.
Definition: ToStringA.hpp:41
std::unique_ptr< Uri > append(const std::string &pathComponent) const override
Appends the path component to the supplied URI, returning a new URI.
Definition: Https.hpp:65
std::string_view scheme() const
Obtain a string view to the scheme.
Definition: UriComponents.hpp:177
std::string_view path() const
Obtain a string view to the path.
Definition: UriComponents.hpp:234
static bool startsWithRegex(const std::string &str, const std::regex &prefix)
Does the string start with the specified regular expression?
Definition: Strings.hpp:94
A read-only HTTP resource which is read as bytes.
Definition: HttpsByteReadResource.hpp:33
std::unique_ptr< ByteWriteResource > byteWriteResource() override
Get a byte write resource for the URI.
Definition: Https.hpp:134
An abstract Url (either http or https).
Definition: Url.hpp:28
Visitor interface for URIs.
Definition: UriDispatcher.hpp:32
Parses a URI and provides views into the URI's components.
Definition: UriComponents.hpp:52