LLVM  6.0.0svn
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...
 
template<typename ItTy >
 SmallString (ItTy S, ItTy E)
 Initialize with a range. More...
 
String Assignment
void assign (size_t NumElts, char Elt)
 Assign from a repeated element. More...
 
template<typename in_iter >
void assign (in_iter S, in_iter E)
 Assign from an iterator pair. More...
 
void assign (StringRef RHS)
 Assign from a StringRef. More...
 
void assign (const SmallVectorImpl< char > &RHS)
 Assign from a SmallVector. More...
 
String Concatenation
template<typename in_iter >
void append (in_iter S, in_iter E)
 Append from an iterator pair. More...
 
void append (size_t NumInputs, char Elt)
 
void append (StringRef RHS)
 Append from a StringRef. More...
 
void append (const SmallVectorImpl< char > &RHS)
 Append from a SmallVector. More...
 
String Comparison
bool equals (StringRef RHS) const
 Check for string equality. More...
 
bool equals_lower (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_lower (StringRef RHS) const
 compare_lower - 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 charc_str ()
 
 operator StringRef () const
 Implicit conversion to StringRef. More...
 
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)
 
const SmallVectoroperator= (const SmallVector &RHS)
 
const SmallVectoroperator= (SmallVector &&RHS)
 
const SmallVectoroperator= (SmallVectorImpl< char > &&RHS)
 
const 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, const char &NV)
 
void reserve (size_type N)
 
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, const char &Elt)
 Add the specified range to the end of the SmallVector. More...
 
void append (std::initializer_list< char > IL)
 
void assign (size_type NumElts, const char &Elt)
 
void assign (in_iter in_start, in_iter in_end)
 
void assign (std::initializer_list< char > IL)
 
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, const char &Elt)
 
iterator insert (iterator I, ItTy From, ItTy To)
 
void insert (iterator I, std::initializer_list< char > IL)
 
void 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
 
void set_size (size_type N)
 Set the array size to N, which the current array must have enough capacity for. More...
 
- Public Member Functions inherited from llvm::SmallVectorTemplateBase< T, isPodLike >
void push_back (const T &Elt)
 
void push_back (T &&Elt)
 
void pop_back ()
 
- Public Member Functions inherited from llvm::SmallVectorTemplateCommon< T >
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin ()
 
LLVM_ATTRIBUTE_ALWAYS_INLINE const_iterator begin () const
 
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end ()
 
LLVM_ATTRIBUTE_ALWAYS_INLINE const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size () const
 
size_type max_size () const
 
size_t capacity () const
 Return the total number of elements in the currently allocated buffer. More...
 
pointer data ()
 Return a pointer to the vector's buffer, even if empty(). More...
 
const_pointer data () const
 Return a pointer to the vector's buffer, even if empty(). More...
 
LLVM_ATTRIBUTE_ALWAYS_INLINE reference operator[] (size_type idx)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE const_reference operator[] (size_type idx) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
- Public Member Functions inherited from llvm::SmallVectorBase
size_t size_in_bytes () const
 This returns size()*sizeof(T). More...
 
size_t capacity_in_bytes () const
 capacity_in_bytes - This returns capacity()*sizeof(T). More...
 
LLVM_NODISCARD bool empty () const
 

Additional Inherited Members

- Public Types inherited from llvm::SmallVectorImpl< char >
using iterator = typename SuperClass::iterator
 
using const_iterator = typename SuperClass::const_iterator
 
using size_type = typename SuperClass::size_type
 
- Public Types inherited from llvm::SmallVectorTemplateCommon< T >
using size_type = size_t
 
using difference_type = ptrdiff_t
 
using value_type = T
 
using iterator = T *
 
using const_iterator = const T *
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using reference = T &
 
using const_reference = const T &
 
using pointer = T *
 
using const_pointer = const T *
 
- Protected Member Functions inherited from llvm::SmallVectorImpl< char >
 SmallVectorImpl (unsigned N)
 
- Protected Member Functions inherited from llvm::SmallVectorTemplateBase< T, isPodLike >
 SmallVectorTemplateBase (size_t Size)
 
void grow (size_t MinSize=0)
 Grow the allocated memory (without initializing new elements), doubling the size of the allocated memory. More...
 
- Protected Member Functions inherited from llvm::SmallVectorTemplateCommon< T >
 SmallVectorTemplateCommon (size_t Size)
 
void grow_pod (size_t MinSizeInBytes, size_t TSize)
 
bool isSmall () const
 Return true if this is a smallvector which has not had dynamic memory allocated for it. More...
 
void resetToSmall ()
 Put this vector in a state of being small. More...
 
void setEnd (T *P)
 
iterator capacity_ptr ()
 
const_iterator capacity_ptr () const
 
- Protected Member Functions inherited from llvm::SmallVectorBase
 SmallVectorBase (void *FirstEl, size_t Size)
 
void grow_pod (void *FirstEl, size_t MinSizeInBytes, size_t TSize)
 This is an implementation of the grow() method which only works on POD-like data types and is out of line to reduce code duplication. More...
 
- Static Protected Member Functions inherited from llvm::SmallVectorTemplateBase< T, isPodLike >
static void destroy_range (T *S, T *E)
 
template<typename It1 , typename It2 >
static void uninitialized_move (It1 I, It1 E, It2 Dest)
 Move the range [I, E) into the uninitialized memory starting with "Dest", constructing elements as needed. More...
 
template<typename It1 , typename It2 >
static void uninitialized_copy (It1 I, It1 E, It2 Dest)
 Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements as needed. More...
 
- Protected Attributes inherited from llvm::SmallVectorBase
void * BeginX
 
void * EndX
 
void * CapacityX
 

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 26 of file SmallString.h.

Constructor & Destructor Documentation

◆ SmallString() [1/3]

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

Default ctor - Initialize to empty.

◆ SmallString() [2/3]

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

Initialize from a StringRef.

Definition at line 32 of file SmallString.h.

◆ SmallString() [3/3]

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

Initialize with a range.

Definition at line 36 of file SmallString.h.

Member Function Documentation

◆ append() [1/4]

template<unsigned InternalLen>
template<typename in_iter >
void llvm::SmallString< InternalLen >::append ( in_iter  S,
in_iter  E 
)
inline

◆ append() [2/4]

template<unsigned InternalLen>
void llvm::SmallString< InternalLen >::append ( size_t  NumInputs,
char  Elt 
)
inline

Definition at line 79 of file SmallString.h.

◆ append() [3/4]

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

Append from a StringRef.

Definition at line 84 of file SmallString.h.

◆ append() [4/4]

template<unsigned InternalLen>
void llvm::SmallString< InternalLen >::append ( const SmallVectorImpl< char > &  RHS)
inline

Append from a SmallVector.

Definition at line 89 of file SmallString.h.

◆ assign() [1/4]

template<unsigned InternalLen>
void llvm::SmallString< InternalLen >::assign ( size_t  NumElts,
char  Elt 
)
inline

Assign from a repeated element.

Definition at line 46 of file SmallString.h.

◆ assign() [2/4]

template<unsigned InternalLen>
template<typename in_iter >
void llvm::SmallString< InternalLen >::assign ( in_iter  S,
in_iter  E 
)
inline

Assign from an iterator pair.

Definition at line 52 of file SmallString.h.

◆ assign() [3/4]

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

Assign from a StringRef.

Definition at line 58 of file SmallString.h.

◆ assign() [4/4]

template<unsigned InternalLen>
void llvm::SmallString< InternalLen >::assign ( const SmallVectorImpl< char > &  RHS)
inline

Assign from a SmallVector.

Definition at line 64 of file SmallString.h.

◆ 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 110 of file SmallString.h.

◆ compare_lower()

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

compare_lower - Compare two strings, ignoring case.

Definition at line 115 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 121 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 223 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 229 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 135 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 99 of file SmallString.h.

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

◆ equals_lower()

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

Check for string equality, ignoring case.

Definition at line 104 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 147 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 155 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 191 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 199 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 177 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 185 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 205 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 213 of file SmallString.h.

◆ operator StringRef()

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

Implicit conversion to StringRef.

Definition at line 277 of file SmallString.h.

◆ operator+=() [1/2]

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

Definition at line 285 of file SmallString.h.

◆ operator+=() [2/2]

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

Definition at line 289 of file SmallString.h.

◆ operator=()

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

Definition at line 280 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 163 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 171 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 260 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 130 of file SmallString.h.

◆ str()

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

Explicit conversion to StringRef.

Definition at line 267 of file SmallString.h.

Referenced by llvm::SmallString< 256 >::compare(), llvm::SmallString< 256 >::compare_lower(), llvm::SmallString< 256 >::compare_numeric(), computeRelativePath(), llvm::SmallString< 256 >::count(), CrashHandler(), llvm::createGraphFilename(), emitComments(), llvm::StringToOffsetTable::EmitString(), llvm::SmallString< 256 >::endswith(), llvm::SmallString< 256 >::equals(), llvm::SmallString< 256 >::equals_lower(), ExpandResponseFile(), 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(), findInputFile(), llvm::symbolize::LLVMSymbolizer::flush(), getAttrFromCode(), getChompedLineBreaks(), llvm::LanaiMCInstLower::GetConstantPoolIndexSymbol(), llvm::yaml::Input::getCurrentNode(), llvm::LineEditor::getDefaultHistoryPath(), llvm::DWARFDebugLine::LineTable::getFileNameByIndex(), getFunctionName(), llvm::ModuleSummaryIndex::getGlobalNameForLocal(), getImplibPath(), llvm::LanaiMCInstLower::GetJumpTableSymbol(), llvm::ExecutionEngine::getMangledName(), getOutputPath(), llvm::lto::getThinLTOOutputFile(), llvm::object::MachOObjectFile::getVersionString(), llvm::lto::localCache(), mangleCoveragePath(), llvm::SmallString< 256 >::operator StringRef(), printSymbolizedStackTrace(), llvm::sys::fs::directory_entry::replace_filename(), llvm::SmallString< 256 >::rfind(), llvm::HexagonTargetObjectFile::shouldPutJumpTableInFunctionSection(), llvm::SmallString< 256 >::slice(), llvm::SmallString< 256 >::startswith(), llvm::SmallString< 256 >::substr(), llvm::APInt::toString(), and writeGeneratedObject().

◆ 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 246 of file SmallString.h.

Referenced by llvm::X86TargetMachine::getSubtargetImpl().


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