Blender V4.5
blender::bke::path_templates::VariableMap Class Reference

#include <BKE_path_templates.hh>

Public Member Functions

bool contains (blender::StringRef name) const
bool remove (blender::StringRef name)
bool add_string (blender::StringRef name, blender::StringRef value)
bool add_integer (blender::StringRef name, int64_t value)
bool add_float (blender::StringRef name, double value)
std::optional< blender::StringRefNullget_string (blender::StringRef name) const
std::optional< int64_tget_integer (blender::StringRef name) const
std::optional< double > get_float (blender::StringRef name) const

Detailed Description

Variables (names and associated values) for use in template substitution.

Note that this is not intended to be persistent storage, but rather is transient for collecting data that is relevant/available in a given templating context.

There are currently three supported variable types: string, integer, and float. Names must be unique across all types: you can't have a string and integer both with the name "bob".

Definition at line 42 of file BKE_path_templates.hh.

Member Function Documentation

◆ add_float()

bool blender::bke::path_templates::VariableMap::add_float ( blender::StringRef name,
double value )

Add a float variable with the given name and value.

If there is already a variable with that name, regardless of type, the new variable is not added (no overwriting).

Returns
True if the variable was successfully added, false if there was already a variable with that name.

Definition at line 70 of file path_templates.cc.

References contains().

Referenced by BKE_build_template_variables_for_render_path(), blender::bke::tests::TEST(), and blender::bke::tests::TEST().

◆ add_integer()

bool blender::bke::path_templates::VariableMap::add_integer ( blender::StringRef name,
int64_t value )

Add an integer variable with the given name and value.

If there is already a variable with that name, regardless of type, the new variable is not added (no overwriting).

Returns
True if the variable was successfully added, false if there was already a variable with that name.

Definition at line 61 of file path_templates.cc.

References contains().

Referenced by BKE_build_template_variables_for_render_path(), blender::bke::tests::TEST(), and blender::bke::tests::TEST().

◆ add_string()

bool blender::bke::path_templates::VariableMap::add_string ( blender::StringRef name,
blender::StringRef value )

Add a string variable with the given name and value.

If there is already a variable with that name, regardless of type, the new variable is not added (no overwriting).

Returns
True if the variable was successfully added, false if there was already a variable with that name.

Definition at line 52 of file path_templates.cc.

References contains().

Referenced by BKE_build_template_variables_for_render_path(), blender::bke::tests::TEST(), and blender::bke::tests::TEST().

◆ contains()

bool blender::bke::path_templates::VariableMap::contains ( blender::StringRef name) const

Check if a variable of the given name exists.

Definition at line 24 of file path_templates.cc.

Referenced by add_float(), add_integer(), add_string(), and blender::bke::tests::TEST().

◆ get_float()

std::optional< double > blender::bke::path_templates::VariableMap::get_float ( blender::StringRef name) const

Fetch the value of the float variable with the given name.

Returns
The value if a float variable with that name exists, #std::nullopt otherwise.

Definition at line 97 of file path_templates.cc.

Referenced by eval_template(), and blender::bke::tests::TEST().

◆ get_integer()

std::optional< int64_t > blender::bke::path_templates::VariableMap::get_integer ( blender::StringRef name) const

Fetch the value of the integer variable with the given name.

Returns
The value if a integer variable with that name exists, #std::nullopt otherwise.

Definition at line 88 of file path_templates.cc.

Referenced by eval_template(), and blender::bke::tests::TEST().

◆ get_string()

std::optional< blender::StringRefNull > blender::bke::path_templates::VariableMap::get_string ( blender::StringRef name) const

Fetch the value of the string variable with the given name.

Returns
The value if a string variable with that name exists, #std::nullopt otherwise.

Definition at line 79 of file path_templates.cc.

Referenced by eval_template(), and blender::bke::tests::TEST().

◆ remove()

bool blender::bke::path_templates::VariableMap::remove ( blender::StringRef name)

Remove the variable with the given name.

Returns
True if the variable existed and was removed, false if it didn't exist in the first place.

Definition at line 38 of file path_templates.cc.

Referenced by blender::bke::tests::TEST().


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