@@ -269,6 +269,9 @@ G_BEGIN_DECLS
269269 * #GArrowExtractRegexOptions is a class to customize the `extract_regex`
270270 * function.
271271 *
272+ * #GArrowReplaceSliceOptions is a class to customize the `utf8_replace_slice` and
273+ * `binary_replace_slice` functions.
274+ *
272275 * There are many functions to compute data on an array.
273276 */
274277
@@ -7091,6 +7094,188 @@ garrow_extract_regex_options_new(void)
70917094 return GARROW_EXTRACT_REGEX_OPTIONS (options);
70927095}
70937096
7097+ enum {
7098+ PROP_REPLACE_SLICE_OPTIONS_START = 1 ,
7099+ PROP_REPLACE_SLICE_OPTIONS_STOP,
7100+ PROP_REPLACE_SLICE_OPTIONS_REPLACEMENT,
7101+ };
7102+
7103+ typedef struct _GArrowReplaceSliceOptionsPrivate GArrowReplaceSliceOptionsPrivate;
7104+ struct _GArrowReplaceSliceOptionsPrivate
7105+ {
7106+ gchar *replacement;
7107+ };
7108+
7109+ G_DEFINE_TYPE_WITH_PRIVATE (GArrowReplaceSliceOptions,
7110+ garrow_replace_slice_options,
7111+ GARROW_TYPE_FUNCTION_OPTIONS)
7112+
7113+ #define GARROW_REPLACE_SLICE_OPTIONS_GET_PRIVATE (object ) \
7114+ static_cast <GArrowReplaceSliceOptionsPrivate *>( \
7115+ garrow_replace_slice_options_get_instance_private ( \
7116+ GARROW_REPLACE_SLICE_OPTIONS (object)))
7117+
7118+ static void
7119+ garrow_replace_slice_options_dispose(GObject *object)
7120+ {
7121+ auto priv = GARROW_REPLACE_SLICE_OPTIONS_GET_PRIVATE (object);
7122+ if (priv->replacement ) {
7123+ g_free (priv->replacement );
7124+ priv->replacement = nullptr ;
7125+ }
7126+ G_OBJECT_CLASS (garrow_replace_slice_options_parent_class)->dispose (object);
7127+ }
7128+
7129+ static void
7130+ garrow_replace_slice_options_set_property (GObject *object,
7131+ guint prop_id,
7132+ const GValue *value,
7133+ GParamSpec *pspec)
7134+ {
7135+ auto options =
7136+ garrow_replace_slice_options_get_raw (GARROW_REPLACE_SLICE_OPTIONS (object));
7137+ auto priv = GARROW_REPLACE_SLICE_OPTIONS_GET_PRIVATE (object);
7138+
7139+ switch (prop_id) {
7140+ case PROP_REPLACE_SLICE_OPTIONS_START:
7141+ options->start = g_value_get_int64 (value);
7142+ break ;
7143+ case PROP_REPLACE_SLICE_OPTIONS_STOP:
7144+ options->stop = g_value_get_int64 (value);
7145+ break ;
7146+ case PROP_REPLACE_SLICE_OPTIONS_REPLACEMENT:
7147+ {
7148+ const gchar *replacement = g_value_get_string (value);
7149+ if (priv->replacement ) {
7150+ g_free (priv->replacement );
7151+ }
7152+ priv->replacement = g_strdup (replacement);
7153+ options->replacement = replacement ? replacement : " " ;
7154+ }
7155+ break ;
7156+ default :
7157+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7158+ break ;
7159+ }
7160+ }
7161+
7162+ static void
7163+ garrow_replace_slice_options_get_property (GObject *object,
7164+ guint prop_id,
7165+ GValue *value,
7166+ GParamSpec *pspec)
7167+ {
7168+ auto options =
7169+ garrow_replace_slice_options_get_raw (GARROW_REPLACE_SLICE_OPTIONS (object));
7170+ auto priv = GARROW_REPLACE_SLICE_OPTIONS_GET_PRIVATE (object);
7171+
7172+ switch (prop_id) {
7173+ case PROP_REPLACE_SLICE_OPTIONS_START:
7174+ g_value_set_int64 (value, options->start );
7175+ break ;
7176+ case PROP_REPLACE_SLICE_OPTIONS_STOP:
7177+ g_value_set_int64 (value, options->stop );
7178+ break ;
7179+ case PROP_REPLACE_SLICE_OPTIONS_REPLACEMENT:
7180+ g_value_set_string (value,
7181+ priv->replacement ? priv->replacement
7182+ : options->replacement .c_str ());
7183+ break ;
7184+ default :
7185+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7186+ break ;
7187+ }
7188+ }
7189+
7190+ static void
7191+ garrow_replace_slice_options_init (GArrowReplaceSliceOptions *object)
7192+ {
7193+ auto priv = GARROW_REPLACE_SLICE_OPTIONS_GET_PRIVATE (object);
7194+ priv->replacement = nullptr ;
7195+ auto arrow_priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
7196+ arrow_priv->options = static_cast <arrow::compute::FunctionOptions *>(
7197+ new arrow::compute::ReplaceSliceOptions ());
7198+ // Sync the private replacement string with the C++ options
7199+ auto arrow_options =
7200+ garrow_replace_slice_options_get_raw (GARROW_REPLACE_SLICE_OPTIONS (object));
7201+ priv->replacement = g_strdup (arrow_options->replacement .c_str ());
7202+ }
7203+
7204+ static void
7205+ garrow_replace_slice_options_class_init (GArrowReplaceSliceOptionsClass *klass)
7206+ {
7207+ auto gobject_class = G_OBJECT_CLASS (klass);
7208+
7209+ gobject_class->dispose = garrow_replace_slice_options_dispose;
7210+ gobject_class->set_property = garrow_replace_slice_options_set_property;
7211+ gobject_class->get_property = garrow_replace_slice_options_get_property;
7212+
7213+ arrow::compute::ReplaceSliceOptions options;
7214+
7215+ GParamSpec *spec;
7216+ /* *
7217+ * GArrowReplaceSliceOptions:start:
7218+ *
7219+ * Index to start slicing at.
7220+ *
7221+ * Since: 23.0.0
7222+ */
7223+ spec = g_param_spec_int64 (" start" ,
7224+ " Start" ,
7225+ " Index to start slicing at" ,
7226+ G_MININT64,
7227+ G_MAXINT64,
7228+ options.start ,
7229+ static_cast <GParamFlags>(G_PARAM_READWRITE));
7230+ g_object_class_install_property (gobject_class, PROP_REPLACE_SLICE_OPTIONS_START, spec);
7231+
7232+ /* *
7233+ * GArrowReplaceSliceOptions:stop:
7234+ *
7235+ * Index to stop slicing at.
7236+ *
7237+ * Since: 23.0.0
7238+ */
7239+ spec = g_param_spec_int64 (" stop" ,
7240+ " Stop" ,
7241+ " Index to stop slicing at" ,
7242+ G_MININT64,
7243+ G_MAXINT64,
7244+ options.stop ,
7245+ static_cast <GParamFlags>(G_PARAM_READWRITE));
7246+ g_object_class_install_property (gobject_class, PROP_REPLACE_SLICE_OPTIONS_STOP, spec);
7247+
7248+ /* *
7249+ * GArrowReplaceSliceOptions:replacement:
7250+ *
7251+ * String to replace the slice with.
7252+ *
7253+ * Since: 23.0.0
7254+ */
7255+ spec = g_param_spec_string (" replacement" ,
7256+ " Replacement" ,
7257+ " String to replace the slice with" ,
7258+ options.replacement .c_str (),
7259+ static_cast <GParamFlags>(G_PARAM_READWRITE));
7260+ g_object_class_install_property (gobject_class,
7261+ PROP_REPLACE_SLICE_OPTIONS_REPLACEMENT,
7262+ spec);
7263+ }
7264+
7265+ /* *
7266+ * garrow_replace_slice_options_new:
7267+ *
7268+ * Returns: A newly created #GArrowReplaceSliceOptions.
7269+ *
7270+ * Since: 23.0.0
7271+ */
7272+ GArrowReplaceSliceOptions *
7273+ garrow_replace_slice_options_new (void )
7274+ {
7275+ return GARROW_REPLACE_SLICE_OPTIONS (
7276+ g_object_new (GARROW_TYPE_REPLACE_SLICE_OPTIONS, NULL ));
7277+ }
7278+
70947279G_END_DECLS
70957280
70967281arrow::Result<arrow::FieldRef>
@@ -7254,6 +7439,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
72547439 static_cast <const arrow::compute::ExtractRegexOptions *>(arrow_options);
72557440 auto options = garrow_extract_regex_options_new_raw (arrow_extract_regex_options);
72567441 return GARROW_FUNCTION_OPTIONS (options);
7442+ } else if (arrow_type_name == " ReplaceSliceOptions" ) {
7443+ const auto arrow_replace_slice_options =
7444+ static_cast <const arrow::compute::ReplaceSliceOptions *>(arrow_options);
7445+ auto options = garrow_replace_slice_options_new_raw (arrow_replace_slice_options);
7446+ return GARROW_FUNCTION_OPTIONS (options);
72577447 } else {
72587448 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
72597449 return GARROW_FUNCTION_OPTIONS (options);
@@ -7893,3 +8083,24 @@ garrow_extract_regex_options_get_raw(GArrowExtractRegexOptions *options)
78938083 return static_cast <arrow::compute::ExtractRegexOptions *>(
78948084 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
78958085}
8086+
8087+ GArrowReplaceSliceOptions *
8088+ garrow_replace_slice_options_new_raw (
8089+ const arrow::compute::ReplaceSliceOptions *arrow_options)
8090+ {
8091+ return GARROW_REPLACE_SLICE_OPTIONS (g_object_new (GARROW_TYPE_REPLACE_SLICE_OPTIONS,
8092+ " start" ,
8093+ arrow_options->start ,
8094+ " stop" ,
8095+ arrow_options->stop ,
8096+ " replacement" ,
8097+ arrow_options->replacement .c_str (),
8098+ NULL ));
8099+ }
8100+
8101+ arrow::compute::ReplaceSliceOptions *
8102+ garrow_replace_slice_options_get_raw (GArrowReplaceSliceOptions *options)
8103+ {
8104+ return static_cast <arrow::compute::ReplaceSliceOptions *>(
8105+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
8106+ }
0 commit comments