Blender V4.3
RNAPath Struct Reference

#include <RNA_path.hh>

Public Attributes

std::string path
 
std::optional< std::string > key = std::nullopt
 
std::optional< intindex = std::nullopt
 

Detailed Description

An RNA path to a property, including an optional key/index for array and collection properties.

The semantics around the key and index fields are specific:

  • If a key is specified, that indicates an element of a key-based array property. If an index is also specified alongside the key then the index is just a fallback.
  • If an index is specified but not a key, that indicates an element of an index-based array property.
  • If neither the key nor index are specified, that indicates a property as a whole.

This type is intended to be convenient to construct with initializer lists:

RNAPath path_only = {"dof.focus_distance"};
RNAPath path_with_index = {"location", {}, 2};
RNAPath path_with_key = {"modifiers", "SimpleDeform"};
RNAPath path_with_key_and_index = {"modifiers", "SimpleDeform", 5};

NOTE: some older parts of Blender's code base use negative array indices as a magic value to mean things like "all array elements". However, magic values should specifically NOT be used in this type. Instead, simply leave the index unspecified. Unspecified indices can then be converted to a negative magic value at the API boundaries that need it, like so:

some_older_function(rna_path.index.value_or(-1));

Definition at line 58 of file RNA_path.hh.

Member Data Documentation

◆ index

◆ key

std::optional<std::string> RNAPath::key = std::nullopt

Key/index for array and collection properties. Any combination of index and key can be specified (including neither). In the case that both are specified, they should be redundant ways to access the same element.

Definition at line 65 of file RNA_path.hh.

◆ path

std::string RNAPath::path

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