Class String#
Defined in File string.h
Class Documentation#
-
class String#
String container class.
Public Functions
-
String(std::nullptr_t) = delete#
avoid misuse of nullptr
-
inline String()#
constructor
-
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
-
inline size_t find(const String &str, size_t pos = 0) const#
Find the first occurrence of a substring.
- Parameters:
str – The substring to search for
pos – The position at which to start the search
- Returns:
The position of the first character of the first match, or npos if not found
-
inline size_t find(const char *str, size_t pos = 0) const#
Find the first occurrence of a substring.
- Parameters:
str – The substring to search for
pos – The position at which to start the search
- Returns:
The position of the first character of the first match, or npos if not found
-
inline size_t find(const char *str, size_t pos, size_t count) const#
Find the first occurrence of a substring.
- Parameters:
str – The substring to search for
pos – The position at which to start the search
count – The length of the substring
- Returns:
The position of the first character of the first match, or npos if not found
-
inline String substr(size_t pos = 0, size_t count = npos) const#
Returns a substring [pos, pos+count)
- Parameters:
pos – The position of the first character to include
count – The length of the substring (default: until end of string)
- Returns:
A string containing the substring
-
inline bool starts_with(const String &prefix) const#
Check if the string starts with a prefix.
- Parameters:
prefix – The prefix to check for
- Returns:
true if the string starts with prefix, false otherwise
-
inline bool starts_with(std::string_view prefix) const#
Check if the string starts with a prefix.
- Parameters:
prefix – The prefix to check for
- Returns:
true if the string starts with prefix, false otherwise
-
inline bool starts_with(const char *prefix) const#
Check if the string starts with a prefix.
- Parameters:
prefix – The prefix to check for
- Returns:
true if the string starts with prefix, false otherwise
-
inline bool starts_with(const char *prefix, size_t count) const#
Check if the string starts with a prefix.
- Parameters:
prefix – The prefix to check for
count – The length of the prefix
- Returns:
true if the string starts with prefix, false otherwise
-
inline bool ends_with(const String &suffix) const#
Check if the string ends with a suffix.
- Parameters:
suffix – The suffix to check for
- Returns:
true if the string ends with suffix, false otherwise
-
inline bool ends_with(std::string_view suffix) const#
Check if the string ends with a suffix.
- Parameters:
suffix – The suffix to check for
- Returns:
true if the string ends with suffix, false otherwise
-
inline bool ends_with(const char *suffix) const#
Check if the string ends with a suffix.
- Parameters:
suffix – The suffix to check for
- Returns:
true if the string ends with suffix, false otherwise
-
inline bool ends_with(const char *suffix, size_t count) const#
Check if the string ends with a suffix.
- Parameters:
suffix – The suffix to check for
count – The length of the suffix
- Returns:
true if the string ends with suffix, false otherwise
-
String(std::nullptr_t) = delete#