Blender V5.3
node_fn_string_length.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_string_utf8.hh"
6
8#include "node_shader_util.hh"
9
11
13{
14 b.is_function_node();
15 b.add_input<decl::String>("String"_ustr).optional_label();
16 b.add_output<decl::Int>("Length"_ustr);
17}
18
20{
21 static auto str_len_fn = mf::build::SI1_SO<std::string, int>(
22 "String Length", [](const std::string &a) { return BLI_strlen_utf8(a.c_str()); });
23 builder.set_matching_fn(&str_len_fn);
24}
25
26static void node_register()
27{
28 static bke::bNodeType ntype;
29
30 common_node_type_base(&ntype, "FunctionNodeStringLength"_ustr, FN_NODE_STRING_LENGTH);
31 ntype.ui_name = "String Length";
32 ntype.ui_description = "Output the number of characters in the given string";
33 ntype.enum_name_legacy = "STRING_LENGTH";
35 ntype.declare = node_declare;
38}
40
41} // namespace blender::nodes::node_fn_string_length_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define FN_NODE_STRING_LENGTH
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void set_matching_fn(const mf::MultiFunction *fn)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_declare(NodeDeclarationBuilder &b)
size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:382
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393