LLVM OpenMP* Runtime Library
Public Member Functions | List of all members
kmp_str_ref Class Referencefinal

kmp_str_ref is a non-owning string class (similar to llvm::StringRef). More...

#include <kmp_adt.h>

Public Member Functions

bool consume_front (kmp_str_ref prefix)
 
bool consume_integer (int &value, bool allow_zero=true, bool allow_negative=false)
 
char * copy () const
 
template<typename Fn >
size_t count_while (const Fn &predicate) const
 
void drop_front (size_t n)
 
template<typename Fn >
void drop_while (const Fn &predicate)
 Drop characters from the string while the predicate returns true.
 
bool empty () const
 Check if the string is empty.
 
template<typename Fn >
size_t find_if (const Fn &predicate) const
 
template<typename Fn >
size_t find_if_not (const Fn &predicate) const
 
size_t length () const
 Get the length of the string.
 
void skip_space ()
 Drop space from the start of the string.
 
template<typename Fn >
kmp_str_ref take_while (const Fn &predicate) const
 
const char * begin () const
 Iterator support (raw pointers work as iterators for contiguous storage)
 

Detailed Description

kmp_str_ref is a non-owning string class (similar to llvm::StringRef).

Definition at line 34 of file kmp_adt.h.

Member Function Documentation

◆ consume_front()

bool kmp_str_ref::consume_front ( kmp_str_ref  prefix)
inline

Check if the string starts with the given prefix and remove it from the string afterwards.

Definition at line 51 of file kmp_adt.h.

Referenced by consume_integer().

◆ consume_integer()

bool kmp_str_ref::consume_integer ( int &  value,
bool  allow_zero = true,
bool  allow_negative = false 
)

Start consuming an integer from the start of the string and remove it from the string afterwards. The maximum integer value that can currently be parsed is INT_MAX - 1.

Definition at line 27 of file kmp_adt.cpp.

◆ copy()

char * kmp_str_ref::copy ( ) const

Get an own duplicate of the string. Must be freed with KMP_INTERNAL_FREE().

Definition at line 56 of file kmp_adt.cpp.

◆ count_while()

template<typename Fn >
size_t kmp_str_ref::count_while ( const Fn &  predicate) const
inline

Count the number of characters in the string while the predicate returns true.

Definition at line 74 of file kmp_adt.h.

Referenced by consume_integer(), drop_while(), and take_while().

◆ drop_front()

void kmp_str_ref::drop_front ( size_t  n)
inline

Drop the first n characters from the string. (Limit n to the length of the string.)

Definition at line 83 of file kmp_adt.h.

Referenced by consume_front(), consume_integer(), and drop_while().

◆ find_if()

template<typename Fn >
size_t kmp_str_ref::find_if ( const Fn &  predicate) const
inline

Return the index of the first character in the string for which the predicate returns true. Returns npos if no match is found.

Definition at line 103 of file kmp_adt.h.

Referenced by find_if_not().

◆ find_if_not()

template<typename Fn >
size_t kmp_str_ref::find_if_not ( const Fn &  predicate) const
inline

Return the index of the first character in the string for which the predicate returns false. Returns npos if no match is found.

Definition at line 115 of file kmp_adt.h.

Referenced by count_while().

◆ take_while()

template<typename Fn >
kmp_str_ref kmp_str_ref::take_while ( const Fn &  predicate) const
inline

Construct a new string with the longest prefix of the original string that satisfies the predicate. Doesn't modify the original string.

Definition at line 134 of file kmp_adt.h.


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