Template Class BaseString

Nested Relationships

Nested Types

Class Documentation

template<::size64_t BUFFER_SIZE>
class BaseString

BaseString defines a base string class with constant memory footprint. The internal buffer size is defined by BUFFER_SIZE template parameter. The maximum length for a string is (BUFFER_SIZE - 1ULL). One character is reserved for terminating zero. The class serves as a common storage and method provider for derived classes.

Template Parameters:

BUFFER_SIZE – defines the size of static string including its terminating zero.

Public Types

using char_type = char8_t

Public Functions

inline BaseString(void) noexcept

default constructor

inline constexpr const ::char8_t * data () const noexcept

Converts the contents of a string into a pointer to an array of characters.

Returns:

return a pointer to the internal zero-terminated array of characters

inline BaseString substr(const ::size64_t pos = 0U, const ::size64_t len = npos) const

Returns a newly constructed string object with its value initialized to a copy of a substring of this object. The substring is the portion of the object that starts at character position pos and spans len characters (or until the end of the string, whichever comes first).

Parameters:
  • pos[in] is a position of the first character to be copied as a substring. If this is equal to the string length, the function returns an empty string. If this is greater than the string length, it throws out_of_range. Note: The first character is denoted by a value of 0 (not 1).

  • len[in] is a number of characters to include in the substring. If the string is shorter, as many characters as possible are used. A value of BaseString::npos indicates all characters until the end of the string.

Throws:

std::out_of_range

inline int32_t compare (const ::size64_t pos1, const ::size64_t count1, const ::char8_t *const s, const ::size64_t count2=npos) const

Compares the value of the string object (or a substring) to the sequence of characters specified by its arguments. The compared string is the value of the string object or (if the signature used has a pos1 and a count1 parameters) the substring that begins at its character in position pos1 and spans count1 characters. This string is compared to a comparing string, which is determined by the other arguments passed to the function.

Parameters:
  • pos1[in] is a position of the first character in the compared string. If this is greater than the string length, it throws out_of_range. Note: The first character is denoted by a value of 0 (not 1).

  • count1[in] is length of compared string. If the string is shorter, as many characters as possible. If count1 is npos, the strings length is assumed

  • s[in] is pointer to an array of characters. If NULL, std::invalid_argument is thrown.

  • count2[in] is number of characters to compare. It it’s npos, all characters compared.

Throws:
  • std::invalid_argument

  • std::out_of_range

Returns:

Returns a signed integral indicating the relation between the strings: 0 They compare equal <0 Either the value of the first character that does not match is lower in the compared string, or all compared characters match but the compared string is shorter. >0 Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer.

inline int32_t compare (const ::char8_t *const s) const

Compares the value of the string object (or a substring) to the sequence of characters specified by its arguments. The compared string is the value of the string object or (if the signature used has a pos1 and a _count1 parameters) the substring that begins at its character in position pos1 and spans _count1 characters. This string is compared to a comparing string, which is determined by the other arguments passed to the function. param [in] s is pointer to an array of characters. If NULL, std::invalid_argument is thrown.

Throws:
  • std::invalid_argument

  • std::out_of_range

Returns:

Returns a signed integral indicating the relation between the strings: 0 They compare equal <0 Either the value of the first character that does not match is lower in the compared string, or all compared characters match but the compared string is shorter. >0 Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer.

inline bool operator==(const char8_t *const rhs) const

operator==

Parameters:

rhs[in] is the right hand comparand up to APEX_STRING_SIZE characters

Throws:
  • std::invalid_argument

  • std::out_of_range

Returns:

return True if the strings are equal, false otherwise

template<::size64_t LEN>
inline int32_t compare(const ::size64_t pos1, const ::size64_t count1, const BaseString<LEN> &str) const

Compares the value of the string object (or a substring) to the given string. The compared string is the value of the string object or (if the signature used has a pos1 and a _count1 parameters) the substring that begins at its character in position pos1 and spans _count1 characters. This string is compared to a comparing string, which is determined by the other arguments passed to the function.

Parameters:
  • pos1[in] is a position of the first character in the compared string. If this is greater than the string length, it throws out_of_range. Note: The first character is denoted by a value of 0 (not 1).

  • count1[in] is length of compared string. If the string is shorter, as many characters as possible. If count1 is npos, full string length assumed.

  • str[in] is a comparand string.

Throws:
  • std::invalid_argument

  • std::out_of_range

Returns:

Returns a signed integral indicating the relation between the strings: 0 They compare equal <0 Either the value of the first character that does not match is lower in the compared string, or all compared characters match but the compared string is shorter. >0 Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer.

inline int32_t compare(const ::size64_t pos1, const ::size64_t count1, const std::string &str) const

Compares the value of the string object (or a substring) to the given string. The compared string is the value of the string object or (if the signature used has a pos1 and a _count1 parameters) the substring that begins at its character in position pos1 and spans _count1 characters. This string is compared to a comparing string, which is determined by the other arguments passed to the function.

Parameters:
  • pos1[in] is a position of the first character in the compared string. If this is greater than the string length, it throws out_of_range. Note: The first character is denoted by a value of 0 (not 1).

  • count1[in] is length of compared string. If the string is shorter, as many characters as possible. If count1 is npos, full string length assumed.

  • str[in] is a comparand string.

Throws:
  • std::invalid_argument

  • std::out_of_range

Returns:

Returns a signed integral indicating the relation between the strings: 0 They compare equal <0 Either the value of the first character that does not match is lower in the compared string, or all compared characters match but the compared string is shorter. >0 Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer.

template<::size64_t LEN>
inline int32_t compare(const BaseString<LEN> &str) const

Compares the value of the string object to the given string specified by its arguments.

Parameters:

str[in] is a comparand string.

Throws:
  • std::invalid_argument

  • std::out_of_range

Returns:

Returns a signed integral indicating the relation between the strings: 0 They compare equal <0 Either the value of the first character that does not match is lower in the compared string, or all compared characters match but the compared string is shorter. >0 Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer.

inline int32_t compare(const std::string &str) const

Compares the value of the string object to the given string specified by its arguments.

Parameters:

str[in] is a comparand string.

Throws:
  • std::invalid_argument

  • std::out_of_range

Returns:

Returns a signed integral indicating the relation between the strings: 0 They compare equal <0 Either the value of the first character that does not match is lower in the compared string, or all compared characters match but the compared string is shorter. >0 Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer.

template<::size64_t LEN>
inline bool operator==(const BaseString<LEN> &rhs) const

operator==

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if the strings are equal, false otherwise

inline bool operator==(const std::string &rhs) const

operator==

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if the strings are equal, false otherwise

inline bool operator!=(const char8_t *const rhs) const

operator!=

Parameters:

rhs[in] is the right hand comparand up to APEX_STRING_SIZE characters

Returns:

return True if the strings are not equal, false otherwise

template<::size64_t LEN>
inline bool operator!=(const BaseString<LEN> &rhs) const

operator!=

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if the strings are not equal, false otherwise

inline bool operator!=(const std::string &rhs) const

operator!=

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if the strings are not equal, false otherwise

inline bool operator<(const char8_t *const rhs) const

operator<

Parameters:

rhs[in] is the right hand comparand up to APEX_STRING_SIZE characters

Throws:

std::invalid_argument

Returns:

return True if rhs is larger

template<::size64_t LEN>
inline bool operator<(const BaseString<LEN> &rhs) const

operator<

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if rhs is larger

inline bool operator<(const std::string &rhs) const

operator<

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if rhs is larger

inline bool operator<=(const char8_t *const rhs) const

operator<=

Parameters:

rhs[in] is the right hand comparand up to APEX_STRING_SIZE characters

Returns:

return True if rhs is larger or equal

template<::size64_t LEN>
inline bool operator<=(const BaseString<LEN> &rhs) const

operator<

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if rhs is larger

inline bool operator<=(const std::string &rhs) const

operator<

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if rhs is larger

inline bool operator>(const char8_t *const rhs) const

operator>

Parameters:

rhs[in] is the right hand comparand up to APEX_STRING_SIZE characters

Throws:

std::invalid_argument

Returns:

return True if rhs is smaller

template<::size64_t LEN>
inline bool operator>(const BaseString<LEN> &rhs) const

operator>

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if rhs is smaller

inline bool operator>(const std::string &rhs) const

operator>

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if rhs is smaller

inline bool operator>=(const char8_t *const rhs) const

operator>=

Parameters:

rhs[in] is the right hand comparand up to APEX_STRING_SIZE characters

Returns:

return True if rhs is smaller or equal

template<size64_t LEN>
inline bool operator>=(const BaseString<LEN> &rhs) const

operator>

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if rhs is smaller

inline bool operator>=(const std::string &rhs) const

operator>

Parameters:

rhs[in] is the right hand comparand

Returns:

return True if rhs is smaller

inline bool empty() const noexcept

Test whether the string contains anything.

Returns:

true if the string contains no characters; false if it has at least one character.

inline const char8_t *c_str() const noexcept

return pointer to the internal string buffer.

inline char8_t *data() noexcept

return non const pointer to the internal string buffer.

inline constexpr size64_t capacity() const

return the largest number of elements that could be stored in the string.

inline size64_t size() const noexcept

return the current number of elements in a string.

inline size64_t length() const noexcept

return the current number of elements in a string.

inline char8_t &operator[](size64_t idx)

a standard index operator

Parameters:

idx[in] is the index of the indexed character

Throws:

std::out_of_range

Returns:

reference to the indexed character

inline char8_t operator[](size64_t idx) const

a standard index operator

Parameters:

idx[in] is the index to get the value at

Throws:

std::out_of_range

Returns:

return value at the index

inline constexpr ::size64_t get_buffer_size() const noexcept

return the total number of character in the buffer, including the terminating zero

Returns:

the total number of character in the buffer, including the terminating zero

inline operator std::string() const

Convert apex::string to an STL string

Returns:

return STL string

inline void clear() noexcept

Public Static Functions

static inline constexpr ::size64_t get_buffer_size_static() noexcept

return the total number of character in the buffer, including the terminating zero

Returns:

the total number of character in the buffer, including the terminating zero

Public Static Attributes

static constexpr const ::size64_t npos = ULLONG_MAX

An unsigned integral value that indicates either “not found” or “all remaining characters” when a search function fails.

Protected Attributes

char8_t m_string[BUFFER_SIZE]

m_string is string’s storage

template<typename Type>
class abs_iterator : public std::iterator<std::random_access_iterator_tag, Type>

Public Types

using difference_type = typename std::iterator<std::random_access_iterator_tag, Type>::difference_type

Public Functions

inline abs_iterator()
inline explicit abs_iterator(Type *rhs)
inline abs_iterator(const abs_iterator &rhs)
inline abs_iterator &operator+=(difference_type rhs)
inline abs_iterator &operator-=(difference_type rhs)
inline Type &operator*() const
inline Type *operator->() const
inline Type &operator[](difference_type rhs)
inline const Type &operator[](difference_type rhs) const
inline abs_iterator &operator++()
inline abs_iterator &operator--()
inline abs_iterator operator++(int)
inline abs_iterator operator--(int)
inline difference_type operator-(const abs_iterator &rhs) const
inline abs_iterator operator+(difference_type rhs) const
inline abs_iterator operator-(difference_type rhs) const
inline bool operator==(const abs_iterator &rhs) const
inline bool operator!=(const abs_iterator &rhs) const
inline bool operator>(const abs_iterator &rhs) const
inline bool operator<(const abs_iterator &rhs) const
inline bool operator>=(const abs_iterator &rhs) const
inline bool operator<=(const abs_iterator &rhs) const

Friends

inline friend abs_iterator operator+(difference_type lhs, const abs_iterator &rhs)
inline friend abs_iterator operator-(difference_type lhs, const abs_iterator &rhs)