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()

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()

◆ copy() [1/2]

◆ 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 add_render_result_meta_data(), 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::ChannelBag::channel_group_create(), blender::animrig::create_fcurve_for_channel(), cryptomatte_determine_identifier(), blender::string_search::damerau_levenshtein_distance(), blender::ed::object::dash_modifier_segment_add_exec(), 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::ed::spreadsheet::get_column_width(), 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::ed::object::bake_simulation::PathStringEquality::operator()(), blender::ed::object::bake_simulation::PathStringHash::operator()(), 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::StringRef::StringRef(), blender::StringRef::StringRef(), blender::StringRef::StringRef(), StringRefBase(), blender::bke::greasepencil::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::ed::object::time_modifier_segment_add_exec(), ui_draw_preview_item_stateless(), UI_panel_drawname_set(), unique_node_name(), versioning_fix_socket_subtype_idnames(), and blender::io::obj::OBJWriter::write_mtllib_name().

◆ end()

◆ 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

◆ 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(), BKE_attribute_calc_unique_name(), BKE_defgroup_listbase_name_find(), BKE_object_defgroup_find_name(), BKE_paint_brush_type_default_reference(), blender::ed::spreadsheet::GreasePencilLayerViewItem::build_row(), blender::ed::spreadsheet::InstanceReferenceViewItem::build_row(), calculate_selection_fcurve_bounds(), blender::gpu::GPUSource::char_literals_preprocess(), blender::gpu::ShaderCompiler::compile(), blender::ed::asset::shelf::create_activate_operator_params(), blender::ed::space_node::create_description_inspection_string(), blender::io::obj::create_geometry(), customData_add_layer__internal(), CustomData_validate_layer_name(), 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::FileHandlerType::get_default_filename(), blender::bke::bake::get_modifier_bake_path(), blender::bke::bake::get_node_bake_path(), get_uv_attribute(), gpu_pass_shader_validate(), blender::gpu::shader::gpu_shader_dependency_get_builtins(), blender::nodes::node_shader_math_cc::gpu_shader_get_name(), blender::compositor::DebugInfo::graphviz(), grease_pencil_layer_cache_add(), 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::io::ply::load_plydata(), 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::io::obj::OBJParser::parse(), blender::io::obj::MTLParser::parse_and_store(), 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(), blender::nodes::node_fn_replace_string_cc::replace_all(), 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(), blender::ui::template_asset_shelf_popover(), blender::io::obj::TEST(), blender::io::obj::TEST(), ui_block_view_find_matching_in_old_block_impl(), ui_but_event_property_operator_string(), ui_draw_preview_item_stateless(), ui_popup_menu_create_block(), ui_tooltip_period_needed(), uiTemplateStatusInfo(), blender::bke::pbvh::pixels::update_pixels(), use_layer_in_render(), blender::fn::multi_function::ProcedureDotExport::variable_to_string(), version_node_socket_id_delim(), blender::gpu::VKShader::vertex_interface_declare(), blender::ed::sculpt_paint::visit_library_catalogs_catalog_for_search(), wm_drag_draw_tooltip(), and blender::io::obj::OBJWriter::write_vertex_coords().

◆ operator Span< char >()

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

Definition at line 175 of file BLI_string_ref.hh.

References data_, and size_.

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

References data_, and size_.

◆ operator std::string_view()

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

Definition at line 189 of file BLI_string_ref.hh.

References data_, and size_.

◆ rfind() [1/2]

◆ 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::gpu::GPUSource::char_literals_preprocess(), blender::gpu::ShaderInterface::copy_input_name(), blender::animrig::create_fcurve_for_channel(), cryptomatte_determine_identifier(), blender::string_search::damerau_levenshtein_distance(), blender::StringRef::drop_known_prefix(), blender::animrig::fcurve_matches_collection_path(), fileentry_uiname(), blender::string_search::get_best_word_index_that_startswith(), blender::ed::spreadsheet::get_column_width(), 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::ed::object::bake_simulation::PathStringHash::operator()(), blender::operator<<(), blender::io::obj::parse_keyword(), blender::io::ply::parse_keyword(), blender::gpu::MSLGeneratorInterface::prepare_from_createinfo(), blender::gpu::shader::ShaderCreateInfo::push_constant(), pyrna_struct_getattro(), blender::bke::cryptomatte::manifest::quoted_string_len_(), blender::gpu::shader::ShaderCreateInfo::sampler(), blender::ed::curves::selection_attribute_writer_by_name(), blender::gpu::shader::ShaderCreateInfo::specialization_constant(), blender::gpu::shader::ShaderCreateInfo::storage_buf(), blender::StringRef::StringRef(), blender::StringRef::StringRef(), blender::StringRef::StringRef(), StringRefBase(), blender::StringRefNull::StringRefNull(), blender::StringRefNull::StringRefNull(), 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(), ui_draw_preview_item_stateless(), UI_panel_drawname_set(), uiTemplateStatusInfo(), blender::gpu::shader::ShaderCreateInfo::uniform_buf(), version_node_socket_id_delim(), and blender::gpu::shader::ShaderCreateInfo::vertex_in().

◆ startswith()

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

Return true when the string starts with the given prefix.

Definition at line 249 of file BLI_string_ref.hh.

References data_, and size_.

Referenced by blender::bke::allow_procedural_attribute_access(), blender::bke::attribute_name_is_anonymous(), blender::deg::DepsgraphRelationBuilder::build_driver_variables(), CustomData_name_maxncpy_calc(), blender::StringRef::drop_known_prefix(), blender::bke::cryptomatte::CryptomatteStampDataCallbackData::extract_layer_hash(), blender::bke::cryptomatte::CryptomatteStampDataCallbackData::extract_layer_manifest(), blender::bke::cryptomatte::CryptomatteStampDataCallbackData::extract_layer_names(), blender::io::obj::geom_update_smooth_group(), blender::string_search::get_best_word_index_that_startswith(), blender::nodes::group_input_insert_link(), blender::nodes::group_output_insert_link(), blender::asset_system::AssetCatalogPath::is_contained_in(), keymap_update_brushes_handle_add_item(), blender::nodes::node_geo_remove_attribute_cc::node_geo_exec(), blender::io::obj::parse_texture_map(), blender::io::obj::parse_texture_option(), blender::asset_system::AssetCatalogDefinitionFile::parse_version_line(), blender::gpu::GPUSource::string_preprocess(), blender::tests::TEST(), ui_but_event_property_operator_string(), ui_tooltip_data_from_button_or_extra_icon(), blender::bke::cryptomatte::tests::validate_cryptomatte_session_from_stamp_data(), version_bonecollection_anim(), version_node_socket_id_delim(), blender::bke::bake::DiskBlobWriter::write_as_stream(), and blender::bke::bake::MemoryBlobWriter::write_as_stream().

◆ substr()

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

Return a new StringRef containing only a sub-string of the original string. This invokes undefined if the start or max_size is negative.

Definition at line 283 of file BLI_string_ref.hh.

References BLI_assert, data_, INT64_MAX, and size_.

Referenced by BKE_asset_metadata_catalog_id_set(), blender::bke::cryptomatte::BKE_cryptomatte_extract_layer_name(), blender::gpu::GPUSource::char_literals_preprocess(), createGPUShader(), blender::gpu::GPUSource::enum_preprocess(), blender::bke::cryptomatte::CryptomatteStampDataCallbackData::extract_layer_hash(), blender::string_search::extract_normalized_words(), blender::bke::greasepencil::convert::AnimDataConvertor::fcurves_convert(), blender::bke::cryptomatte::manifest::from_manifest(), blender::ed::asset::index::init_indexer_entry_from_value(), blender::gpu::GPUSource::material_functions_parse(), blender::nodes::node_geo_remove_attribute_cc::node_geo_exec(), blender::asset_system::utils::normalize_path(), blender::asset_system::AssetCatalogDefinitionFile::parse_catalog_line(), blender::asset_system::AssetCatalogDefinitionFile::parse_version_line(), blender::gpu::GPUSource::print_error(), blender::gpu::Shader::print_log(), blender::gpu::tests::print_test_line(), blender::gpu::GPUSource::printf_preprocess(), blender::asset_system::AssetCatalogPath::rebase(), blender::asset_system::AssetLibraryService::resolve_asset_weak_reference_to_exploded_path(), blender::gpu::GPUSource::string_preprocess(), blender::asset_system::tests::TEST(), blender::tests::TEST(), trim(), ui_but_drawstr_without_sep_char(), and unescape().

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