14#ifndef WPIUTIL_WPI_SMALLSTRING_H
15#define WPIUTIL_WPI_SMALLSTRING_H
26template<
unsigned InternalLen>
42 template<
typename ItTy>
57 void assign(std::initializer_list<std::string_view> Refs) {
74 void append(std::initializer_list<std::string_view> Refs) {
75 size_t CurrentSize = this->
size();
76 size_t SizeNeeded = CurrentSize;
77 for (std::string_view Ref : Refs)
78 SizeNeeded += Ref.size();
80 for (std::string_view Ref : Refs) {
81 std::copy(Ref.begin(), Ref.end(), this->begin() + CurrentSize);
82 CurrentSize += Ref.size();
84 assert(CurrentSize == this->
size());
94 [[nodiscard]]
int compare(std::string_view RHS)
const {
95 return str().compare(RHS);
106 [[nodiscard]]
size_t find(
char C,
size_t From = 0)
const {
107 return str().find(C, From);
114 [[nodiscard]]
size_t find(std::string_view Str,
size_t From = 0)
const {
115 return str().find(Str, From);
123 size_t From = std::string_view::npos)
const {
124 return str().rfind(C, From);
131 [[nodiscard]]
size_t rfind(std::string_view Str)
const {
132 return str().rfind(Str);
138 return str().find_first_of(C, From);
146 size_t From = 0)
const {
147 return str().find_first_of(Chars, From);
153 return str().find_first_not_of(C, From);
161 size_t From = 0)
const {
162 return str().find_first_not_of(Chars, From);
168 char C,
size_t From = std::string_view::npos)
const {
169 return str().find_last_of(C, From);
177 std::string_view Chars,
size_t From = std::string_view::npos)
const {
178 return str().find_last_of(Chars, From);
186 [[nodiscard]] std::string_view
str()
const {
187 return std::string_view(this->
begin(), this->
size());
198 operator std::string_view()
const {
return str(); }
200 explicit operator std::string()
const {
201 return std::string(this->
data(), this->
size());
211 this->
append(RHS.begin(), RHS.end());
This file defines the SmallVector class.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:27
size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
Definition SmallString.h:152
size_t find_last_of(std::string_view Chars, size_t From=std::string_view::npos) const
Find the last character in the string that is in C, or npos if not found.
Definition SmallString.h:176
size_t find_first_of(std::string_view Chars, size_t From=0) const
Find the first character in the string that is in Chars, or npos if not found.
Definition SmallString.h:145
size_t rfind(char C, size_t From=std::string_view::npos) const
Search for the last character C in the string.
Definition SmallString.h:122
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Definition SmallString.h:137
void assign(std::initializer_list< std::string_view > Refs)
Assign from a list of std::string_views.
Definition SmallString.h:57
std::string_view str() const
Explicit conversion to std::string_view.
Definition SmallString.h:186
size_t find_first_not_of(std::string_view Chars, size_t From=0) const
Find the first character in the string that is not in the string Chars, or npos if not found.
Definition SmallString.h:160
size_t find(char C, size_t From=0) const
find - Search for the first character C in the string.
Definition SmallString.h:106
SmallString(ItTy S, ItTy E)
Initialize with a range.
Definition SmallString.h:43
const char * c_str()
Definition SmallString.h:191
size_t find_last_of(char C, size_t From=std::string_view::npos) const
Find the last character in the string that is C, or npos if not found.
Definition SmallString.h:167
void append(std::string_view RHS)
Append from a std::string_view.
Definition SmallString.h:69
size_t rfind(std::string_view Str) const
Search for the last string Str in the string.
Definition SmallString.h:131
void assign(std::string_view RHS)
Assign from a std::string_view.
Definition SmallString.h:52
void append(std::initializer_list< std::string_view > Refs)
Append from a list of std::string_views.
Definition SmallString.h:74
SmallString & operator=(std::string_view RHS)
Definition SmallString.h:205
size_t find(std::string_view Str, size_t From=0) const
Search for the first string Str in the string.
Definition SmallString.h:114
SmallString(std::string_view S)
Initialize from a std::string_view.
Definition SmallString.h:33
SmallString & operator+=(std::string_view RHS)
Definition SmallString.h:210
SmallString()=default
Default ctor - Initialize to empty.
SmallString(std::initializer_list< std::string_view > Refs)
Initialize by concatenating a list of std::string_views.
Definition SmallString.h:36
int compare(std::string_view RHS) const
compare - Compare two strings; the result is negative, zero, or positive if this string is lexicograp...
Definition SmallString.h:94
SmallString & operator+=(char C)
Definition SmallString.h:214
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1212
void resize_for_overwrite(size_type N)
Definition SmallVector.h:657
void clear()
Definition SmallVector.h:626
void assign(size_type NumElts, ValueParamT Elt)
Definition SmallVector.h:720
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition SmallVector.h:699
void pop_back()
Definition SmallVector.h:441
void push_back(const char &Elt)
Definition SmallVector.h:429
size_t size() const
Definition SmallVector.h:99
pointer data()
Definition SmallVector.h:302
iterator begin()
Definition SmallVector.h:283
Foonathan namespace.
Definition ntcore_cpp.h:26
#define S(label, offset, message)
Definition Errors.h:113