Public Member Functions | List of all members
StringUri Class Reference

An immediate string pseudo-URI. More...

#include <StringUri.hpp>

Inheritance diagram for StringUri:
[legend]
Collaboration diagram for StringUri:
[legend]

Public Member Functions

 StringUri ()=default
 Create an empty String URI. More...
 
 StringUri (std::string data_)
 Create a String URI with the supplied string data. More...
 
 StringUri (const StringUri &copy)=default
 Create an HTTP URI by copying the supplied instance. More...
 
 StringUri (StringUri &&rhs) noexcept=default
 Create an HTTP URI by moving the contents of the supplied instance. More...
 
StringUriappend (std::string_view text)
 Append the supplied text to the internal string data. More...
 
StringUriappend (char c)
 Append the supplied ascii character to the internal string data. More...
 
StringUriappend (char32_t c)
 Append the supplied code point to the internal string data. More...
 
std::unique_ptr< Uriappend (const std::string &pathComponent) const override
 Appends the path component to the supplied URI, returning a new URI. More...
 
std::unique_ptr< ByteReadResourcebyteReadResource () const override
 Get a byte read resource for the URI. More...
 
std::unique_ptr< ByteWriteResourcebyteWriteResource () override
 Get a byte write resource for the URI. More...
 
bool canReadFrom () const override
 Can data be read from the URI via a read resource. More...
 
bool canWriteTo () const override
 Can data be written to the URI via a write resource. More...
 
std::unique_ptr< Uriclone () const override
 Clone the concrete Uri. More...
 
void dispatch (UriDispatcher &dispatcher) const override
 Visitor pattern dispatching. More...
 
StringUriByteReadResource getByteReadResource () const
 Get a byte read resource for the HTTP source. More...
 
const std::string & getString () const
 Get a const reference to the string data of the String URI. More...
 
StringUriUtf8To32ReadResource getUtf8To32ReadResource () const
 Get a UTF-8 to UTF-32 read resource for the HTTP source. More...
 
size_t hashcode () const noexcept override
 Get the URI's hash code. More...
 
bool isIterable () const override
 Does the URI have a non-recursive iterator (examples: file and zip archive URIs). More...
 
bool isRecursivelyIterable () const override
 Does the URI have a recursive iterator (examples: file and zip archive URIs). More...
 
bool isRegularDirectory () const override
 Returns true if the URI points to a file directory. More...
 
bool isRegularFile () const override
 Returns true if the URI is a regular file. More...
 
std::unique_ptr< UriIteratoriterator () const override
 Get a (non-recursive) iterator. More...
 
bool operator== (const Uri &rhs) const override
 Compare the supplied URI to the current URI. More...
 
std::unique_ptr< RecursiveUriIteratorrecursiveIterator () const override
 Get a recursive iterator. More...
 
std::unique_ptr< Uriresolve (std::string_view path) const override
 Resolve the relative or absolute path, in reference to the current URI. More...
 
std::string toRawString () const override
 Get a string representing the raw URI. More...
 
std::string toUriString () const override
 Get a string representing the URI, complete with scheme. More...
 
std::unique_ptr< Utf32To8WriteResourceutf32To8WriteResource () override
 Get a UTF-32 to UTF-8 write resource for the URI. More...
 
std::unique_ptr< Utf8To32ReadResourceutf8To32ReadResource () const override
 Get a UTF-8 to UTF-32 read resource for the URI. More...
 
- Public Member Functions inherited from Uri
virtual ~Uri ()=default
 Destroy the URI instance. More...
 
std::shared_ptr< UricloneToShared () const
 Clone the concrete Uri to a shared pointer. More...
 

Detailed Description

An immediate string pseudo-URI.

Unlike other resource URIs, the String URI is a pseudo-URI that specifies a immediate data available from the read resource streams. As such, String URIs do not designate a remote resource that will be read. Instead, string data internal to the String URI will be implicitly read.

String URIs are a convenience mechanism that allows the abstraction of a byte, UTF-8, or UTF-32 data source to be specified via a pointer to the abstract URI class. They are thus not compliant with the Universal Resource Identifier specification.

The URI of a String URI is always "string:". Note that String URI equality is based on the internal data and not the URI contents (which is identical for all String UIRs).

Todo:
Create String URI write resources

Constructor & Destructor Documentation

◆ StringUri() [1/4]

StringUri ( )
default

Create an empty String URI.

The internal string can be appended by calling the append() method.

◆ StringUri() [2/4]

StringUri ( std::string  data_)
inlineexplicit

Create a String URI with the supplied string data.

◆ StringUri() [3/4]

StringUri ( const StringUri copy)
default

Create an HTTP URI by copying the supplied instance.

◆ StringUri() [4/4]

StringUri ( StringUri &&  rhs)
defaultnoexcept

Create an HTTP URI by moving the contents of the supplied instance.

Member Function Documentation

◆ append() [1/4]

StringUri& append ( std::string_view  text)
inline

Append the supplied text to the internal string data.

Parameters
texta view onto the text to append
Returns
the current object, allowing chaining calls to be made

◆ append() [2/4]

StringUri& append ( char  c)
inline

Append the supplied ascii character to the internal string data.

Parameters
cthe character to append
Returns
the current object, allowing chaining calls to be made

◆ append() [3/4]

StringUri& append ( char32_t  c)
inline

Append the supplied code point to the internal string data.

Parameters
cthe code point to append
Returns
the current object, allowing chaining calls to be made

◆ append() [4/4]

std::unique_ptr<Uri> append ( const std::string &  pathComponent) const
inlineoverridevirtual

Appends the path component to the supplied URI, returning a new URI.

If the URI type does not permit appending of path components, UnsupportedOperationException is thrown.

Implements Uri.

◆ byteReadResource()

std::unique_ptr<ByteReadResource> byteReadResource ( ) const
inlineoverridevirtual

Get a byte read resource for the URI.

Exceptions
NotImplementedExceptionif the URI does not support reading
ResourceExceptionif the resource could not be created

Implements Uri.

◆ byteWriteResource()

std::unique_ptr<ByteWriteResource> byteWriteResource ( )
inlineoverridevirtual

Get a byte write resource for the URI.

Exceptions
NotImplementedExceptionif the URI does not support writing
ResourceExceptionif the resource could not be created

Implements Uri.

◆ canReadFrom()

bool canReadFrom ( ) const
inlineoverridevirtual

Can data be read from the URI via a read resource.

Implements Uri.

◆ canWriteTo()

bool canWriteTo ( ) const
inlineoverridevirtual

Can data be written to the URI via a write resource.

Implements Uri.

◆ clone()

std::unique_ptr<Uri> clone ( ) const
inlineoverridevirtual

Clone the concrete Uri.

Returns
a clone of the URI

Implements Uri.

◆ dispatch()

void dispatch ( UriDispatcher visitor) const
inlineoverridevirtual

Visitor pattern dispatching.

Parameters
visitorthe visitor to visit

Implements Uri.

◆ getByteReadResource()

StringUriByteReadResource getByteReadResource ( ) const
inline

Get a byte read resource for the HTTP source.

◆ getString()

const std::string& getString ( ) const
inline

Get a const reference to the string data of the String URI.

Returns
a reference to the string data

◆ getUtf8To32ReadResource()

StringUriUtf8To32ReadResource getUtf8To32ReadResource ( ) const
inline

Get a UTF-8 to UTF-32 read resource for the HTTP source.

◆ hashcode()

size_t hashcode ( ) const
inlineoverridevirtualnoexcept

Get the URI's hash code.

Returns
the hash code

Implements Uri.

◆ isIterable()

bool isIterable ( ) const
inlineoverridevirtual

Does the URI have a non-recursive iterator (examples: file and zip archive URIs).

Implements Uri.

◆ isRecursivelyIterable()

bool isRecursivelyIterable ( ) const
inlineoverridevirtual

Does the URI have a recursive iterator (examples: file and zip archive URIs).

Implements Uri.

◆ isRegularDirectory()

bool isRegularDirectory ( ) const
inlineoverridevirtual

Returns true if the URI points to a file directory.

Returns
true if the URI points to a file directory

Implements Uri.

◆ isRegularFile()

bool isRegularFile ( ) const
inlineoverridevirtual

Returns true if the URI is a regular file.

Returns
true if the URI is a regular file

Implements Uri.

◆ iterator()

std::unique_ptr<UriIterator> iterator ( ) const
inlineoverridevirtual

Get a (non-recursive) iterator.

This will throw a NotImplementedException if the URI does not have an iterator.

Implements Uri.

◆ operator==()

bool operator== ( const Uri rhs) const
inlineoverridevirtual

Compare the supplied URI to the current URI.

Returns
true if the supplied URI is equal to the current URI.

Implements Uri.

◆ recursiveIterator()

std::unique_ptr<RecursiveUriIterator> recursiveIterator ( ) const
inlineoverridevirtual

Get a recursive iterator.

This will throw a NotImplementedException if the URI does not have a recursive iterator.

Implements Uri.

◆ resolve()

std::unique_ptr<Uri> resolve ( std::string_view  path) const
inlineoverridevirtual

Resolve the relative or absolute path, in reference to the current URI.

If the supplied path contains a scheme prefix, the URI fromString function will be called to create a new unrelated URI instance.

This method will determine the base path to use by applying the following rules.

  • If the URI path ends with a forward slash (or is a directory for file URIs), the base path is the URI path.
  • Otherwise, the rightmost path element is stripped from the URI path to form the base path.
Parameters
patha relative or absolute path, or a full URI
Returns
a new URI

Implements Uri.

◆ toRawString()

std::string toRawString ( ) const
inlineoverridevirtual

Get a string representing the raw URI.

This may or may not be the same as the string returned by toUriString().

Returns
a string representing the raw URI

Implements Uri.

◆ toUriString()

std::string toUriString ( ) const
inlineoverridevirtual

Get a string representing the URI, complete with scheme.

Returns
a string representing the URI, complete with scheme

Implements Uri.

◆ utf32To8WriteResource()

std::unique_ptr<Utf32To8WriteResource> utf32To8WriteResource ( )
inlineoverridevirtual

Get a UTF-32 to UTF-8 write resource for the URI.

Exceptions
NotImplementedExceptionif the URI does not support writing
ResourceExceptionif the resource could not be created

Implements Uri.

◆ utf8To32ReadResource()

std::unique_ptr<Utf8To32ReadResource> utf8To32ReadResource ( ) const
inlineoverridevirtual

Get a UTF-8 to UTF-32 read resource for the URI.

Exceptions
NotImplementedExceptionif the URI does not support reading
ResourceExceptionif the resource could not be created

Implements Uri.


The documentation for this class was generated from the following file: