LLVM OpenMP
kmp_str_ref Class Referencefinal

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

#include "/work/as-worker-4/publish-doxygen-docs/llvm-project/openmp/runtime/src/kmp_adt.h"

Public Member Functions

 kmp_str_ref (const char *str)
 kmp_str_ref (const char *str, size_t len)
 kmp_str_ref (const kmp_str_ref &other)=default
kmp_str_refoperator= (const kmp_str_ref &other)=default
bool consume_front (kmp_str_ref prefix)
 Check if the string starts with the given prefix and remove it from the string afterwards.
bool 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.
charcopy () const
 Get an own duplicate of the string.
template<typename Fn>
size_t count_while (const Fn &predicate) const
 Count the number of characters in the string while the predicate returns true.
void drop_front (size_t n)
 Drop the first n characters from the string.
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
 Return the index of the first character in the string for which the predicate returns true.
template<typename Fn>
size_t find_if_not (const Fn &predicate) const
 Return the index of the first character in the string for which the predicate returns false.
size_t length () const
 Get the length of the string.
size_t size () const
void skip_space ()
 Drop space from the start of the string.
template<typename Fn>
kmp_str_ref take_while (const Fn &predicate) const
 Construct a new string with the longest prefix of the original string that satisfies the predicate.
const charbegin () const
 Iterator support (raw pointers work as iterators for contiguous storage)
const charend () const

Static Public Attributes

static constexpr size_t npos = SIZE_MAX

Detailed Description

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

Definition at line 31 of file kmp_adt.h.

Constructor & Destructor Documentation

◆ kmp_str_ref() [1/3]

kmp_str_ref::kmp_str_ref ( const char * str)
inline

Definition at line 38 of file kmp_adt.h.

Referenced by consume_front(), consume_integer(), kmp_str_ref(), operator=(), and take_while().

◆ kmp_str_ref() [2/3]

kmp_str_ref::kmp_str_ref ( const char * str,
size_t len )
inline

Definition at line 39 of file kmp_adt.h.

◆ kmp_str_ref() [3/3]

kmp_str_ref::kmp_str_ref ( const kmp_str_ref & other)
default

References kmp_str_ref().

Member Function Documentation

◆ begin()

const char * kmp_str_ref::begin ( ) const
inline

Iterator support (raw pointers work as iterators for contiguous storage)

Definition at line 138 of file kmp_adt.h.

◆ 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 48 of file kmp_adt.h.

References drop_front(), empty(), and kmp_str_ref().

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.

References __kmp_basic_str_to_int(), consume_front(), count_while(), drop_front(), kmp_str_ref(), and value.

◆ 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.

References KMP_FATAL, and KMP_INTERNAL_MALLOC.

◆ 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 71 of file kmp_adt.h.

References find_if_not(), and npos.

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 80 of file kmp_adt.h.

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

◆ drop_while()

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

Drop characters from the string while the predicate returns true.

Definition at line 88 of file kmp_adt.h.

References count_while(), and drop_front().

Referenced by skip_space().

◆ empty()

bool kmp_str_ref::empty ( ) const
inline

Check if the string is empty.

Definition at line 95 of file kmp_adt.h.

Referenced by consume_front().

◆ end()

const char * kmp_str_ref::end ( ) const
inline

Definition at line 139 of file kmp_adt.h.

◆ 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 100 of file kmp_adt.h.

References i, and npos.

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 112 of file kmp_adt.h.

References find_if().

Referenced by count_while().

◆ length()

size_t kmp_str_ref::length ( ) const
inline

Get the length of the string.

Definition at line 119 of file kmp_adt.h.

Referenced by size().

◆ operator=()

kmp_str_ref & kmp_str_ref::operator= ( const kmp_str_ref & other)
default

References kmp_str_ref().

◆ size()

size_t kmp_str_ref::size ( ) const
inline

Definition at line 120 of file kmp_adt.h.

References length().

◆ skip_space()

void kmp_str_ref::skip_space ( )
inline

Drop space from the start of the string.

Definition at line 123 of file kmp_adt.h.

References drop_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 131 of file kmp_adt.h.

References count_while(), and kmp_str_ref().

Member Data Documentation

◆ npos

size_t kmp_str_ref::npos = SIZE_MAX
staticconstexpr

Definition at line 36 of file kmp_adt.h.

Referenced by count_while(), and find_if().


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