LLVM  14.0.0git
Public Member Functions | List of all members
llvm::SmallString< InternalLen > Class Template Reference

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better as a string (e.g. More...

#include "llvm/ADT/SmallString.h"

Inheritance diagram for llvm::SmallString< InternalLen >:
Inheritance graph
[legend]
Collaboration diagram for llvm::SmallString< InternalLen >:
Collaboration graph
[legend]

Public Member Functions

 SmallString ()=default
 Default ctor - Initialize to empty. More...
 
 SmallString (StringRef S)
 Initialize from a StringRef. More...
 
 SmallString (std::initializer_list< StringRef > Refs)
 Initialize by concatenating a list of StringRefs. More...
 
template<typename ItTy >
 SmallString (ItTy S, ItTy E)
 Initialize with a range. More...
 
String Assignment
void assign (StringRef RHS)
 Assign from a StringRef. More...
 
void assign (std::initializer_list< StringRef > Refs)
 Assign from a list of StringRefs. More...
 
String Concatenation
void append (StringRef RHS)
 Append from a StringRef. More...
 
void append (std::initializer_list< StringRef > Refs)
 Append from a list of StringRefs. More...
 
String Comparison
bool equals (StringRef RHS) const
 Check for string equality. More...
 
bool equals_insensitive (StringRef RHS) const
 Check for string equality, ignoring case. More...
 
int compare (StringRef RHS) const
 Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less than, equal to, or greater than the RHS. More...
 
int compare_insensitive (StringRef RHS) const
 compare_insensitive - Compare two strings, ignoring case. More...
 
int compare_numeric (StringRef RHS) const
 compare_numeric - Compare two strings, treating sequences of digits as numbers. More...
 
String Predicates
bool startswith (StringRef Prefix) const
 startswith - Check if this string starts with the given Prefix. More...
 
bool endswith (StringRef Suffix) const
 endswith - Check if this string ends with the given Suffix. More...
 
String Searching
size_t find (char C, size_t From=0) const
 find - Search for the first character C in the string. More...
 
size_t find (StringRef Str, size_t From=0) const
 Search for the first string Str in the string. More...
 
size_t rfind (char C, size_t From=StringRef::npos) const
 Search for the last character C in the string. More...
 
size_t rfind (StringRef Str) const
 Search for the last string Str in the string. More...
 
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. More...
 
size_t find_first_of (StringRef Chars, size_t From=0) const
 Find the first character in the string that is in Chars, or npos if not found. More...
 
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. More...
 
size_t find_first_not_of (StringRef 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. More...
 
size_t find_last_of (char C, size_t From=StringRef::npos) const
 Find the last character in the string that is C, or npos if not found. More...
 
size_t find_last_of (StringRef Chars, size_t From=StringRef::npos) const
 Find the last character in the string that is in C, or npos if not found. More...
 
Helpful Algorithms
size_t count (char C) const
 Return the number of occurrences of C in the string. More...
 
size_t count (StringRef Str) const
 Return the number of non-overlapped occurrences of Str in the string. More...
 
Substring Operations
StringRef substr (size_t Start, size_t N=StringRef::npos) const
 Return a reference to the substring from [Start, Start + N). More...
 
StringRef slice (size_t Start, size_t End) const
 Return a reference to the substring from [Start, End). More...
 
StringRef str () const
 Explicit conversion to StringRef. More...
 
const char * c_str ()
 
 operator StringRef () const
 Implicit conversion to StringRef. More...
 
 operator std::string () const
 
SmallStringoperator= (StringRef RHS)
 
SmallStringoperator+= (StringRef RHS)
 
SmallStringoperator+= (char C)
 
- Public Member Functions inherited from llvm::SmallVector< char, InternalLen >
 SmallVector ()
 
 SmallVector (size_t Size, const char &Value=char())
 
 SmallVector (ItTy S, ItTy E)
 
 SmallVector (const iterator_range< RangeTy > &R)
 
 SmallVector (std::initializer_list< char > IL)
 
 SmallVector (const SmallVector &RHS)
 
 SmallVector (SmallVector &&RHS)
 
 SmallVector (SmallVectorImpl< char > &&RHS)
 
 ~SmallVector ()
 
SmallVectoroperator= (const SmallVector &RHS)
 
SmallVectoroperator= (SmallVector &&RHS)
 
SmallVectoroperator= (SmallVectorImpl< char > &&RHS)
 
SmallVectoroperator= (std::initializer_list< char > IL)
 
- Public Member Functions inherited from llvm::SmallVectorImpl< char >
 SmallVectorImpl (const SmallVectorImpl &)=delete
 
 ~SmallVectorImpl ()
 
void clear ()
 
void resize (size_type N)
 
void resize (size_type N, ValueParamT NV)
 
void resize_for_overwrite (size_type N)
 Like resize, but T is POD, the new values won't be initialized. More...
 
void reserve (size_type N)
 
void pop_back_n (size_type NumItems)
 
LLVM_NODISCARD char pop_back_val ()
 
void swap (SmallVectorImpl &RHS)
 
void append (in_iter in_start, in_iter in_end)
 Add the specified range to the end of the SmallVector. More...
 
void append (size_type NumInputs, ValueParamT Elt)
 Append NumInputs copies of Elt to the end. More...
 
void append (std::initializer_list< char > IL)
 
void append (const SmallVectorImpl &RHS)
 
void assign (size_type NumElts, ValueParamT Elt)
 
void assign (in_iter in_start, in_iter in_end)
 
void assign (std::initializer_list< char > IL)
 
void assign (const SmallVectorImpl &RHS)
 
iterator erase (const_iterator CI)
 
iterator erase (const_iterator CS, const_iterator CE)
 
iterator insert (iterator I, char &&Elt)
 
iterator insert (iterator I, const char &Elt)
 
iterator insert (iterator I, size_type NumToInsert, ValueParamT Elt)
 
iterator insert (iterator I, ItTy From, ItTy To)
 
void insert (iterator I, std::initializer_list< char > IL)
 
reference emplace_back (ArgTypes &&... Args)
 
SmallVectorImploperator= (const SmallVectorImpl &RHS)
 
SmallVectorImploperator= (SmallVectorImpl &&RHS)
 
bool operator== (const SmallVectorImpl &RHS) const
 
bool operator!= (const SmallVectorImpl &RHS) const
 
bool operator< (const SmallVectorImpl &RHS) const
 

Additional Inherited Members

- Public Types inherited from llvm::SmallVectorImpl< char >
using iterator = typename SuperClass::iterator
 
using const_iterator = typename SuperClass::const_iterator
 
using reference = typename SuperClass::reference
 
using size_type = typename SuperClass::size_type
 
- Protected Types inherited from llvm::SmallVectorImpl< char >
using ValueParamT = typename SuperClass::ValueParamT
 
- Protected Member Functions inherited from llvm::SmallVectorImpl< char >
 SmallVectorImpl (unsigned N)
 

Detailed Description

template<unsigned InternalLen>
class llvm::SmallString< InternalLen >

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better as a string (e.g.

operator+ etc).

Definition at line 25 of file SmallString.h.

Constructor & Destructor Documentation

◆ SmallString() [1/4]

template<unsigned InternalLen>
llvm::SmallString< InternalLen >::SmallString ( )
default

Default ctor - Initialize to empty.

◆ SmallString() [2/4]

template<unsigned InternalLen>
llvm::SmallString< InternalLen >::SmallString ( StringRef  S)
inline

Initialize from a StringRef.

Definition at line 31 of file SmallString.h.

◆ SmallString() [3/4]

template<unsigned InternalLen>
llvm::SmallString< InternalLen >::SmallString ( std::initializer_list< StringRef Refs)
inline

Initialize by concatenating a list of StringRefs.

Definition at line 34 of file SmallString.h.

◆ SmallString() [4/4]

template<unsigned InternalLen>
template<typename ItTy >
llvm::SmallString< InternalLen >::SmallString ( ItTy  S,
ItTy  E 
)
inline

Initialize with a range.

Definition at line 41 of file SmallString.h.

Member Function Documentation

◆ append() [1/2]

template<unsigned InternalLen>
void llvm::SmallString< InternalLen >::append ( std::initializer_list< StringRef Refs)
inline

Append from a list of StringRefs.

Definition at line 72 of file SmallString.h.

◆ append() [2/2]

template<unsigned InternalLen>
void llvm::SmallString< InternalLen >::append ( StringRef  RHS)
inline

◆ assign() [1/2]

template<unsigned InternalLen>
void llvm::SmallString< InternalLen >::assign ( std::initializer_list< StringRef Refs)
inline

Assign from a list of StringRefs.

Definition at line 55 of file SmallString.h.

◆ assign() [2/2]

template<unsigned InternalLen>
void llvm::SmallString< InternalLen >::assign ( StringRef  RHS)
inline

Assign from a StringRef.

Definition at line 50 of file SmallString.h.

Referenced by llvm::SmallString< 256 >::operator=().

◆ c_str()

template<unsigned InternalLen>
const char* llvm::SmallString< InternalLen >::c_str ( )
inline

◆ compare()

template<unsigned InternalLen>
int llvm::SmallString< InternalLen >::compare ( StringRef  RHS) const
inline

Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less than, equal to, or greater than the RHS.

Definition at line 102 of file SmallString.h.

◆ compare_insensitive()

template<unsigned InternalLen>
int llvm::SmallString< InternalLen >::compare_insensitive ( StringRef  RHS) const
inline

compare_insensitive - Compare two strings, ignoring case.

Definition at line 107 of file SmallString.h.

◆ compare_numeric()

template<unsigned InternalLen>
int llvm::SmallString< InternalLen >::compare_numeric ( StringRef  RHS) const
inline

compare_numeric - Compare two strings, treating sequences of digits as numbers.

Definition at line 113 of file SmallString.h.

◆ count() [1/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::count ( char  C) const
inline

Return the number of occurrences of C in the string.

Definition at line 215 of file SmallString.h.

◆ count() [2/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::count ( StringRef  Str) const
inline

Return the number of non-overlapped occurrences of Str in the string.

Definition at line 221 of file SmallString.h.

◆ endswith()

template<unsigned InternalLen>
bool llvm::SmallString< InternalLen >::endswith ( StringRef  Suffix) const
inline

endswith - Check if this string ends with the given Suffix.

Definition at line 127 of file SmallString.h.

◆ equals()

template<unsigned InternalLen>
bool llvm::SmallString< InternalLen >::equals ( StringRef  RHS) const
inline

Check for string equality.

This is more efficient than compare() when the relative ordering of inequal strings isn't needed.

Definition at line 91 of file SmallString.h.

Referenced by llvm::object::ExportEntry::operator==().

◆ equals_insensitive()

template<unsigned InternalLen>
bool llvm::SmallString< InternalLen >::equals_insensitive ( StringRef  RHS) const
inline

Check for string equality, ignoring case.

Definition at line 96 of file SmallString.h.

◆ find() [1/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::find ( char  C,
size_t  From = 0 
) const
inline

find - Search for the first character C in the string.

Returns
- The index of the first occurrence of C, or npos if not found.

Definition at line 139 of file SmallString.h.

◆ find() [2/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::find ( StringRef  Str,
size_t  From = 0 
) const
inline

Search for the first string Str in the string.

Returns
The index of the first occurrence of Str, or npos if not found.

Definition at line 147 of file SmallString.h.

◆ find_first_not_of() [1/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::find_first_not_of ( char  C,
size_t  From = 0 
) const
inline

Find the first character in the string that is not C or npos if not found.

Definition at line 183 of file SmallString.h.

◆ find_first_not_of() [2/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::find_first_not_of ( StringRef  Chars,
size_t  From = 0 
) const
inline

Find the first character in the string that is not in the string Chars, or npos if not found.

Complexity: O(size() + Chars.size())

Definition at line 191 of file SmallString.h.

◆ find_first_of() [1/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::find_first_of ( char  C,
size_t  From = 0 
) const
inline

Find the first character in the string that is C, or npos if not found.

Same as find.

Definition at line 169 of file SmallString.h.

◆ find_first_of() [2/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::find_first_of ( StringRef  Chars,
size_t  From = 0 
) const
inline

Find the first character in the string that is in Chars, or npos if not found.

Complexity: O(size() + Chars.size())

Definition at line 177 of file SmallString.h.

◆ find_last_of() [1/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::find_last_of ( char  C,
size_t  From = StringRef::npos 
) const
inline

Find the last character in the string that is C, or npos if not found.

Definition at line 197 of file SmallString.h.

◆ find_last_of() [2/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::find_last_of ( StringRef  Chars,
size_t  From = StringRef::npos 
) const
inline

Find the last character in the string that is in C, or npos if not found.

Complexity: O(size() + Chars.size())

Definition at line 205 of file SmallString.h.

◆ operator std::string()

template<unsigned InternalLen>
llvm::SmallString< InternalLen >::operator std::string ( ) const
inlineexplicit

Definition at line 271 of file SmallString.h.

◆ operator StringRef()

template<unsigned InternalLen>
llvm::SmallString< InternalLen >::operator StringRef ( ) const
inline

Implicit conversion to StringRef.

Definition at line 269 of file SmallString.h.

◆ operator+=() [1/2]

template<unsigned InternalLen>
SmallString& llvm::SmallString< InternalLen >::operator+= ( char  C)
inline

Definition at line 285 of file SmallString.h.

◆ operator+=() [2/2]

template<unsigned InternalLen>
SmallString& llvm::SmallString< InternalLen >::operator+= ( StringRef  RHS)
inline

Definition at line 281 of file SmallString.h.

◆ operator=()

template<unsigned InternalLen>
SmallString& llvm::SmallString< InternalLen >::operator= ( StringRef  RHS)
inline

Definition at line 276 of file SmallString.h.

◆ rfind() [1/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::rfind ( char  C,
size_t  From = StringRef::npos 
) const
inline

Search for the last character C in the string.

Returns
The index of the last occurrence of C, or npos if not found.

Definition at line 155 of file SmallString.h.

◆ rfind() [2/2]

template<unsigned InternalLen>
size_t llvm::SmallString< InternalLen >::rfind ( StringRef  Str) const
inline

Search for the last string Str in the string.

Returns
The index of the last occurrence of Str, or npos if not found.

Definition at line 163 of file SmallString.h.

◆ slice()

template<unsigned InternalLen>
StringRef llvm::SmallString< InternalLen >::slice ( size_t  Start,
size_t  End 
) const
inline

Return a reference to the substring from [Start, End).

Parameters
StartThe index of the starting character in the substring; if the index is npos or greater than the length of the string then the empty substring will be returned.
EndThe index following the last character to include in the substring. If this is npos, or less than Start, or exceeds the number of characters remaining in the string, the string suffix (starting with Start) will be returned.

Definition at line 252 of file SmallString.h.

◆ startswith()

template<unsigned InternalLen>
bool llvm::SmallString< InternalLen >::startswith ( StringRef  Prefix) const
inline

startswith - Check if this string starts with the given Prefix.

Definition at line 122 of file SmallString.h.

◆ str()

template<unsigned InternalLen>
StringRef llvm::SmallString< InternalLen >::str ( ) const
inline

Explicit conversion to StringRef.

Definition at line 259 of file SmallString.h.

Referenced by llvm::SmallString< 256 >::compare(), llvm::SmallString< 256 >::compare_insensitive(), llvm::SmallString< 256 >::compare_numeric(), llvm::computeArchiveRelativePath(), llvm::SmallString< 256 >::count(), llvm::createGraphFilename(), llvm::MCStreamer::emitIntValue(), llvm::SmallString< 256 >::endswith(), llvm::SmallString< 256 >::equals(), llvm::SmallString< 256 >::equals_insensitive(), llvm::SmallString< 256 >::find(), llvm::SmallString< 256 >::find_first_not_of(), llvm::SmallString< 256 >::find_first_of(), llvm::SmallString< 256 >::find_last_of(), llvm::sys::Process::FindInEnvPath(), llvm::LineEditor::getDefaultHistoryPath(), getDefaultOutputPath(), llvm::MCCVDefRangeFragment::getFixedSizePortion(), llvm::object::Archive::Child::getFullName(), llvm::ModuleSummaryIndex::getGlobalNameForLocal(), llvm::ExecutionEngine::getMangledName(), llvm::OpenMPIRBuilder::getOrCreateSrcLocStr(), llvm::lto::getThinLTOOutputFile(), llvm::localCache(), llvm::LockFileManager::LockFileManager(), llvm::SmallString< 256 >::operator StringRef(), printSymbolizedStackTrace(), llvm::cl::readConfigFile(), llvm::sys::fs::directory_entry::replace_filename(), llvm::SmallString< 256 >::rfind(), llvm::vfs::InMemoryFileSystem::setCurrentWorkingDirectory(), llvm::vfs::RedirectingFileSystem::setCurrentWorkingDirectory(), llvm::VFABI::setVectorVariantNames(), solveTypeName(), llvm::SmallString< 256 >::startswith(), llvm::unittest::TempDir::TempDir(), llvm::cl::TokenizeGNUCommandLine(), llvm::coverage::CoverageFilenamesSectionWriter::write(), llvm::unittest::TempDir::~TempDir(), llvm::unittest::TempFile::~TempFile(), and llvm::unittest::TempLink::~TempLink().

◆ substr()

template<unsigned InternalLen>
StringRef llvm::SmallString< InternalLen >::substr ( size_t  Start,
size_t  N = StringRef::npos 
) const
inline

Return a reference to the substring from [Start, Start + N).

Parameters
StartThe index of the starting character in the substring; if the index is npos or greater than the length of the string then the empty substring will be returned.
NThe number of characters to included in the substring. If N exceeds the number of characters remaining in the string, the string suffix (starting with Start) will be returned.

Definition at line 238 of file SmallString.h.


The documentation for this class was generated from the following file: