Blender V5.3
BKE_path_templates.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
65#pragma once
66
67#include <cmath>
68#include <optional>
69
70#include "BLI_map.hh"
71#include "BLI_path_utils.hh"
72#include "BLI_string.hh"
73#include "BLI_string_ref.hh"
74#include "BLI_string_utils.hh"
75
77#include "BKE_report.hh"
78
79#include "DNA_node_types.h"
80#include "DNA_scene_types.h"
81
82/* Collapsed abbreviation to use when shortening path template strings for viewing purposes. */
83#define BKE_TEMPLATE_EXPRESSION_ABBREVIATION "{" BLI_STR_UTF8_HORIZONTAL_ELLIPSIS "}"
84
85namespace blender {
86
87struct bContext;
88struct PointerRNA;
89struct PropertyRNA;
90
92
122
123 public:
127 bool contains(StringRef name) const;
128
135 bool remove(StringRef name);
136
146 bool add_string(StringRef name, StringRef value);
147
157 bool add_filepath(StringRef name, StringRef value);
158
168 bool add_integer(StringRef name, int64_t value);
169
179 bool add_float(StringRef name, double value);
180
187 std::optional<StringRefNull> get_string(StringRef name) const;
188
195 std::optional<StringRefNull> get_filepath(StringRef name) const;
196
203 std::optional<int64_t> get_integer(StringRef name) const;
204
211 std::optional<double> get_float(StringRef name) const;
212
213 /* ------------------------------------------------------------------
214 * Convenience methods, to aid in consistency across different uses. */
215
231 bool add_filename_only(StringRef var_name, StringRefNull full_path, StringRef fallback);
232
248 bool add_path_up_to_file(StringRef var_name, StringRefNull full_path, StringRef fallback);
249};
250
269
276
281
282bool operator==(const Error &left, const Error &right);
283
291std::optional<ExpressionInfo> next_template_variable_expression(StringRef text,
292 size_t starting_offset);
293
294} // namespace bke::path_templates
295
308std::optional<bke::path_templates::VariableMap> BKE_build_template_variables_for_prop(
309 const bContext *C, PointerRNA *ptr, PropertyRNA *prop);
310
318
337 const ID *path_owner_id,
339
357 const Scene &scene);
358
371 const bNode &owning_node);
372
376std::string BKE_path_template_escape(StringRef text);
377
389
402 StringRef path, const bke::path_templates::VariableMap &template_variables);
403
444 char *path, int path_maxncpy, const bke::path_templates::VariableMap &template_variables);
445
460 char **path, int path_maxncpy, const bke::path_templates::VariableMap &template_variables);
461
466 StringRef path);
467
473 eReportType report_type,
474 StringRef path,
476
483std::optional<std::string> BKE_path_template_format_float(StringRef format_specifier,
484 double value);
485
487std::optional<std::string> BKE_path_template_format_int(StringRef format_specifier, int64_t value);
488
489} // namespace blender
#define C
Definition RandGen.cpp:29
std::optional< int64_t > get_integer(StringRef name) const
bool add_filename_only(StringRef var_name, StringRefNull full_path, StringRef fallback)
bool add_float(StringRef name, double value)
bool add_path_up_to_file(StringRef var_name, StringRefNull full_path, StringRef fallback)
std::optional< double > get_float(StringRef name) const
std::optional< StringRefNull > get_filepath(StringRef name) const
std::optional< StringRefNull > get_string(StringRef name) const
bool add_integer(StringRef name, int64_t value)
bool add_string(StringRef name, StringRef value)
bool add_filepath(StringRef name, StringRef value)
std::optional< ExpressionInfo > next_template_variable_expression(StringRef text, size_t starting_offset)
bool operator==(const Error &left, const Error &right)
BMesh Iterators.
__int64 int64_t
Definition BKE_text.h:90
void BKE_add_template_variables_general(bke::path_templates::VariableMap &variables, const ID *path_owner_id, const bke::BlenderProject *project)
bool BKE_path_contains_template_syntax(StringRef path)
Vector< bke::path_templates::Error > BKE_path_apply_template_alloc(char **path, int path_maxncpy, const bke::path_templates::VariableMap &template_variables)
void BKE_report_path_template_errors(ReportList *reports, eReportType report_type, StringRef path, Span< bke::path_templates::Error > errors)
std::string BKE_path_template_error_to_string(const bke::path_templates::Error &error, StringRef path)
void BKE_add_template_variables_for_render_path(bke::path_templates::VariableMap &variables, const Scene &scene)
void BKE_add_template_variables_for_node(bke::path_templates::VariableMap &variables, const bNode &owning_node)
Vector< bke::path_templates::Error > BKE_path_apply_template(char *path, int path_maxncpy, const bke::path_templates::VariableMap &template_variables)
std::string BKE_path_template_escape(StringRef text)
std::optional< bke::path_templates::VariableMap > BKE_build_template_variables_for_prop(const bContext *C, PointerRNA *ptr, PropertyRNA *prop)
void BKE_add_template_variables_for_project(bke::path_templates::VariableMap &variables, const bke::BlenderProject &project)
Vector< bke::path_templates::Error > BKE_path_validate_template(StringRef path, const bke::path_templates::VariableMap &template_variables)
std::optional< std::string > BKE_path_template_format_float(StringRef format_specifier, double value)
std::optional< std::string > BKE_path_template_format_int(StringRef format_specifier, int64_t value)