A reference counted string, that is copy-on-write and implements the small-string optimization.
More...
|
|
| RcString ()=default |
| | Create an empty string.
|
|
| ~RcString ()=default |
| | Destructor.
|
| | RcString (std::string_view data) |
| | Constructs a new RcString object by copying an existing string.
|
| | RcString (const char *data, size_t len=npos) |
| | Constructs a new RcString object from a C-style string and optional length.
|
|
| RcString (const RcString &other)=default |
| | Copy constructor.
|
|
| RcString (RcString &&other) noexcept=default |
| | Move constructor.
|
|
RcString & | operator= (const RcString &other)=default |
| | Copy assignment operator.
|
|
RcString & | operator= (RcString &&other) noexcept=default |
| | Move assignment operator.
|
|
RcString & | operator= (const char *data) |
| | Assignment operator from a C-style string.
|
|
RcString & | operator= (std::string_view data) |
| | Assignment operator from a std::string_view.
|
|
| operator std::string_view () const |
| | Cast operator to std::string_view.
|
| const char * | data () const |
| bool | empty () const |
| size_t | size () const |
| std::string | str () const |
|
const_iterator | begin () const noexcept |
| | Begin iterator.
|
|
const_iterator | end () const noexcept |
| | End iterator.
|
|
const_iterator | cbegin () const noexcept |
| | Begin iterator.
|
|
const_iterator | cend () const noexcept |
| | End iterator.
|
| bool | equalsLowercase (std::string_view lowercaseOther) const |
| | Returns true if the string equals another all-lowercase string, with a case insensitive comparison.
|
| bool | equalsIgnoreCase (std::string_view other) const |
| | Returns true if the string equals another string with a case-insensitive comparison.
|
| RcString | substr (size_t pos, size_t len=npos) const |
| | Returns a substring of the string, returning a reference to the original string's data.
|
| void | dedup () |
| | Deduplicates the string, updating its underlying storage to ensure that it has a unique reference to the underlying contents.
|
|
|
std::ostream & | operator<< (std::ostream &os, const RcString &self) |
| | Ostream output operator.
|
|
auto | operator<=> (const RcString &lhs, const RcString &rhs) |
| | Spaceship equality operator to another RcString.
|
|
auto | operator<=> (const RcString &lhs, const char *rhs) |
| | Spaceship equality operator to a C-style string.
|
|
auto | operator<=> (const RcString &lhs, std::string_view rhs) |
| | Spaceship equality operator to a std::string_view.
|
|
auto | operator<=> (const char *lhs, const RcString &rhs) |
| | Spaceship equality operator to another RcString.
|
|
auto | operator<=> (std::string_view lhs, const RcString &rhs) |
| | Spaceship equality operator to a C-style string.
|
|
bool | operator== (const RcString &lhs, const RcString &rhs) |
| | Equality operator to another RcString.
|
|
bool | operator== (const RcString &lhs, const char *rhs) |
| | Equality operator to a C-style string.
|
|
bool | operator== (const RcString &lhs, std::string_view rhs) |
| | Equality operator to a std::string_view.
|
|
bool | operator== (const char *lhs, const RcString &rhs) |
| | Reversed equality operator to another RcString.
|
|
bool | operator== (std::string_view lhs, const RcString &rhs) |
| | Reversed equality operator to a C-style string.
|
|
std::string | operator+ (const RcString &lhs, const RcString &rhs) |
| | Concatenation operator with another RcString.
|
|
std::string | operator+ (const RcString &lhs, const char *rhs) |
| | Concatenation operator with a C-style string.
|
|
std::string | operator+ (const RcString &lhs, std::string_view rhs) |
| | Concatenation operator with a std::string_view.
|
|
std::string | operator+ (std::string_view lhs, const RcString &rhs) |
| | Reversed concatenation operator with a C-style string.
|
|
std::string | operator+ (const char *lhs, const RcString &rhs) |
| | Reversed concatenation operator with a std::string_view.
|
A reference counted string, that is copy-on-write and implements the small-string optimization.
Implements a short-string optimization similar to the libc++ std::string class, see https://joellaity.com/2020/01/31/string.html for details.
USAGE NOTES:
- This class is not thread-safe, and should not be shared between threads without synchronization.
- data() is not guaranteed to remain stable across references, and should not be stored longer than the original RcString which created it.