28 if (
node !=
nullptr) {
34 .description(
"Numeric base for the input string (e.g. 2 for binary, 16 for hexadecimal)")
36 b.add_output(data_type,
"Value"_ustr);
44 static auto str_to_float_fn = mf::build::SI1_SO2<std::string, float, int>(
45 "String to Value", [](
const std::string &s,
float &value,
int &
length) ->
void {
46 const auto result = fast_float::from_chars(s.data(), s.data() + s.size(), value);
47 if (
result.ec != std::errc()) {
55 static auto str_to_int_fn = mf::build::SI2_SO2<std::string, int, int, int>(
56 "String to Value", [](
const std::string &s,
int base,
int &value,
int &
length) ->
void {
57 if (base < 2 || base > 36) {
62 const auto result = std::from_chars(s.data(), s.data() + s.size(), value, base);
63 if (
result.ec != std::errc()) {
73 return &str_to_float_fn;
75 return &str_to_int_fn;
137 {
SOCK_FLOAT,
"FLOAT", ICON_NODE_SOCKET_FLOAT,
N_(
"Float"),
N_(
"Floating-point value")},
138 {
SOCK_INT,
"INT", ICON_NODE_SOCKET_INT,
N_(
"Integer"),
N_(
"32-bit integer")},
139 {0,
nullptr, 0,
nullptr,
nullptr}};
155 ntype.
ui_name =
"String to Value";
156 ntype.
ui_description =
"Derive a numeric value from a given string representation";
#define NODE_CLASS_CONVERTER
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
#define BLI_assert_unreachable()
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeTree & node_tree() const
const bNodeSocket & other_socket() const
eNodeSocketInOut in_out() const
void update_and_connect_available_socket(bNode &new_node, UString socket_name)
bNode & add_node(UString idname)
void set_matching_fn(const mf::MultiFunction *fn)
float length(VecOp< float, D >) RET
void node_register_type(bNodeType &ntype)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_init(bNodeTree *, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
static void node_rna(StructRNA *srna)
static void node_register()
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static const mf::MultiFunction * get_multi_function(const bNode &bnode)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
size_t size_t BLI_strnlen_utf8(const char *strc, size_t strc_maxlen) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
bke::bNodeTreeType * typeinfo
bool(*) validate_link(eNodeSocketDatatype from, eNodeSocketDatatype to)
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeMultiFunctionBuildFunction build_multi_function
void(*) initfunc(bNodeTree *ntree, bNode *node)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)