Struct Literal

Inheritance Relationships

Base Type

Struct Documentation

struct Literal : public rdf4cpp::Node

An RDF Literal.

Functions behave based on the following rules:

  • public transformation functions (i.e. Literal -> Literal functions, that are usually called as_*) check for null and return back a null literal

  • public is_* functions check for null and return an appropriate value for null-literals

  • other public functions (i.e. Literal -> non-Literal) usually do not check for null (e.g. Literal::lexical_form), but if the null-Literal has a meaningful value for that function it will behave correctly (e.g. for null-Literal <=> non-null-Literal)

Public Functions

Literal() noexcept

Constructs the null-literal

Literal to_node_storage(storage::DynNodeStoragePtr node_storage) const
Literal try_get_in_node_storage(storage::DynNodeStoragePtr node_storage) const noexcept
template<datatypes::LiteralDatatype T>
inline Literal as_datatype_eq(storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Checks if the datatype of this matches the provided LiteralDatatype

Note

You should prefer this function over comparing datatypes using Literal::datatype

Template Parameters:

T – the datatype to compare against

Returns:

true as xsd:boolean iff this datatype is T or null-literal if this is null

Literal as_datatype_eq(IRI const &datatype, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Checks if the datatype of this matches the given IRI

Note

You should prefer this function over comparing datatypes using Literal::datatype

Parameters:

datatype – the datatype to compare against

Returns:

true as xsd:boolean iff this datatype is datatype or null-literal if this is null

Literal as_datatype_eq(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Checks if the datatype of this matches the datatype of other

Note

You should prefer this function over comparing datatypes using Literal::datatype

Parameters:

other – other literal to check against

Returns:

true as xsd:boolean iff this’ datatype matches other’s datatype or null-literal if this or other is null

Literal cast(IRI const &target, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Tries to cast this literal to a literal of the given type IRI.

Parameters:
  • target – the IRI of the cast target

  • node_storage – where to store the literal resulting from the cast

Returns:

the literal with the same value as a different type if the cast was successful or the null literal

template<datatypes::LiteralDatatype T>
inline Literal cast(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Identical to Literal::cast except with compile time specified target type.

template<datatypes::LiteralDatatype T> requires(!std::same_as< T, datatypes::xsd::String >) std FetchOrSerializeResult fetch_or_serialize_lexical_form (std::string_view &out_lex_form, writer::BufWriterParts writer) const noexcept

Tries to cast this literal to a literal of the given type and return the result without creating a Literal.

Parameters:
  • out_lex_form – out parameter for the fetched lexical form, is set to the lexical form if function returned FetchOrSerializeResult::Fetched

  • writer – writer parts to be used if the lexical form is not yet materialized

Returns:

conversion result Returns the lexical from of this. The lexical form is the part of the identifier that encodes the value. So datatype and language_tag are not part of the lexical form.

E.g. For “abc”^^xsd::string the lexical form is abc

Returns:

lexical form Similar to Literal::lexical_form. If the lexical form is already materialized, will return a string_view to it, otherwise serializes it using the given writer.

Returns:

- Fetched, if lexical form was already materialized and could be fetched.

  • Serialized if lexical form was not yet materialized, but could be serialized.

  • SerializationFailed if lexical for was not yet materialized, but serialization failed.

Literal as_lexical_form(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Converts this into it’s lexical form as xsd:string. See Literal::lexical_form for more details.

Parameters:

node_storage – where to put the resulting literal

Returns:

lexical form of this as xsd:string if this is not the null literal, otherwise returns the null literal

CowString simplified_lexical_form() const noexcept

Returns the simplified/more user friendly string version of this. This is for example used when casting numerics to string.

Returns:

user friendly string representation

FetchOrSerializeResult fetch_or_serialize_simplified_lexical_form(std::string_view &out_lex_form, writer::BufWriterParts writer) const noexcept

Similar to Literal::simplified_lexical_form. If the simplified lexical form is already materialized, will return a string_view to it, otherwise serializes it using the given writer.

Parameters:
  • out_lex_form – out parameter for the fetched lexical form, is set to the lexical form if function returned FetchOrSerializeResult::Fetched

  • writer – writer parts to be used if the simplified lexical form is not yet materialized

Returns:

- Fetched, if lexical form was already materialized and could be fetched.

  • Serialized if lexical form was not yet materialized, but could be serialized.

  • SerializationFailed if lexical for was not yet materialized, but serialization failed.

Literal as_simplified_lexical_form(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Converts this into it’s simplified/more user friendly string representation as xsd:string. See Literal::to_simplified_string for more details.

Returns:

user friendly string representation of this as xsd:string if this is not the null literal, otherwise returns the null literal

IRI datatype() const noexcept

Returns the datatype IRI of this.

Returns:

datatype IRI

std::string_view language_tag() const noexcept

Returns the language tag of this Literal. If the string is empty this has no language tag.

Returns:

language tag

Literal as_language_tag(storage::DynNodeStoragePtr node_storage = keep_node_storage) const
Returns:

the language tag of this Literal as xsd:string. If the string is empty this has no language tag.

TriBool language_tag_eq(std::string_view lang_tag) const noexcept
Parameters:

lang_tag – language tag to compare against

Returns:

if this->language_tag() == lang_tag or error if this is not langString

TriBool language_tag_eq(Literal const &other) const noexcept
Parameters:

other – literal to compare against

Returns:

if this->language_tag() == other.language_tag() or error if:

  • this is not rdf:langString

  • other is not rdf:langString

Literal as_language_tag_eq(std::string_view lang_tag, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Parameters:

lang_tag – language tag to compare against

Returns:

if this->language_tag() == lang_tag or null-literal if this is not langString

Literal as_language_tag_eq(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Parameters:

other – literal to compare against

Returns:

if this->language_tag() == other.language_tag() or null-literal if:

  • this is not rdf:langString

  • other is not rdf:langString

bool serialize(writer::BufWriterParts writer, NodeSerializationOpts opts = NodeSerializationOpts::long_form()) const noexcept

See Node::serialize

bool serialize_lexical_form(writer::BufWriterParts writer) const noexcept

Serializes this Literal’s canonical lexical form into the decomposed writer See Node::serialize for more details

bool serialize_simplified_lexical_form(writer::BufWriterParts writer) const noexcept

Serializes this Literal’s simplified lexical form into the decomposed writer See Node::serialize for more details

explicit operator std::string() const noexcept
std::any value() const noexcept

Constructs a datatype specific container from Literal.

Returns:

std::any wrapped value. will be empty if type is not registered.

template<datatypes::LiteralDatatype T>
inline T::cpp_type value() const

Get the value of an literal. T must be the registered datatype for the datatype iri.

Template Parameters:

T – datatype of the returned instance

Returns:

T instance with the value from this

bool is_literal() const noexcept = delete
bool is_variable() const noexcept = delete
bool is_blank_node() const noexcept = delete
bool is_iri() const noexcept = delete
bool is_numeric() const noexcept
bool is_timepoint() const noexcept
bool is_duration() const noexcept
std::partial_ordering compare(Literal const &other) const noexcept

The literal comparison function for SPARQL filters (FILTER). In contrast to Node, here we can provide a combined “compare” function here because for Literals the definitions of ==/!= and </<=/>/>= are not split in the SPARQL spec.

https://www.w3.org/TR/sparql11-query/#OperatorMapping

std::strong_ordering order(Literal const &other) const noexcept

The comparison function for SPARQL orderings (ORDER BY). For FILTER semantics use compare.

Returns:

similar to compare but:

  • all values of an incomparable type are considered equivalent

  • a null literal is the smallest possible value of all types

  • the type ordering replaces the value ordering in the following cases

    • the values are equal

    • at least one of the value’s types is not comparable

    • there is no viable conversion to a common type to check for equality

TriBool eq(Literal const &other) const noexcept
bool order_eq(Literal const &other) const noexcept
TriBool ne(Literal const &other) const noexcept
bool order_ne(Literal const &other) const noexcept
TriBool lt(Literal const &other) const noexcept
bool order_lt(Literal const &other) const noexcept
TriBool le(Literal const &other) const noexcept
bool order_le(Literal const &other) const noexcept
TriBool gt(Literal const &other) const noexcept
bool order_gt(Literal const &other) const noexcept
TriBool ge(Literal const &other) const noexcept
bool order_ge(Literal const &other) const noexcept
Literal as_eq(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_order_eq(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_ne(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_order_ne(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_lt(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_order_lt(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_le(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_order_le(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_gt(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_order_gt(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_ge(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal as_order_ge(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
std::partial_ordering operator<=>(Literal const &other) const noexcept

Equivalent to this->compare(other)

bool operator==(Literal const &other) const noexcept

Equivalent to this->eq(other)

Literal add(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const
Literal operator+(Literal const &other) const
Literal &add_assign(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage)
Literal &operator+=(Literal const &other)
Literal sub(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const
Literal operator-(Literal const &other) const
Literal &sub_assign(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage)
Literal &operator-=(Literal const &other)
Literal mul(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const
Literal operator*(Literal const &other) const
Literal &mul_assign(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage)
Literal &operator*=(Literal const &other)
Literal div(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const
Literal operator/(Literal const &other) const
Literal &div_assign(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage)
Literal &operator/=(Literal const &other)
Literal pos(storage::DynNodeStoragePtr node_storage = keep_node_storage) const
Literal operator+() const
Literal neg(storage::DynNodeStoragePtr node_storage = keep_node_storage) const
Literal operator-() const
Literal abs(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

absolute value of this or the null literal if this is not numeric

Literal round(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

the rounded value of this or the null literal if this is not numeric

Literal floor(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

the floored value of this or the null literal if this is not numeric

Literal ceil(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

the ceiled value of this or the null literal if this is not numeric

std::optional<size_t> strlen() const noexcept

Returns:

the length this’ lexical form if it is string-like otherwise nullopt

Literal as_strlen(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

the length this’ lexical form (as xsd:integer) if it is string-like otherwise the null literal

TriBool language_tag_matches_range(std::string_view lang_range) const noexcept

Parameters:

lang_range – a basic language range

Returns:

whether the language tag of this matches the given lang range if this is string-like, otherwise Err

Literal as_language_tag_matches_range(std::string_view lang_range, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

lang_range – a basic language range as xsd:string

Returns:

whether the language tag of this matches the given lang range or the null literal if

  • this is not string-like

Literal as_language_tag_matches_range(Literal const &lang_range, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

lang_range – a basic language range as xsd:string

Returns:

whether the language tag of this matches the given lang range or the null literal if

  • this is not string-like

  • lang_range is not xsd:string

TriBool regex_matches(regex::Regex const &pattern) const noexcept

Parameters:

pattern – regex to match against

Returns:

whether this’ lexical form matches the regex or Err if this is not string-like

Literal as_regex_matches(regex::Regex const &pattern, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

pattern – xsd:string containing a regex to match against

Returns:

whether this’ lexical form matches the regex or the null literal if

  • this is not string-like

Literal as_regex_matches(Literal const &pattern, Literal const &flags = Literal::make_simple(""), storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:
Returns:

whether this’ lexical form matches the regex or the null literal if

  • this is not string-like

  • regex is not string-like

  • flags is not string-like or not parsable as flags

regex::Regex make_regex(Literal const &flags = Literal::make_simple("")) const

Creates a regex, whose pattern is the lexical form of the caller (this->lexical_form())

Parameters:

flags – regex flags to use for matching (https://www.w3.org/TR/xpath-functions/#flags)

Returns:

A regex object (rdf4cpp::regex::Regex)

Literal regex_replace(regex::RegexReplacer const &replacer, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Parameters:

replacer – replacement regex

Returns:

the new string with the matches substring replaced by replacement

Literal regex_replace(Literal const &pattern, Literal const &replacement, Literal const &flags = Literal::make_simple(""), storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Parameters:
Returns:

the new string with the matches substring replaced by replacement

TriBool contains(std::string_view needle) const noexcept

Parameters:

needle – substring to search for in this

Returns:

whether this’ lexical form contains the given string or Err if this is not string-like

Literal as_contains(std::string_view needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

needle – substring to search for in this

Returns:

whether this’ lexical form contains the given string (as xsd:boolean) or the null literal if

  • this is not string-like

Literal as_contains(Literal const &needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

needle – substring to search for in this

Returns:

whether this’ lexical form contains the given string (as xsd:boolean) or the null literal if

  • this is not string-like

  • needle is not string-like

Literal substr_before(std::string_view needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Parameters:

needle – substring to search for in this

Returns:

substring of this’ up to the position of the needle or null literal if

  • this is not string-like or empty string if

  • needle is the empty string

  • needle could not be found in this

Literal substr_before(Literal const &needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Parameters:

needle – string-like value to search for in this

Returns:

substring of this’ up to the position of the needle or null literal if

  • this is not string-like

  • needle is not string-like or empty string if

  • needle is the empty string

  • needle could not be found in this

Literal substr_after(std::string_view needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Parameters:

needle – substring to search for in this

Returns:

substring of this’ after the end of the needle or null literal if

  • this is not string-like or empty string if

  • needle is the empty string

  • needle could not be found in this

Literal substr_after(Literal const &needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Parameters:

needle – substring to search for in this

Returns:

substring of this’ after the end of the needle or null literal if

  • this is not string-like

  • needle is not string-like or empty string if

  • needle is the empty string

  • needle could not be found in this

TriBool str_starts_with(std::string_view needle) const noexcept

Parameters:

needle – substring to check

Returns:

whether this’ lexical form starts with needle or Err if

  • this is not string-like

Literal as_str_starts_with(std::string_view needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

needle – substring to check

Returns:

whether this’ lexical form starts with needle (as xsd:boolean) or the null literal if

  • this is not string-like

Literal as_str_starts_with(Literal const &needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

needle – substring to check

Returns:

whether this’ lexical form starts with needle (as xsd:boolean) or the null literal if

  • this is not string-like

  • needle is not string-like

  • the language tags of this and needle do not match

TriBool str_ends_with(std::string_view needle) const noexcept

Parameters:

needle – substring to check

Returns:

whether this’ lexical form ends with needle or Err if

  • this is not string-like

Literal as_str_ends_with(std::string_view needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

needle – substring to check

Returns:

whether this’ lexical form ends with needle (as xsd:boolean) or the null literal if

  • this is not string-like

Literal as_str_ends_with(Literal const &needle, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Parameters:

needle – substring to check

Returns:

whether this’ lexical form ends with needle (as xsd:boolean) or the null literal if

  • this is not string-like

  • needle is not string-like

  • the language tags of this and needle do not match

Literal uppercase(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

the upper case version if this’ if this is string-like or the null literal if

  • this is not string-like

Literal lowercase(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

the lower case version if this’ if this is string-like or the null literal if

  • this is not string-like

Literal concat(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Parameters:

other – other literal to append to this

Returns:

a string-like type that is the concatenation of the lexical forms of this and other

Literal encode_for_uri(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

URL encoded string type literal or the null literal if

  • this is not string-like

Literal substr(size_t start, size_t len = std::string_view::npos, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

akin to std::string_view::substr

Warning

0-based indexing

Parameters:
  • start – position of the first character

  • len – requested length of the substring

Returns:

the characters in this whose position P satisfy: P >= start && P < start + len or the null literal if

  • this is not string-like

Literal substr(Literal const &start, Literal const &len = Literal::make_typed_from_value<datatypes::xsd::Double>(std::numeric_limits<datatypes::xsd::Double::cpp_type>::infinity()), storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Warning

1-based indexing

Parameters:
  • start – position of the first character

  • len – requested length of the substring

Returns:

the characters in this whose position P satisfy: P >= round(start) && P < round(start) + round(len) or the null literal if

  • this is not string-like

  • start is not xsd:double or derived from it

  • len is not xsd:double or derived from it

Literal md5(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

MD5 hash as simple literal, or null literal if this is not of type xsd::String

Literal sha1(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

SHA1 hash as simple literal, or null literal if this is not of type xsd::String

Literal sha256(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

SHA2-256 hash as simple literal, or null literal if this is not of type xsd::String

Literal sha384(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

SHA2-384 hash as simple literal, or null literal if this is not of type xsd::String

Literal sha512(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

Returns:

SHA2-512 hash as simple literal, or null literal if this is not of type xsd::String

std::optional<Year> year() const noexcept

returns the year part of this.

Returns:

year or nullopt

Literal as_year(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

returns the year part of this.

Returns:

xsd::Integer or null literal

std::optional<std::chrono::month> month() const noexcept

returns the month part of this.

Returns:

month or nullopt

Literal as_month(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

returns the month part of this.

Returns:

xsd::Integer or null literal

std::optional<std::chrono::day> day() const noexcept

returns the day part of this.

Returns:

day or nullopt

Literal as_day(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

returns the day part of this.

Returns:

xsd::Integer or null literal

std::optional<std::chrono::hours> hours() const noexcept

returns the hours part of this.

Returns:

hours ot nullopt

Literal as_hours(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

returns the hours part of this.

Returns:

xsd::Integer or null literal

std::optional<std::chrono::minutes> minutes() const noexcept

returns the minutes part of this.

Returns:

minutes ot nullopt

Literal as_minutes(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

returns the minutes part of this.

Returns:

xsd::Integer or null literal

std::optional<std::chrono::nanoseconds> seconds() const noexcept

returns the seconds (including fractional) part of this.

Returns:

seconds or nullopt

Literal as_seconds(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

returns the seconds (including fractional) part of this.

Returns:

xsd::Decimal or null literal

std::optional<Timezone> timezone() const noexcept

returns the timezone offset part of this.

Returns:

timezone or nullopt

Literal as_timezone(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

returns the timezone offset part of this.

Returns:

offset as xsd::DayTimeDuration or null literal

std::optional<std::string> tz() const noexcept

returns the timezone offset part of this.

Returns:

timezone as string or nullopt

Literal as_tz(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

returns the timezone offset part of this.

Returns:

timezone as simple literal or null literal

TriBool ebv() const noexcept
Returns:

the effective boolean value of this

Literal as_ebv(storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept

Converts this literal to its effective boolean value

Returns:

Literal containing the ebv

Literal logical_and(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal operator&&(Literal const &other) const noexcept
Literal logical_or(Literal const &other, storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal operator||(Literal const &other) const noexcept
Literal logical_not(storage::DynNodeStoragePtr node_storage = keep_node_storage) const noexcept
Literal operator!() const noexcept
Literal math_exp(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-exp returns null, if this is not of type xsd::Double.

Returns:

pow(e, this)

Literal math_exp10(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-exp10 returns null, if this is not of type xsd::Double.

Returns:

pow(10, this)

Literal math_log(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-log returns null, if this is not of type xsd::Double.

Returns:

log(e, this)

Literal math_log10(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-log10 returns null, if this is not of type xsd::Double.

Returns:

log(10, this)

Literal math_pow(Literal exp, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-pow returns null, if this is not of type xsd::Double or exp not numeric.

Returns:

pow(this, exp)

Literal math_sqrt(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-sqrt returns null, if this is not of type xsd::Double.

Returns:

sqrt(this)

Literal math_sin(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-sin returns null, if this is not of type xsd::Double.

Returns:

sin(this)

Literal math_cos(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-cos returns null, if this is not of type xsd::Double.

Returns:

cos(this)

Literal math_tan(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-tan returns null, if this is not of type xsd::Double.

Returns:

tan(this)

Literal math_asin(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-asin returns null, if this is not of type xsd::Double.

Returns:

asin(this)

Literal math_acos(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-acos returns null, if this is not of type xsd::Double.

Returns:

acos(this)

Literal math_atan(storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-atan returns null, if this is not of type xsd::Double.

Returns:

atan(this)

Literal math_atan2(Literal y, storage::DynNodeStoragePtr node_storage = keep_node_storage) const

https://www.w3.org/TR/xpath-functions/#func-math-atan2 returns null, if this or y is not of type xsd::Double.

Returns:

atan2(this, y)

Public Static Functions

static Literal make_null() noexcept

Constructs the null-literal

static Literal make_simple(std::string_view lexical_form, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Constructs a simple Literal from a lexical form. Datatype is xsd:string.

Parameters:
  • lexical_form – the lexical form

  • node_storage – optional custom node_storage used to store the literal

Throws:

std::runtime_error – if lexical_form contains invalid unicode

static Literal make_simple_normalize(std::string_view lexical_form, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Constructs a simple Literal from a lexical form. Datatype is xsd:string. normalizes lexical_form to UTF-8 NFC.

Parameters:
  • lexical_form – the lexical form

  • node_storage – optional custom node_storage used to store the literal

static Literal make_lang_tagged(std::string_view lexical_form, std::string_view lang_tag, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Constructs a Literal from a lexical form and a language tag. The datatype is rdf:langString.

Parameters:
  • lexical_form – the lexical form

  • lang_tag – the language tag

  • node_storage – optional custom node_storage used to store the literal

Throws:

std::runtime_error – if lexical_form contains invalid unicode

static Literal make_lang_tagged_normalize(std::string_view lexical_form, std::string_view lang_tag, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Constructs a Literal from a lexical form and a language tag. The datatype is rdf:langString. normalizes lexical_form to UTF-8 NFC.

Parameters:
  • lexical_form – the lexical form

  • lang_tag – the language tag

  • node_storage – optional custom node_storage used to store the literal

static Literal make_typed(std::string_view lexical_form, IRI const &datatype, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Constructs a Literal from a lexical form and a datatype.

Parameters:
  • lexical_form – the lexical form

  • datatype – the datatype

  • node_storage – optional custom node_storage used to store the literal

Throws:

std::runtime_error – if lexical_form contains invalid unicode (only xsd::string)

template<datatypes::LiteralDatatype T>
static inline Literal make_typed(std::string_view lexical_form, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Constructs a Literal from a lexical form and a datatype provided as a template parameter.

Template Parameters:

T – the datatype

Parameters:
  • lexical_form – the lexical form

  • node_storage – optional custom node_storage used to store the literal

Throws:

std::runtime_error – if lexical_form contains invalid unicode (only xsd::string)

template<datatypes::LiteralDatatype T>
static inline Literal make_typed_from_value(typename T::cpp_type const &compatible_value, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Constructs a literal from a compatible type. In this version of the function the datatype is specified at compile time. No runtime lookup of the type information is required. If type information is available at compile time, you should use this version of the function.

Template Parameters:

T – the datatype

Parameters:
  • compatible_value – instance for which the literal is created

  • node_storage – NodeStorage used

Returns:

literal instance representing compatible_value

static Literal make_boolean(TriBool b, storage::DynNodeStoragePtr node_storage = storage::default_node_storage) noexcept

Constructs a literal from a tri-bool with the following mappings

Returns:

the literal form of the given boolean

static Literal make_string_uuid(storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

creates a new string Literal containing a random UUID (Universally Unique IDentifier)

Returns:

UUID Literal

static Literal generate_random_double(storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Generates a random double in the range [0.0, 1.0). The values are generated in a thread-safe manner using a lazily initialized thread_local random generator.

Returns:

random double in [0.0, 1.0)

template<typename Rng>
static inline Literal generate_random_double(Rng &rng, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Generates a random double in the range [0.0, 1.0). The values are generated using the given random number generator

Parameters:

rng – random number generator

Returns:

random double in [0.0, 1.0)

static Literal find_simple(std::string_view lexical_form, storage::DynNodeStoragePtr node_storage = storage::default_node_storage) noexcept

searches for a xsd::String Literal in the specified node storage and returns it. returns a null Literal, if not found.

Parameters:
  • lexical_form

  • node_storage

Returns:

static Literal find_lang_tagged(std::string_view lexical_form, std::string_view lang_tag, storage::DynNodeStoragePtr node_storage = storage::default_node_storage) noexcept

searches for a rdf::LangString Literal in the specified node storage and returns it. returns a null Literal, if not found.

Parameters:
  • lexical_form

  • node_storage

Returns:

template<datatypes::LiteralDatatype T>
static inline Literal find_typed_from_value(typename T::cpp_type const &compatible_value, storage::DynNodeStoragePtr node_storage = storage::default_node_storage) noexcept

searches for a Literal of type T in the specified node storage and returns it. returns a null Literal, if not found. if T is inlineable (and not rdf::LangString) always returns the inlined Literal.

Template Parameters:

T

Parameters:
  • compatible_value

  • node_storage

Returns:

static Literal encode_for_uri(std::string_view string, storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

Parameters:

string – literal to encode

Returns:

URL encoded string type literal

static Literal now(storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

returns the current time. Note: will need to be buffered for each query, because each query has only one now.

Returns:

std::chrono::system_clock::now() as xsd:dateTime

static Literal math_pi(storage::DynNodeStoragePtr node_storage = storage::default_node_storage)

https://www.w3.org/TR/xpath-functions/#func-math-pi

Returns:

std::numbers::pi as xsd::Double

Friends

friend struct Node
friend std::ostream &operator<<(std::ostream &os, const Literal &literal)
friend Literal lang_matches(Literal const &lang_tag, Literal const &lang_range, storage::DynNodeStoragePtr node_storage) noexcept
Returns:

whether lang_tag matches the basic language range lang_range as xsd:boolean or the null-literal if:

  • lang_tag is not xsd:string

  • lang_range is not xsd:string