Blender V4.3
blender::StringRefBase Class Reference

#include <BLI_string_ref.hh>

Inherited by blender::StringRef, and blender::StringRefNull.

Static Public Attributes

static constexpr int64_t not_found = -1
 

Protected Attributes

const char * data_
 
int64_t size_
 

#StringRefBase Inline Methods

constexpr StringRefBase (const char *data, int64_t size)
 
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 unsafe_copy (char *dst) const
 
void copy (char *dst, int64_t dst_size) const
 
template<size_t N>
void copy (char(&dst)[N]) 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
 

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.

Constructor & Destructor Documentation

◆ StringRefBase()

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

Definition at line 149 of file BLI_string_ref.hh.

Member Function Documentation

◆ back()

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

Get the last char in the string. This invokes undefined behavior when the string is empty.

Definition at line 304 of file BLI_string_ref.hh.

References BLI_assert, data_, and size_.

Referenced by ui_tooltip_period_needed().

◆ begin()

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

Definition at line 194 of file BLI_string_ref.hh.

References data_.

Referenced by blender::io::obj::read_next_line(), and blender::StringRef::StringRef().

◆ copy() [1/2]

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

Copy the string into a buffer. The copied string will be null-terminated. This invokes undefined behavior when dst_size is too small. (Should we define the behavior?)

Definition at line 226 of file BLI_string_ref.hh.

References BLI_assert, size_, and unsafe_copy().

Referenced by BKE_asset_metadata_catalog_id_set(), copy(), blender::bke::bake::file_name_to_frame(), blender::ed::asset::index::init_indexer_entry_from_value(), blender::draw::compositor::Context::set_info_message(), and blender::tests::TEST().

◆ copy() [2/2]

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

Copy the string into a char array. The copied string will be null-terminated. This invokes undefined behavior when dst is too small.

Definition at line 241 of file BLI_string_ref.hh.

References copy(), and N.

◆ data()

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

Return a pointer to the start of the string.

Definition at line 170 of file BLI_string_ref.hh.

References data_.

Referenced by blender::ed::space_node::animation_basepath_change_new(), blender::bke::asset_blendfile_path_for_save(), blender::asset_system::asset_definition_default_file_path_from_dir(), BKE_fcurve_rnapath_set(), blender::animrig::create_fcurve_for_channel(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::execute_multi_layer(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::execute_single_layer_multi_view_exr(), blender::string_search::extract_normalized_words(), blender::ed::spreadsheet::GeometryDataSource::foreach_default_column_ids(), blender::string_search::get_fuzzy_match_errors(), blender::ed::asset::index::init_indexer_entry_from_value(), blender::bke::greasepencil::convert::legacy_object_modifier_influence(), legacy_socket_move_to_interface(), blender::bke::node_interface::make_panel(), blender::bke::forward_compat::make_socket(), blender::bke::node_interface::make_socket(), blender::string_search::match_word_initials(), blender::io::obj::MTLParser::MTLParser(), blender::ed::space_node::node_socket_get_translation_context(), blender::asset_system::utils::normalize_directory_path(), blender::operator<<(), blender::io::obj::parse_keyword(), blender::io::ply::parse_keyword(), blender::deg::RootPChanMap::print_debug(), blender::ed::sculpt_paint::greasepencil::process_stroke_weights(), pyrna_struct_getattro(), blender::ed::spreadsheet::spreadsheet_filter_panel_draw_header(), blender::bke::greasepencil::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::io::obj::OBJWriter::write_mtllib_name().

◆ end()

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

Definition at line 199 of file BLI_string_ref.hh.

References data_, and size_.

Referenced by blender::io::obj::read_next_line().

◆ endswith()

◆ find() [1/2]

◆ find() [2/2]

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

Definition at line 325 of file BLI_string_ref.hh.

References BLI_assert, blender::index_or_npos_to_int64(), pos, and str.

◆ find_first_not_of() [1/2]

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

Definition at line 373 of file BLI_string_ref.hh.

References BLI_assert, blender::index_or_npos_to_int64(), and pos.

◆ find_first_not_of() [2/2]

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

◆ find_first_of() [1/2]

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

Definition at line 349 of file BLI_string_ref.hh.

References BLI_assert, blender::index_or_npos_to_int64(), and pos.

◆ find_first_of() [2/2]

◆ find_last_not_of() [1/2]

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

Definition at line 385 of file BLI_string_ref.hh.

References BLI_assert, blender::index_or_npos_to_int64(), and pos.

◆ find_last_not_of() [2/2]

int64_t blender::StringRefBase::find_last_not_of ( StringRef chars,
int64_t pos = INT64_MAX ) const
constexpr

Definition at line 379 of file BLI_string_ref.hh.

References BLI_assert, blender::index_or_npos_to_int64(), and pos.

Referenced by trim().

◆ find_last_of() [1/2]

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

Definition at line 361 of file BLI_string_ref.hh.

References BLI_assert, blender::index_or_npos_to_int64(), and pos.

◆ find_last_of() [2/2]

int64_t blender::StringRefBase::find_last_of ( StringRef chars,
int64_t pos = INT64_MAX ) const
constexpr

◆ front()

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

Get the first char in the string. This invokes undefined behavior when the string is empty.

Definition at line 295 of file BLI_string_ref.hh.

References BLI_assert, data_, and size_.

Referenced by blender::bke::cryptomatte::manifest::from_manifest().

◆ index_range()

IndexRange blender::StringRefBase::index_range ( ) const
constexpr

Definition at line 204 of file BLI_string_ref.hh.

References size_.

◆ is_empty()

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

Definition at line 162 of file BLI_string_ref.hh.

References size_.

Referenced by blender::animrig::legacy::action_fcurves_remove(), blender::ui::BasicTreeViewItem::add_label(), blender::ed::object::bake_simulation::bake_simulation_get_path_users(), calculate_selection_fcurve_bounds(), blender::gpu::shader::ShaderCreateInfo::check_error(), blender::gpu::ShaderCompiler::compile(), blender::ed::asset::shelf::create_activate_operator_params(), blender::ed::space_node::create_description_inspection_string(), blender::nodes::draw_bake_data_block_list_item(), blender::nodes::draw_common_bake_settings(), blender::ed::spreadsheet::SpreadsheetLayoutDrawer::draw_content_cell(), ED_armature_bone_rename(), blender::animrig::fcurve_matches_collection_path(), filelist_readjob_all_asset_library(), blender::gpu::shader::ShaderCreateInfo::finalize(), blender::nodes::find_output_attributes_to_store(), blender::gpu::GLShader::fragment_interface_declare(), blender::gpu::VKShader::fragment_interface_declare(), blender::bke::cryptomatte::manifest::from_manifest(), blender::io::ply::generate_vertex_map(), blender::asset_system::AssetLibraryService::get_asset_library(), blender::asset_system::AssetLibraryService::get_asset_library_on_disk(), blender::bke::bake::get_modifier_bake_path(), blender::bke::bake::get_node_bake_path(), get_uv_attribute(), blender::nodes::node_shader_math_cc::gpu_shader_get_name(), blender::gpu::VKShader::init(), blender::gpu::tests::ShaderSpecializationConst::init_shader(), blender::ed::object::bake_simulation::initialize_modifier_bake_directory_if_necessary(), blender::gpu::shader::is_vulkan_compatible_interface(), blender::bke::node_interface::make_panel(), blender::bke::node_interface::make_socket(), blender::ed::space_node::node_socket_get_translation_context(), blender::bke::nodeSocketShortLabel(), blender::asset_system::utils::normalize_directory_path(), blender::ed::outliner::outliner_draw_get_warning_tree_element(), blender::ed::outliner::outliner_draw_get_warning_tree_element_subtree(), blender::ed::outliner::outliner_draw_overrides_rna_buts(), blender::ed::outliner::outliner_draw_warning_column(), paint_brush_set_default_reference(), blender::asset_system::AssetCatalogDefinitionFile::parse_catalog_file(), blender::gpu::MTLLogParser::parse_line(), blender::gpu::print_interface(), print_interface(), blender::gpu::Shader::print_log(), pyrna_struct_getattro(), rna_path_from_ptr_to_property_index_ex(), rna_prepend_real_ID_path(), blender::ed::spreadsheet::spreadsheet_filter_panel_draw(), blender::ed::spreadsheet::spreadsheet_filter_panel_draw_header(), blender::io::obj::OBJMesh::store_uv_coords_and_indices(), ui_block_view_find_matching_in_old_block_impl(), ui_but_event_property_operator_string(), ui_popup_menu_create_block(), ui_tooltip_period_needed(), uiTemplateStatusInfo(), blender::bke::pbvh::pixels::update_pixels(), version_node_socket_id_delim(), blender::gpu::VKShader::vertex_interface_declare(), blender::ed::sculpt_paint::visit_library_catalogs_catalog_for_search(), and wm_drag_draw_tooltip().

◆ operator Span< char >()

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

Definition at line 175 of file BLI_string_ref.hh.

◆ operator std::string()

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

Implicitly convert to std::string. This is convenient in most cases, but you have to be a bit careful not to convert to std::string accidentally.

Definition at line 184 of file BLI_string_ref.hh.

◆ operator std::string_view()

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

Definition at line 189 of file BLI_string_ref.hh.

◆ rfind() [1/2]

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

◆ rfind() [2/2]

int64_t blender::StringRefBase::rfind ( StringRef str,
int64_t pos = INT64_MAX ) const
constexpr

Definition at line 337 of file BLI_string_ref.hh.

References BLI_assert, blender::index_or_npos_to_int64(), pos, and str.

◆ size()

int64_t blender::StringRefBase::size ( ) const
constexpr

Return the (byte-)length of the referenced string, without any null-terminator.

Definition at line 157 of file BLI_string_ref.hh.

References size_.

Referenced by blender::ed::space_node::animation_basepath_change_new(), blender::bke::asset_blendfile_path_for_save(), blender::bke::cryptomatte::BKE_cryptomatte_extract_layer_name(), BKE_fcurve_rnapath_set(), blender::LinearAllocator< Allocator >::copy_string(), blender::animrig::create_fcurve_for_channel(), blender::StringRef::drop_known_prefix(), blender::animrig::fcurve_matches_collection_path(), fileentry_uiname(), blender::string_search::get_best_word_index_that_startswith(), blender::string_search::get_fuzzy_match_errors(), blender::gpu::GLShaderInterface::GLShaderInterface(), icon_source_edit_cb(), blender::gpu::shader::ShaderCreateInfo::image(), blender::bke::node_interface::make_panel(), blender::bke::node_interface::make_socket(), blender::string_search::match_word_initials(), blender::asset_system::utils::normalize_directory_path(), blender::asset_system::utils::normalize_path(), blender::operator<<(), blender::io::obj::parse_keyword(), blender::io::ply::parse_keyword(), pyrna_struct_getattro(), blender::bke::cryptomatte::manifest::quoted_string_len_(), blender::ed::curves::selection_attribute_writer_by_name(), blender::gpu::shader::ShaderCreateInfo::storage_buf(), svg_replace_color_attributes(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), uiTemplateStatusInfo(), and blender::gpu::shader::ShaderCreateInfo::uniform_buf().

◆ startswith()

◆ substr()

◆ trim() [1/3]

◆ trim() [2/3]

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

Return a new StringRef that does not contain leading and trailing white-space.

Definition at line 399 of file BLI_string_ref.hh.

References trim().

◆ trim() [3/3]

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

Return a new StringRef that removes all the leading and trailing characters that occur in characters_to_remove.

Definition at line 408 of file BLI_string_ref.hh.

References BLI_assert_msg, find_first_not_of(), find_last_not_of(), not_found, and substr().

◆ unsafe_copy()

void blender::StringRefBase::unsafe_copy ( char * dst) const
inline

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.

Definition at line 214 of file BLI_string_ref.hh.

References data_, and size_.

Referenced by copy().

Member Data Documentation

◆ data_

◆ not_found

◆ size_


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