14#ifndef IOX2_BB_SEMANTIC_STRING_HPP
15#define IOX2_BB_SEMANTIC_STRING_HPP
61template <
typename Child,
63 DoesContainInvalidContent<Capacity> DoesContainInvalidContentCall,
64 DoesContainInvalidCharacter<Capacity> DoesContainInvalidCharacterCall>
98 constexpr auto size() const noexcept -> uint64_t;
102 static constexpr auto
capacity() noexcept -> uint64_t;
115 template <typename T>
125 template <typename T>
136 template <typename T>
147 template <typename T>
158 template <typename T>
169 template <typename T>
180 template <typename T>
191 template <typename T>
195 template <uint64_t N>
199 template <uint64_t N>
204template <typename Child,
214template <
typename Child,
216 DoesContainInvalidContent<Capacity> DoesContainInvalidContentCall,
217 DoesContainInvalidCharacter<Capacity> DoesContainInvalidCharacterCall>
220SemanticString<Child, Capacity, DoesContainInvalidContentCall, DoesContainInvalidCharacterCall>::create_impl(
224 "Unable to create semantic string since the value \""
225 << value <<
"\" exceeds the maximum valid length of " << Capacity <<
".");
231 if (DoesContainInvalidCharacterCall(str)) {
233 "Unable to create semantic string since the value \"" << value
234 <<
"\" contains invalid characters as content");
238 if (DoesContainInvalidContentCall(str)) {
240 "Unable to create semantic string since the value \"" << value <<
"\" contains invalid content");
247template <
typename Child,
249 DoesContainInvalidContent<Capacity> DoesContainInvalidContentCall,
250 DoesContainInvalidCharacter<Capacity> DoesContainInvalidCharacterCall>
257 template create_impl<N>(value);
260template <
typename Child,
268 template create_impl<N>(value.unchecked_access().c_str());
271template <
typename Child,
277 if (strnlen(value, Capacity + 1) > Capacity) {
279 "Unable to create semantic string since the value \""
280 << value <<
"\" exceeds the maximum valid length of " << Capacity <<
".");
285 template create_impl<Capacity>(value);
288template <
typename Child,
295 return m_data.
size();
298template <
typename Child,
308template <
typename Child,
318template <
typename Child,
328template <
typename Child,
336 if (!temp.unchecked_code_units().insert(pos, str, 0, count)) {
338 "Unable to insert the value \""
339 << str.unchecked_access().c_str()
340 <<
"\" to the semantic string since it would exceed the maximum valid length of " << Capacity
345 if (DoesContainInvalidCharacterCall(temp)) {
347 "Unable to insert the value \""
348 << str.unchecked_access().c_str()
349 <<
"\" to the semantic string since it contains invalid characters as content.");
353 if (DoesContainInvalidContentCall(temp)) {
355 "Unable to insert the value \""
356 << str.unchecked_access().c_str()
357 <<
"\" to the semantic string since it would lead to invalid content.");
365template <
typename Child,
374template <
typename Child,
384template <
typename Child,
393template <
typename Child,
403template <
typename Child,
412template <
typename Child,
422template <
typename Child,
431template <
typename Child,
441template <
typename Child,
450template <
typename Child,
460template <
typename Child,
469template <
typename Child,
The SemanticString is a string which has an inner syntax and restrictions to valid content....
auto operator!=(const SemanticString &rhs) const noexcept -> bool
checks if another SemanticString is not equal to this string
auto operator==(const SemanticString &rhs) const noexcept -> bool
checks if another SemanticString is equal to this string
auto operator<=(const SemanticString &rhs) const noexcept -> bool
checks if another SemanticString is less than or equal this string
constexpr auto size() const noexcept -> uint64_t
Returns the number of characters.
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 resul...
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 ...
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 guarante...
static constexpr auto capacity() noexcept -> uint64_t
Returns the capacity of the string.
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 in...
auto operator>=(const SemanticString &rhs) const noexcept -> bool
checks if another SemanticString is greater than or equal this string
auto operator>(const SemanticString &rhs) const noexcept -> bool
checks if another SemanticString is greater than this string
auto operator<(const SemanticString &rhs) const noexcept -> bool
checks if another SemanticString is less than this string
static auto create(const char *value) noexcept -> bb::Expected< Child, SemanticStringError >
Creates a new SemanticString from the provided string literal. If the value contains invalid characte...
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 characte...
static auto from_utf8_null_terminated_unchecked_truncated(char const *utf8_str, SizeType count) -> StaticString
constexpr auto size() const noexcept -> SizeType
#define IOX2_LOG(level, msg_stream)
Macro for logging.
auto get_size(const StaticString< N > &data) -> uint64_t
bool(*)(const StaticString< Capacity > &value) DoesContainInvalidCharacter
SemanticStringError
Defines errors which can occur when modifying or creating a SemanticString.
constexpr auto err(const E &error) -> Unexpected< E >
bool(*)(const StaticString< Capacity > &value) DoesContainInvalidContent
iox2::bb::variation::Expected< T, E > Expected
typename std::enable_if_t< IsStaticString< T >::value||legacy::is_char_array< T >::value, ReturnType > RequireStaticStringOrCharArray