31 .description(
"Path to a text file");
43 counter.
add(this->text.size());
49 auto load_fn = [path]() {
50 auto cached_value = std::make_unique<LoadTextCache>();
55 const std::string message = fmt::format(fmt::runtime(
TIP_(
"Cannot open file: {}")), path);
61 cached_value->warnings.append(
65 cached_value->text = std::string(buffer, buffer_len);
82 std::shared_ptr<const LoadTextCache> cached_value =
get_cached_text(*path);
84 for (
const NodeWarning &warning : cached_value->warnings) {
88 params.
set_output(
"String"_ustr, cached_value->text);
98 if (!
result.should_compute()) {
102 const std::optional<std::string> path = this->ensure_absolute_path(
103 this->
get_input(
"Path").get_single_value_default<std::string>());
105 result.allocate_single_value();
106 result.set_single_value(std::string(
""));
110 std::shared_ptr<const LoadTextCache> cached_value =
get_cached_text(*path);
112 for (
const NodeWarning &warning : cached_value->warnings) {
116 result.allocate_single_value();
117 result.set_single_value(cached_value->text);
121 std::optional<std::string> ensure_absolute_path(
const StringRefNull path)
const
127 return std::string(path);
132 if (!base_path || base_path[0] ==
'\0') {
138 return absolute_path;
File and directory operations.
#define BLI_SCOPED_DEFER(function_to_defer)
ID and Library types, which are fundamental for SDNA.
#define ID_BLEND_PATH(_bmain, _id)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
constexpr const char * c_str() const
constexpr bool is_empty() const
virtual const Main & get_main() const =0
NodeOperation(Context &context, const bNode &node)
void add_warning(nodes::NodeWarningType type, std::string message)
Result & get_result(StringRef identifier)
Context & context() const
Result & get_input(StringRef identifier) const
void add(const int64_t bytes)
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
std::optional< std::string > ensure_absolute_path(StringRefNull path) const
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
std::optional< std::string > path_filter
Vector< NodeWarning > warnings
void count_memory(MemoryCounter &counter) const override
void node_register_type(bNodeType &ntype)
std::shared_ptr< const T > get_loaded(const GenericKey &loader_key, Span< StringRefNull > file_paths, FunctionRef< std::unique_ptr< T >()> load_fn)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static compositor::NodeOperation * get_compositor_operation(compositor::Context &context, const bNode &node)
static void node_declare(NodeDeclarationBuilder &b)
static std::shared_ptr< const LoadTextCache > get_cached_text(const StringRefNull path)
char * STRNCPY(char(&dst)[N], const char *src)
ptrdiff_t BLI_str_utf8_invalid_byte(const char *str, size_t str_len) ATTR_NONNULL(1)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
char * BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void geo_cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGetCompositorOperationFunction get_compositor_operation
NodeGeometryExecFunction geometry_node_execute
NodeDeclareFunction declare