Blender V5.0
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.h"
6
8
10
12{
13 b.add_input<decl::String>("String").optional_label();
14 b.add_output<decl::Int>("Length");
15}
16
18{
19 static auto str_len_fn = mf::build::SI1_SO<std::string, int>(
20 "String Length", [](const std::string &a) { return BLI_strlen_utf8(a.c_str()); });
21 builder.set_matching_fn(&str_len_fn);
22}
23
24static void node_register()
25{
26 static blender::bke::bNodeType ntype;
27
28 fn_node_type_base(&ntype, "FunctionNodeStringLength", FN_NODE_STRING_LENGTH);
29 ntype.ui_name = "String Length";
30 ntype.ui_description = "Output the number of characters in the given string";
31 ntype.enum_name_legacy = "STRING_LENGTH";
33 ntype.declare = node_declare;
36}
38
39} // namespace blender::nodes::node_fn_string_length_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:453
#define FN_NODE_STRING_LENGTH
size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void set_matching_fn(const mf::MultiFunction *fn)
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_declare(NodeDeclarationBuilder &b)
void fn_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:351
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362