iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall > Class Template Reference

The SemanticString is a string which has an inner syntax and restrictions to valid content. Examples are for instance. More...

#include <semantic_string.hpp>

Public Member Functions

constexpr auto size () const noexcept -> uint64_t
 Returns the number of characters.
 
constexpr auto as_string () const noexcept -> const bb::StaticString< Capacity > &
 Returns a const reference to the underlying string. It is const and shall not be modified to guarantee the contract that a SemanticString contains always a valid value.
 
template<typename T >
auto append (const T &value) noexcept -> bb::Expected< void, SemanticStringError >
 Appends another string to the SemanticString. If the value contains invalid characters or the result would end up in invalid content it fails.
 
template<typename T >
auto insert (uint64_t pos, const T &str, uint64_t count) noexcept -> bb::Expected< void, SemanticStringError >
 Inserts another string into the SemanticString. If the value contains invalid characters or the result would end up in invalid content it fails.
 
auto operator== (const SemanticString &rhs) const noexcept -> bool
 checks if another SemanticString is equal to this string
 
template<typename T >
auto operator== (const T &rhs) const noexcept -> bb::RequireStaticStringOrCharArray< T, bool >
 checks if another string or char array is equal to this string
 
auto operator!= (const SemanticString &rhs) const noexcept -> bool
 checks if another SemanticString is not equal to this string
 
template<typename T >
auto operator!= (const T &rhs) const noexcept -> bb::RequireStaticStringOrCharArray< T, bool >
 checks if another string or char array is not equal to this string
 
auto operator<= (const SemanticString &rhs) const noexcept -> bool
 checks if another SemanticString is less than or equal this string
 
template<typename T >
auto operator<= (const T &rhs) const noexcept -> bb::RequireStaticStringOrCharArray< T, bool >
 checks if another string or char array is less than or equal this string
 
auto operator< (const SemanticString &rhs) const noexcept -> bool
 checks if another SemanticString is less than this string
 
template<typename T >
auto operator< (const T &rhs) const noexcept -> bb::RequireStaticStringOrCharArray< T, bool >
 checks if another string or char array is less than this string
 
auto operator>= (const SemanticString &rhs) const noexcept -> bool
 checks if another SemanticString is greater than or equal this string
 
template<typename T >
auto operator>= (const T &rhs) const noexcept -> bb::RequireStaticStringOrCharArray< T, bool >
 checks if another string or char array is greater than or equal this string
 
auto operator> (const SemanticString &rhs) const noexcept -> bool
 checks if another SemanticString is greater than this string
 
template<typename T >
auto operator> (const T &rhs) const noexcept -> bb::RequireStaticStringOrCharArray< T, bool >
 checks if another string or char array is greater than this string
 

Static Public Member Functions

template<uint64_t N>
static auto create (const char(&value)[N]) noexcept -> bb::Expected< Child, SemanticStringError >
 Creates a new SemanticString from the provided string literal. If the value contains invalid characters or invalid content the expected returns an error describing the cause.
 
template<uint64_t N>
static auto create (const bb::StaticString< N > &value) noexcept -> bb::Expected< Child, SemanticStringError >
 Creates a new SemanticString from the provided string. If the value contains invalid characters or invalid content the expected returns an error describing the cause.
 
static constexpr auto capacity () noexcept -> uint64_t
 Returns the capacity of the string.
 

Protected Member Functions

template<uint64_t N>
 SemanticString (const bb::StaticString< N > &value) noexcept
 

Detailed Description

template<typename Child, uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
class iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >

The SemanticString is a string which has an inner syntax and restrictions to valid content. Examples are for instance.

  • FileNames, no slashes etc. The SemanticString shall be a basic building block to create string types with a semantic contract. It is used via inheritance. The user has to also define the maximum capacity, a callable which defines invalid characters as well as a callable which defines invalid content.
    bool file_name_does_contain_invalid_characters(const StaticString<platform::IOX2_MAX_FILENAME_LENGTH>& value)
    noexcept;
    bool file_name_does_contain_invalid_content(const StaticString<platform::IOX2_MAX_FILENAME_LENGTH>& value) noexcept;
    // define custom semantic string FileName
    class FileName : public SemanticString<FileName,
    platform::IOX2_MAX_FILENAME_LENGTH,
    details::file_name_does_contain_invalid_content,
    details::file_name_does_contain_invalid_characters>
    {
    using Parent = SemanticString<FileName,
    platform::IOX2_MAX_FILENAME_LENGTH,
    details::file_name_does_contain_invalid_content,
    details::file_name_does_contain_invalid_characters>;
    using Parent::Parent;
    };
    Represents a single file name. It is not allowed to contain any path elements like "....
    Definition file_name.hpp:43
    The SemanticString is a string which has an inner syntax and restrictions to valid content....
    Note
    Since the inner logic of the SemanticString is always the same additional implementations can be verified directly by the test suite defined in 'test_vocabulary_semantic_string.cpp'. One has to only add the specific implementation to the 'Implementations' type list.

Definition at line 65 of file semantic_string.hpp.

Constructor & Destructor Documentation

◆ SemanticString()

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<uint64_t N>
iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::SemanticString ( const bb::StaticString< N > &  value)
inlineexplicitprotectednoexcept

Definition at line 202 of file semantic_string.hpp.

Member Function Documentation

◆ append()

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<typename T >
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::append ( const T &  value) -> bb::Expected<void, SemanticStringError>
inlinenoexcept

Appends another string to the SemanticString. If the value contains invalid characters or the result would end up in invalid content it fails.

Parameters
[in]valuethe value which should be added
Returns
on failure the error inside the expected describes the failure

Definition at line 299 of file semantic_string.hpp.

References iox2::bb::detail::get_size(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::insert(), and iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::size().

◆ as_string()

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
constexpr auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string ( ) const -> const bb::StaticString<Capacity>&
constexprnoexcept

Returns a const reference to the underlying string. It is const and shall not be modified to guarantee the contract that a SemanticString contains always a valid value.

Returns
string reference containing the actual value.

Definition at line 289 of file semantic_string.hpp.

Referenced by iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator!=(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator!=(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator<(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator<(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator<=(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator<=(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator==(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator==(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator>(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator>(), iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator>=(), and iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator>=().

◆ capacity()

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
constexpr auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::capacity ( ) -> uint64_t
staticconstexprnoexcept

Returns the capacity of the string.

Returns
the maximum amount of characters which can be stored.

Definition at line 279 of file semantic_string.hpp.

◆ create() [1/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<uint64_t N>
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::create ( const bb::StaticString< N > &  value) -> bb::Expected<Child, SemanticStringError>
inlinestaticnoexcept

Creates a new SemanticString from the provided string. If the value contains invalid characters or invalid content the expected returns an error describing the cause.

Parameters
[in]valuethe value of the SemanticString
Returns
expected either containing the new SemanticString or an error

Definition at line 258 of file semantic_string.hpp.

◆ create() [2/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<uint64_t N>
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::create ( const char(&)  value[N]) -> bb::Expected<Child, SemanticStringError>
inlinestaticnoexcept

Creates a new SemanticString from the provided string literal. If the value contains invalid characters or invalid content the expected returns an error describing the cause.

Parameters
[in]valuethe value of the SemanticString
Returns
expected either containing the new SemanticString or an error

Definition at line 245 of file semantic_string.hpp.

◆ insert()

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<typename T >
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::insert ( uint64_t  pos,
const T &  str,
uint64_t  count 
) -> bb::Expected<void, SemanticStringError>
inlinenoexcept

Inserts another string into the SemanticString. If the value contains invalid characters or the result would end up in invalid content it fails.

Parameters
[in]posthe position where the string should be inserted
[in]strthe value which should be added
[in]counthow many characters of str shall be inserted
Returns
on failure the error inside the expected describes the failure

Definition at line 309 of file semantic_string.hpp.

References iox2::Debug, iox2::bb::err(), iox2::bb::ExceedsMaximumLength, iox2::bb::InvalidContent, and IOX2_LOG.

Referenced by iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::append().

◆ operator!=() [1/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator!= ( const SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall > &  rhs) const -> bool
inlinenoexcept

checks if another SemanticString is not equal to this string

Parameters
[in]rhsthe other SemanticString
Returns
true if the contents are not equal, otherwise false

Definition at line 364 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator!=() [2/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<typename T >
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator!= ( const T &  rhs) const -> bb::RequireStaticStringOrCharArray<T, bool>
inlinenoexcept

checks if another string or char array is not equal to this string

Parameters
[in]rhsthe other string
Returns
true if the contents are not equal, otherwise false

Definition at line 374 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator<() [1/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator< ( const SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall > &  rhs) const -> bool
inlinenoexcept

checks if another SemanticString is less than this string

Parameters
[in]rhsthe other SemanticString
Returns
true if the contents are less than rhs, otherwise false

Definition at line 402 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator<() [2/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<typename T >
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator< ( const T &  rhs) const -> bb::RequireStaticStringOrCharArray<T, bool>
inlinenoexcept

checks if another string or char array is less than this string

Parameters
[in]rhsthe other string
Returns
true if the contents are less than rhs, otherwise false

Definition at line 412 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator<=() [1/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator<= ( const SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall > &  rhs) const -> bool
inlinenoexcept

checks if another SemanticString is less than or equal this string

Parameters
[in]rhsthe other SemanticString
Returns
true if the contents are less than or equal rhs, otherwise false

Definition at line 383 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator<=() [2/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<typename T >
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator<= ( const T &  rhs) const -> bb::RequireStaticStringOrCharArray<T, bool>
inlinenoexcept

checks if another string or char array is less than or equal this string

Parameters
[in]rhsthe other string
Returns
true if the contents are less than or equal rhs, otherwise false

Definition at line 393 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator==() [1/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator== ( const SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall > &  rhs) const -> bool
inlinenoexcept

checks if another SemanticString is equal to this string

Parameters
[in]rhsthe other SemanticString
Returns
true if the contents are equal, otherwise false

Definition at line 345 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator==() [2/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<typename T >
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator== ( const T &  rhs) const -> bb::RequireStaticStringOrCharArray<T, bool>
inlinenoexcept

checks if another string or char array is equal to this string

Parameters
[in]rhsthe other string
Returns
true if the contents are equal, otherwise false

Definition at line 355 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator>() [1/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator> ( const SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall > &  rhs) const -> bool
inlinenoexcept

checks if another SemanticString is greater than this string

Parameters
[in]rhsthe other SemanticString
Returns
true if the contents are greater than rhs, otherwise false

Definition at line 440 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator>() [2/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<typename T >
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator> ( const T &  rhs) const -> bb::RequireStaticStringOrCharArray<T, bool>
inlinenoexcept

checks if another string or char array is greater than this string

Parameters
[in]rhsthe other string
Returns
true if the contents are greater than rhs, otherwise false

Definition at line 450 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator>=() [1/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator>= ( const SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall > &  rhs) const -> bool
inlinenoexcept

checks if another SemanticString is greater than or equal this string

Parameters
[in]rhsthe other SemanticString
Returns
true if the contents are greater than or equal rhs, otherwise false

Definition at line 421 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ operator>=() [2/2]

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
template<typename T >
auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::operator>= ( const T &  rhs) const -> bb::RequireStaticStringOrCharArray<T, bool>
inlinenoexcept

checks if another string or char array is greater than or equal this string

Parameters
[in]rhsthe other string
Returns
true if the contents are greater than or equal rhs, otherwise false

Definition at line 431 of file semantic_string.hpp.

References iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::as_string().

◆ size()

template<typename Child , uint64_t Capacity, DoesContainInvalidContent< Capacity > DoesContainInvalidContentCall, DoesContainInvalidCharacter< Capacity > DoesContainInvalidCharacterCall>
constexpr auto iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::size ( ) const -> uint64_t
constexprnoexcept

Returns the number of characters.

Returns
number of characters

Definition at line 269 of file semantic_string.hpp.

References iox2::bb::StaticString< N >::size().

Referenced by iox2::bb::SemanticString< Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall >::append().


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