Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/function/nodes/node_fn_replace_string.cc
| Show All 12 Lines | |||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| */ | */ | ||||
| #include "BLI_string_utf8.h" | #include "BLI_string_utf8.h" | ||||
| #include "node_function_util.hh" | #include "node_function_util.hh" | ||||
| namespace blender::nodes { | namespace blender::nodes::node_fn_replace_string_cc { | ||||
| static void fn_node_replace_string_declare(NodeDeclarationBuilder &b) | static void fn_node_replace_string_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::String>(N_("String")); | b.add_input<decl::String>(N_("String")); | ||||
| b.add_input<decl::String>(N_("Find")).description(N_("The string to find in the input string")); | b.add_input<decl::String>(N_("Find")).description(N_("The string to find in the input string")); | ||||
| b.add_input<decl::String>(N_("Replace")) | b.add_input<decl::String>(N_("Replace")) | ||||
| .description(N_("The string to replace each match with")); | .description(N_("The string to replace each match with")); | ||||
| b.add_output<decl::String>(N_("String")); | b.add_output<decl::String>(N_("String")); | ||||
| Show All 18 Lines | |||||
| { | { | ||||
| static fn::CustomMF_SI_SI_SI_SO<std::string, std::string, std::string, std::string> substring_fn{ | static fn::CustomMF_SI_SI_SI_SO<std::string, std::string, std::string, std::string> substring_fn{ | ||||
| "Replace", [](const std::string &str, const std::string &find, const std::string &replace) { | "Replace", [](const std::string &str, const std::string &find, const std::string &replace) { | ||||
| return replace_all(str, find, replace); | return replace_all(str, find, replace); | ||||
| }}; | }}; | ||||
| builder.set_matching_fn(&substring_fn); | builder.set_matching_fn(&substring_fn); | ||||
| } | } | ||||
| } // namespace blender::nodes | } // namespace blender::nodes::node_fn_replace_string_cc | ||||
| void register_node_type_fn_replace_string() | void register_node_type_fn_replace_string() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_fn_replace_string_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| fn_node_type_base(&ntype, FN_NODE_REPLACE_STRING, "Replace String", NODE_CLASS_CONVERTER, 0); | fn_node_type_base(&ntype, FN_NODE_REPLACE_STRING, "Replace String", NODE_CLASS_CONVERTER); | ||||
| ntype.declare = blender::nodes::fn_node_replace_string_declare; | ntype.declare = file_ns::fn_node_replace_string_declare; | ||||
| ntype.build_multi_function = blender::nodes::fn_node_replace_string_build_multi_function; | ntype.build_multi_function = file_ns::fn_node_replace_string_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||