Blender V5.3
blender::StringRefBase Class Reference

#include <BLI_string_ref.hh>

Public Types

using value_type = char

Public Member Functions

constexpr int64_t size () const
constexpr bool is_empty () const
constexpr const char * data () const
constexpr operator Span< char > () const
 operator std::string () const
constexpr operator std::string_view () const
constexpr const char * begin () const
constexpr const char * end () const
constexpr IndexRange index_range () const
void copy_utf8_truncated (char *dst, int64_t dst_size) const
template<size_t N>
void copy_utf8_truncated (char(&dst)[N]) const
void copy_bytes_truncated (char *dst, int64_t dst_size) const
template<size_t N>
void copy_bytes_truncated (char(&dst)[N]) const
void copy_unsafe (char *dst) const
constexpr bool startswith (StringRef prefix) const
constexpr bool endswith (StringRef suffix) const
constexpr StringRef substr (int64_t start, int64_t size) const
constexpr const char & front () const
constexpr const char & back () const
constexpr int64_t find (char c, int64_t pos=0) const
constexpr int64_t find (StringRef str, int64_t pos=0) const
constexpr int64_t rfind (char c, int64_t pos=INT64_MAX) const
constexpr int64_t rfind (StringRef str, int64_t pos=INT64_MAX) const
constexpr int64_t find_first_of (StringRef chars, int64_t pos=0) const
constexpr int64_t find_first_of (char c, int64_t pos=0) const
constexpr int64_t find_last_of (StringRef chars, int64_t pos=INT64_MAX) const
constexpr int64_t find_last_of (char c, int64_t pos=INT64_MAX) const
constexpr int64_t find_first_not_of (StringRef chars, int64_t pos=0) const
constexpr int64_t find_first_not_of (char c, int64_t pos=0) const
constexpr int64_t find_last_not_of (StringRef chars, int64_t pos=INT64_MAX) const
constexpr int64_t find_last_not_of (char c, int64_t pos=INT64_MAX) const
constexpr StringRef trim () const
constexpr StringRef trim (StringRef characters_to_remove) const
constexpr StringRef trim (char character_to_remove) const
constexpr StringRef trim_left () const
constexpr StringRef trim_left (StringRef characters_to_remove) const
constexpr StringRef trim_right () const
constexpr StringRef trim_right (StringRef characters_to_remove) const

Static Public Attributes

static constexpr int64_t not_found = -1

Protected Member Functions

constexpr StringRefBase (const char *data, int64_t size)

Protected Attributes

const char * data_
int64_t size_

Detailed Description

A common base class for StringRef and StringRefNull. This should never be used in other files. It only exists to avoid some code duplication.

Definition at line 49 of file BLI_string_ref.hh.

Member Typedef Documentation

◆ value_type

Makes this type "string-like" for some libraries (e.g. fmt).

Definition at line 59 of file BLI_string_ref.hh.

Constructor & Destructor Documentation

◆ StringRefBase()

blender::StringRefBase::StringRefBase ( const char * data,
int64_t size )
constexprprotected

References data(), and size().

Member Function Documentation

◆ back()

const char & blender::StringRefBase::back ( ) const
constexpr

◆ begin()

const char * blender::StringRefBase::begin ( ) const
constexpr

◆ copy_bytes_truncated() [1/2]

void blender::StringRefBase::copy_bytes_truncated ( char * dst,
int64_t dst_size ) const

Copy the string into a char array. The copied string will be null-terminated. If it does not fit, it will be truncated.

Note
copy_utf8_truncated should be used UTF8 strings, this should be used for strings which are allowed to contain arbitrary byte sequences without a known encoding such as file-paths.

◆ copy_bytes_truncated() [2/2]

template<size_t N>
void blender::StringRefBase::copy_bytes_truncated ( char(&) dst[N]) const

References N.

◆ copy_unsafe()

void blender::StringRefBase::copy_unsafe ( char * dst) const

Copy the string into a buffer. The buffer has to be one byte larger than the size of the string, because the copied string will be null-terminated. Only use this when you are absolutely sure that the buffer is large enough.

◆ copy_utf8_truncated() [1/2]

void blender::StringRefBase::copy_utf8_truncated ( char * dst,
int64_t dst_size ) const

Copy the string into a char array. The copied string will be null-terminated. If it does not fit, it will be truncated while keeping it valid UTF8 (assuming the StringRef itself is valid UTF8).

◆ copy_utf8_truncated() [2/2]

template<size_t N>
void blender::StringRefBase::copy_utf8_truncated ( char(&) dst[N]) const

References N.

◆ data()

const char * blender::StringRefBase::data ( ) const
constexpr

Referenced by StringRefBase().

◆ end()

const char * blender::StringRefBase::end ( ) const
constexpr

◆ endswith()

bool blender::StringRefBase::endswith ( StringRef suffix) const
constexpr

◆ find() [1/2]

int64_t blender::StringRefBase::find ( char c,
int64_t pos = 0 ) const
constexpr

The behavior of those functions matches the standard library implementation of std::string_view.

Returns
the offset at which the char/string was found, or StringRefBase::not_found when nothing was found.

◆ find() [2/2]

int64_t blender::StringRefBase::find ( StringRef str,
int64_t pos = 0 ) const
constexpr

References str.

◆ find_first_not_of() [1/2]

int64_t blender::StringRefBase::find_first_not_of ( char c,
int64_t pos = 0 ) const
constexpr

◆ find_first_not_of() [2/2]

◆ find_first_of() [1/2]

int64_t blender::StringRefBase::find_first_of ( char c,
int64_t pos = 0 ) const
constexpr

◆ find_first_of() [2/2]

int64_t blender::StringRefBase::find_first_of ( StringRef chars,
int64_t pos = 0 ) const
constexpr

◆ find_last_not_of() [1/2]

References INT64_MAX.

◆ find_last_not_of() [2/2]

◆ find_last_of() [1/2]

int64_t blender::StringRefBase::find_last_of ( char c,
int64_t pos = INT64_MAX ) const
constexpr

References INT64_MAX.

◆ find_last_of() [2/2]

References INT64_MAX.

◆ front()

const char & blender::StringRefBase::front ( ) const
constexpr

◆ index_range()

◆ is_empty()

bool blender::StringRefBase::is_empty ( ) const
constexpr

◆ operator Span< char >()

blender::StringRefBase::operator Span< char > ( ) const
constexpr

◆ operator std::string()

blender::StringRefBase::operator std::string ( ) const

◆ operator std::string_view()

blender::StringRefBase::operator std::string_view ( ) const
constexpr

◆ rfind() [1/2]

int64_t blender::StringRefBase::rfind ( char c,
int64_t pos = INT64_MAX ) const
constexpr

References INT64_MAX.

◆ rfind() [2/2]

References INT64_MAX, and str.

◆ size()

Referenced by StringRefBase(), and substr().

◆ startswith()

bool blender::StringRefBase::startswith ( StringRef prefix) const
constexpr

◆ substr()

StringRef blender::StringRefBase::substr ( int64_t start,
int64_t size ) const
constexpr

References size().

◆ trim() [1/3]

◆ trim() [2/3]

StringRef blender::StringRefBase::trim ( char character_to_remove) const
constexpr

◆ trim() [3/3]

StringRef blender::StringRefBase::trim ( StringRef characters_to_remove) const
constexpr

◆ trim_left() [1/2]

◆ trim_left() [2/2]

StringRef blender::StringRefBase::trim_left ( StringRef characters_to_remove) const
constexpr

◆ trim_right() [1/2]

◆ trim_right() [2/2]

StringRef blender::StringRefBase::trim_right ( StringRef characters_to_remove) const
constexpr

Member Data Documentation

◆ data_

const char* blender::StringRefBase::data_
protected

Definition at line 52 of file BLI_string_ref.hh.

◆ not_found

Similar to #string_view::npos, but signed.

Definition at line 62 of file BLI_string_ref.hh.

Referenced by blender::rna_path_rename_fix().

◆ size_

Definition at line 53 of file BLI_string_ref.hh.


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