Blender V4.5
node_geo_string_join.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
6
8
10{
11 b.add_input<decl::String>("Delimiter");
12 b.add_input<decl::String>("Strings").multi_input().hide_value();
13 b.add_output<decl::String>("String");
14}
15
17{
18 Vector<SocketValueVariant> strings = params.extract_input<Vector<SocketValueVariant>>("Strings");
19 const std::string delim = params.extract_input<std::string>("Delimiter");
20
21 std::string output;
22 for (const int i : strings.index_range()) {
23 output += strings[i].extract<std::string>();
24 if (i < (strings.size() - 1)) {
25 output += delim;
26 }
27 }
28 params.set_output("String", std::move(output));
29}
30
31static void node_register()
32{
33 static blender::bke::bNodeType ntype;
34
35 geo_node_type_base(&ntype, "GeometryNodeStringJoin", GEO_NODE_STRING_JOIN);
36 ntype.ui_name = "Join Strings";
37 ntype.ui_description = "Combine any number of input strings";
38 ntype.enum_name_legacy = "STRING_JOIN";
41 ntype.declare = node_declare;
43}
45
46} // namespace blender::nodes::node_geo_string_join_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:439
#define GEO_NODE_STRING_JOIN
#define NOD_REGISTER_NODE(REGISTER_FUNC)
int64_t size() const
IndexRange index_range() const
#define output
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
void geo_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:226
std::string ui_description
Definition BKE_node.hh:232
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:347
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355
i
Definition text_draw.cc:230