Description
Immutable RDF IRI values, represented by their exact validated UTF-8 bytes.
RDF compares IRIs codepoint by codepoint and applies no normalisation of any kind, so this type stores what it was given and returns it unchanged. Admission is RFC 3987 as implemented by Flyology_IRI in IRI_Syntax, plus a requirement that the reference be absolute. See docs/iri-strictness.md for the differential evidence behind that choice.
The exact bytes are the whole representation. Component offsets are deliberately not retained: a document holds hundreds of thousands of these, and nothing in the RDF model asks an IRI for its authority or its path.
"="
function "=" (Left, Right : IRI) return Boolean
Compare two IRIs by their exact UTF-8 bytes.
Parameters
- Left
First IRI
- Right
Second IRI
Return value
True exactly when both byte strings are equal
Byte_Length
function Byte_Length (Value : IRI) return Natural
Return the encoded length without constructing a String copy.
Parameters
- Value
IRI to inspect
Return value
Number of UTF-8 bytes, not Unicode scalar values
From_UTF_8
function From_UTF_8 (Value : String) return IRI
Construct an IRI from exact UTF-8 bytes.
Parameters
- Value
Bytes to validate and preserve
Return value
An IRI containing exactly Value
Raised exceptions
- Invalid_UTF_8
Value is malformed, truncated, overlong, a surrogate, or out of range
- Invalid_IRI
Value is well-formed UTF-8 but is not an absolute IRI, or exceeds Maximum_IRI_Bytes
Invalid_IRI
Invalid_IRI : exception;
Raised when validated UTF-8 is not an absolute RFC 3987 IRI.
Invalid_UTF_8
Invalid_UTF_8 : exception;
Raised when input is not a canonical UTF-8 encoding of Unicode scalar values.
IRI
type IRI (<>) is private;
An immutable RDF IRI value. Equality compares the exact validated UTF-8 bytes and performs no Unicode or IRI normalisation.
Is_Valid
function Is_Valid (Value : String) return Boolean
Test the admission rule without constructing an IRI or raising.
Parameters
- Value
Candidate bytes
Return value
True exactly when From_UTF_8 would succeed
Maximum_IRI_Bytes
Maximum_IRI_Bytes : constant Positive := 1_048_576;
Largest IRI this crate will admit, in encoded bytes.
Resolve
function Resolve (Base : IRI; Reference : String) return IRI
Resolve a possibly relative reference against an absolute base, using RFC 3986 section 5.2 merging and dot-segment removal.
Parameters
- Base
Absolute base IRI
- Reference
Reference to resolve, absolute or relative
Return value
The resolved absolute IRI
Raised exceptions
- Invalid_IRI
Reference is malformed, or the resolved result is not an absolute IRI
To_UTF_8
function To_UTF_8 (Value : IRI) return String
Return an independent copy of the exact bytes supplied at construction.
Parameters
- Value
IRI to inspect
Return value
Exact validated UTF-8 bytes of Value