@@ -330,6 +330,9 @@ G_BEGIN_DECLS
330330 * #GArrowTDigestOptions is a class to customize the `tdigest` and
331331 * `hash_tdigest` functions.
332332 *
333+ * #GArrowTrimOptions is a class to customize the `utf8_trim`, `utf8_ltrim`,
334+ * `utf8_rtrim`, `ascii_trim`, `ascii_ltrim`, and `ascii_rtrim` functions.
335+ *
333336 * There are many functions to compute data on an array.
334337 */
335338
@@ -10185,6 +10188,133 @@ garrow_tdigest_options_set_qs(GArrowTDigestOptions *options, const gdouble *qs,
1018510188 }
1018610189}
1018710190
10191+ enum {
10192+ PROP_TRIM_OPTIONS_CHARACTERS = 1 ,
10193+ };
10194+
10195+ typedef struct _GArrowTrimOptionsPrivate GArrowTrimOptionsPrivate;
10196+ struct _GArrowTrimOptionsPrivate
10197+ {
10198+ gchar *characters;
10199+ };
10200+
10201+ G_DEFINE_TYPE_WITH_PRIVATE (GArrowTrimOptions,
10202+ garrow_trim_options,
10203+ GARROW_TYPE_FUNCTION_OPTIONS)
10204+
10205+ #define GARROW_TRIM_OPTIONS_GET_PRIVATE (object ) \
10206+ static_cast <GArrowTrimOptionsPrivate *>( \
10207+ garrow_trim_options_get_instance_private (GARROW_TRIM_OPTIONS(object)))
10208+
10209+ static void
10210+ garrow_trim_options_dispose(GObject *object)
10211+ {
10212+ auto priv = GARROW_TRIM_OPTIONS_GET_PRIVATE (object);
10213+ if (priv->characters ) {
10214+ g_free (priv->characters );
10215+ priv->characters = nullptr ;
10216+ }
10217+ G_OBJECT_CLASS (garrow_trim_options_parent_class)->dispose (object);
10218+ }
10219+
10220+ static void
10221+ garrow_trim_options_set_property (GObject *object,
10222+ guint prop_id,
10223+ const GValue *value,
10224+ GParamSpec *pspec)
10225+ {
10226+ auto options = garrow_trim_options_get_raw (GARROW_TRIM_OPTIONS (object));
10227+ auto priv = GARROW_TRIM_OPTIONS_GET_PRIVATE (object);
10228+
10229+ switch (prop_id) {
10230+ case PROP_TRIM_OPTIONS_CHARACTERS:
10231+ {
10232+ const gchar *characters = g_value_get_string (value);
10233+ if (priv->characters ) {
10234+ g_free (priv->characters );
10235+ }
10236+ priv->characters = g_strdup (characters);
10237+ options->characters = characters ? characters : " " ;
10238+ }
10239+ break ;
10240+ default :
10241+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
10242+ break ;
10243+ }
10244+ }
10245+
10246+ static void
10247+ garrow_trim_options_get_property (GObject *object,
10248+ guint prop_id,
10249+ GValue *value,
10250+ GParamSpec *pspec)
10251+ {
10252+ auto options = garrow_trim_options_get_raw (GARROW_TRIM_OPTIONS (object));
10253+ auto priv = GARROW_TRIM_OPTIONS_GET_PRIVATE (object);
10254+
10255+ switch (prop_id) {
10256+ case PROP_TRIM_OPTIONS_CHARACTERS:
10257+ g_value_set_string (value, priv->characters ? priv->characters : options->characters .c_str ());
10258+ break ;
10259+ default :
10260+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
10261+ break ;
10262+ }
10263+ }
10264+
10265+ static void
10266+ garrow_trim_options_init (GArrowTrimOptions *object)
10267+ {
10268+ auto priv = GARROW_TRIM_OPTIONS_GET_PRIVATE (object);
10269+ priv->characters = nullptr ;
10270+ auto arrow_priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
10271+ arrow_priv->options =
10272+ static_cast <arrow::compute::FunctionOptions *>(new arrow::compute::TrimOptions ());
10273+ // Sync the private string with the C++ options
10274+ auto arrow_options = garrow_trim_options_get_raw (GARROW_TRIM_OPTIONS (object));
10275+ priv->characters = g_strdup (arrow_options->characters .c_str ());
10276+ }
10277+
10278+ static void
10279+ garrow_trim_options_class_init (GArrowTrimOptionsClass *klass)
10280+ {
10281+ auto gobject_class = G_OBJECT_CLASS (klass);
10282+
10283+ gobject_class->dispose = garrow_trim_options_dispose;
10284+ gobject_class->set_property = garrow_trim_options_set_property;
10285+ gobject_class->get_property = garrow_trim_options_get_property;
10286+
10287+ arrow::compute::TrimOptions options;
10288+
10289+ GParamSpec *spec;
10290+ /* *
10291+ * GArrowTrimOptions:characters:
10292+ *
10293+ * The individual characters to be trimmed from the string.
10294+ *
10295+ * Since: 23.0.0
10296+ */
10297+ spec = g_param_spec_string (" characters" ,
10298+ " Characters" ,
10299+ " The individual characters to be trimmed from the string" ,
10300+ options.characters .c_str (),
10301+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10302+ g_object_class_install_property (gobject_class, PROP_TRIM_OPTIONS_CHARACTERS, spec);
10303+ }
10304+
10305+ /* *
10306+ * garrow_trim_options_new:
10307+ *
10308+ * Returns: A newly created #GArrowTrimOptions.
10309+ *
10310+ * Since: 23.0.0
10311+ */
10312+ GArrowTrimOptions *
10313+ garrow_trim_options_new (void )
10314+ {
10315+ return GARROW_TRIM_OPTIONS (g_object_new (GARROW_TYPE_TRIM_OPTIONS, NULL ));
10316+ }
10317+
1018810318G_END_DECLS
1018910319
1019010320arrow::Result<arrow::FieldRef>
@@ -10451,6 +10581,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
1045110581 static_cast <const arrow::compute::TDigestOptions *>(arrow_options);
1045210582 auto options = garrow_tdigest_options_new_raw (arrow_tdigest_options);
1045310583 return GARROW_FUNCTION_OPTIONS (options);
10584+ } else if (arrow_type_name == " TrimOptions" ) {
10585+ const auto arrow_trim_options =
10586+ static_cast <const arrow::compute::TrimOptions *>(arrow_options);
10587+ auto options = garrow_trim_options_new_raw (arrow_trim_options);
10588+ return GARROW_FUNCTION_OPTIONS (options);
1045410589 } else {
1045510590 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
1045610591 return GARROW_FUNCTION_OPTIONS (options);
@@ -11540,3 +11675,19 @@ garrow_tdigest_options_get_raw(GArrowTDigestOptions *options)
1154011675 return static_cast <arrow::compute::TDigestOptions *>(
1154111676 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
1154211677}
11678+
11679+ GArrowTrimOptions *
11680+ garrow_trim_options_new_raw (const arrow::compute::TrimOptions *arrow_options)
11681+ {
11682+ return GARROW_TRIM_OPTIONS (g_object_new (GARROW_TYPE_TRIM_OPTIONS,
11683+ " characters" ,
11684+ arrow_options->characters .c_str (),
11685+ NULL ));
11686+ }
11687+
11688+ arrow::compute::TrimOptions *
11689+ garrow_trim_options_get_raw (GArrowTrimOptions *options)
11690+ {
11691+ return static_cast <arrow::compute::TrimOptions *>(
11692+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
11693+ }
0 commit comments