Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/function/nodes/node_fn_replace_string.cc
| Show All 16 Lines | |||||
| #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 { | ||||
| static void fn_node_replace_string_declare(NodeDeclarationBuilder &b) | static void fn_node_replace_string_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::String>("String"); | b.add_input<decl::String>(N_("String")); | ||||
| b.add_input<decl::String>("Find").description("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>("Replace").description("The string to replace each match with"); | b.add_input<decl::String>(N_("Replace")) | ||||
| b.add_output<decl::String>("String"); | .description(N_("The string to replace each match with")); | ||||
| b.add_output<decl::String>(N_("String")); | |||||
| }; | }; | ||||
| static std::string replace_all(std::string str, const std::string &from, const std::string &to) | static std::string replace_all(std::string str, const std::string &from, const std::string &to) | ||||
| { | { | ||||
| if (from.length() <= 0) { | if (from.length() <= 0) { | ||||
| return str; | return str; | ||||
| } | } | ||||
| const size_t step = to.length() > 0 ? to.length() : 1; | const size_t step = to.length() > 0 ? to.length() : 1; | ||||
| Show All 29 Lines | |||||