|
|
constexpr | RcStringOrRef ()=default |
| | Create an empty string.
|
|
| ~RcStringOrRef ()=default |
| | Destructor.
|
| constexpr | RcStringOrRef (std::string_view value) |
| | Constructs a new RcStringOrRef containing a non-owning std::string_view.
|
| constexpr | RcStringOrRef (const RcString &value) |
| | Constructs a new RcStringOrRef containing a transferrable RcString.
|
| constexpr | RcStringOrRef (const char *value, size_t len=npos) |
| | Constructs a new RcStringOrRef object from a C-style string reference and optional length.
|
|
constexpr | RcStringOrRef (const RcStringOrRef &other)=default |
| | Copy constructor.
|
|
constexpr | RcStringOrRef (RcStringOrRef &&other) noexcept |
| | Move constructor.
|
|
RcStringOrRef & | operator= (const RcStringOrRef &other)=default |
| | Copy assignment operator.
|
|
RcStringOrRef & | operator= (RcStringOrRef &&other) noexcept |
| | Move assignment operator.
|
|
RcStringOrRef & | operator= (const char *value) |
| | Assignment operator from a C-style string.
|
|
RcStringOrRef & | operator= (std::string_view value) |
| | Assignment operator from a std::string_view.
|
|
RcStringOrRef & | operator= (const RcString &value) |
| | Assignment operator from an RcString.
|
|
| operator std::string_view () const |
| | Cast operator to std::string_view. The returned view aliases this object's storage, so it must not outlive the RcStringOrRef. Annotated with UTILS_LIFETIME_BOUND so Clang's -Wdangling and clang-tidy flag binding the view to a temporary RcStringOrRef.
|
|
| operator RcString () const |
| | Cast operator to RcString. If the internal storage is a long RcString, it will increment the refcount without copying.
|
| const char * | data () const |
| bool | empty () const |
| size_t | size () const |
| std::string | str () const |
| RcStringOrRef | substr (size_t pos, size_t len=npos) const |
| | Returns a substring of the string.
|
|
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.
|
|
|
std::ostream & | operator<< (std::ostream &os, const RcStringOrRef &self) |
| | Ostream output operator.
|
|
auto | operator<=> (const RcStringOrRef &lhs, const RcStringOrRef &rhs) |
| | Spaceship equality operator to another RcStringOrRef.
|
|
template<StringLike StringT> |
| auto | operator<=> (const RcStringOrRef &lhs, const StringT &rhs) |
| | Spaceship equality operator to a StringLike type such as std::string_view or RcString.
|
|
template<StringLike StringT> |
| auto | operator<=> (const StringT &lhs, const RcStringOrRef &rhs) |
| | Spaceship equality operator to a StringLike type such as std::string_view or RcString.
|
|
bool | operator== (const RcStringOrRef &lhs, const RcStringOrRef &rhs) |
| | Equality operator to another RcStringOrRef.
|
|
template<StringLike StringT> |
| bool | operator== (const RcStringOrRef &lhs, const StringT &rhs) |
| | Equality operator to a StringLike type such as std::string_view or RcString.
|
|
template<StringLike StringT> |
| bool | operator== (const StringT &lhs, const RcStringOrRef &rhs) |
| | Reversed equality operator to a StringLike type such as std::string_view or RcString.
|
|
std::string | operator+ (const RcStringOrRef &lhs, const RcStringOrRef &rhs) |
| | Concatenation operator with another RcStringOrRef.
|
|
std::string | operator+ (const RcStringOrRef &lhs, const char *rhs) |
| | Concatenation operator with a C-style string.
|
|
std::string | operator+ (const RcStringOrRef &lhs, std::string_view rhs) |
| | Concatenation operator with a std::string_view.
|
|
std::string | operator+ (std::string_view lhs, const RcStringOrRef &rhs) |
| | Reversed concatenation operator with a std::string_view.
|
|
std::string | operator+ (const char *lhs, const RcStringOrRef &rhs) |
| | Reversed concatenation operator with a C-style string.
|
An in-transit type that can hold either an RcString or std::string_view, to enable transferring the RcString reference or also accepting a non-owning std::string_view from API surfaces.
This can be used either for function arguments, or as a key value for a std::map-like type.
As a function:
}
setString("test");
setString(
RcString(
"will addref if this is larger than the small string optimization"));
constexpr RcStringOrRef()=default
Create an empty string.
A reference counted string, that is copy-on-write and implements the small-string optimization.
Definition RcString.h:35
As a map key:
std::map<RcStringOrRef, int> myMap;
std::string buffer = "view";
myMap[std::string_view(buffer)] = 2;
auto it = myMap.find("key");
const bool found = it != myMap.end();
assert(found);