Class String#

Class Documentation#

class String#

String container class.

Public Functions

String(std::nullptr_t) = delete#

avoid misuse of nullptr

inline String()#

constructor

String(const String &other) = default#

Copy constructor.

Parameters:

other – The other string

String(String &&other) = default#

Move constructor.

Parameters:

other – The other string

inline void swap(String &other) noexcept#

Swap this String with another string.

Parameters:

other – The other string

inline String(const char *data, size_t size)#

constructor from raw string

Parameters:
  • data – The data pointer.

  • size – The size of the char array.

inline String(const char *other)#

constructor from raw string

Note

This constructor is marked as explicit to avoid implicit conversion of nullptr value here to string, which then was used in comparison

Parameters:

other – a char array.

inline String(const std::string &other)#

Construct a new string object.

Parameters:

other – The std::string object to be copied

inline String(std::string &&other)#

Construct a new string object.

Parameters:

other – The std::string object to be moved

inline explicit String(TVMFFIByteArray other)#

constructor from TVMFFIByteArray

Parameters:

other – a TVMFFIByteArray.

inline const char *data() const noexcept#

Return the data pointer.

Returns:

const char* data pointer

inline const char *c_str() const noexcept#

Returns a pointer to the char array in the string.

Returns:

const char*

inline size_t size() const noexcept#

Return the length of the string.

Returns:

size_t string length

inline int compare(const String &other) const#

Compares this String object to other.

Parameters:

other – The String to compare with.

Returns:

zero if both char sequences compare equal. negative if this appear before other, positive otherwise.

inline int compare(const std::string &other) const#

Compares this String object to other.

Parameters:

other – The string to compare with.

Returns:

zero if both char sequences compare equal. negative if this appear before other, positive otherwise.

inline int compare(const char *other) const#

Compares this to other.

Parameters:

other – The character array to compare with.

Returns:

zero if both char sequences compare equal. negative if this appear before other, positive otherwise.

inline int compare(const TVMFFIByteArray &other) const#

Compares this to other.

Parameters:

other – The TVMFFIByteArray to compare with.

Returns:

zero if both char sequences compare equal. negative if this appear before other, positive otherwise.

inline size_t length() const#

Return the length of the string.

Returns:

size_t string length

inline bool empty() const#

Retun if the string is empty.

Returns:

true if empty, false otherwise.

inline char at(size_t pos) const#

Read an element.

Parameters:

pos – The position at which to read the character.

Returns:

The char at position