17 b.use_custom_socket_order();
18 b.allow_any_socket_order();
20 b.add_output<
decl::String>(
"String"_ustr).align_with_previous();
23 .
description(
"Individual characters to trim. The order of characters does not matter");
26 .
description(
"Trim whitespace characters in addition to the provided characters");
28 auto &p =
b.add_panel(
"Limit"_ustr).default_closed(
true);
40 static auto trim_fn = mf::build::SI5_SO<std::string, std::string, bool, bool, bool, std::string>(
42 [](
const std::string &input_str,
43 const std::string &characters,
44 const bool trim_whitespace,
45 const bool trim_start,
46 const bool trim_end) {
47 std::string characters_to_trim = characters;
48 if (trim_whitespace) {
49 characters_to_trim.append(
" \t\n\r");
52 const StringRef chars = characters_to_trim;
55 const auto is_character_trimmed = [&](
const StringRef query) {
65 if (!is_character_trimmed(
str.substr(start, size))) {
73 const char *prev = std::max(
77 if (!is_character_trimmed(
str.substr(end - size, size))) {
83 std::string
result =
str.substr(start, end - start);
95 ntype.
ui_description =
"Remove characters from the beginning and end of a string";
#define NODE_CLASS_CONVERTER
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static constexpr int64_t not_found
constexpr int64_t find(char c, int64_t pos=0) const
void set_matching_fn(const mf::MultiFunction *fn)
void node_register_type(bNodeType &ntype)
static void node_declare(NodeDeclarationBuilder &b)
static void node_register()
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
int BLI_str_utf8_size_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
const char * BLI_str_find_prev_char_utf8(const char *p, const char *str_start) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeMultiFunctionBuildFunction build_multi_function
NodeDeclareFunction declare