@@ -289,6 +289,10 @@ G_BEGIN_DECLS
289289 *
290290 * #GArrowNullOptions is a class to customize the `is_null` function.
291291 *
292+ * #GArrowPadOptions is a class to customize the padding functions such as
293+ * `utf8_lpad`, `utf8_rpad`, `utf8_center`, `ascii_lpad`, `ascii_rpad`, and
294+ * `ascii_center`.
295+ *
292296 * There are many functions to compute data on an array.
293297 */
294298
@@ -8107,6 +8111,147 @@ garrow_null_options_new(void)
81078111 return GARROW_NULL_OPTIONS (g_object_new (GARROW_TYPE_NULL_OPTIONS, NULL ));
81088112}
81098113
8114+ enum {
8115+ PROP_PAD_OPTIONS_WIDTH = 1 ,
8116+ PROP_PAD_OPTIONS_PADDING,
8117+ PROP_PAD_OPTIONS_LEAN_LEFT_ON_ODD_PADDING,
8118+ };
8119+
8120+ G_DEFINE_TYPE (GArrowPadOptions, garrow_pad_options, GARROW_TYPE_FUNCTION_OPTIONS)
8121+
8122+ static void
8123+ garrow_pad_options_set_property(GObject *object,
8124+ guint prop_id,
8125+ const GValue *value,
8126+ GParamSpec *pspec)
8127+ {
8128+ auto options = garrow_pad_options_get_raw (GARROW_PAD_OPTIONS (object));
8129+
8130+ switch (prop_id) {
8131+ case PROP_PAD_OPTIONS_WIDTH:
8132+ options->width = g_value_get_int64 (value);
8133+ break ;
8134+ case PROP_PAD_OPTIONS_PADDING:
8135+ options->padding = g_value_get_string (value);
8136+ break ;
8137+ case PROP_PAD_OPTIONS_LEAN_LEFT_ON_ODD_PADDING:
8138+ options->lean_left_on_odd_padding = g_value_get_boolean (value);
8139+ break ;
8140+ default :
8141+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
8142+ break ;
8143+ }
8144+ }
8145+
8146+ static void
8147+ garrow_pad_options_get_property (GObject *object,
8148+ guint prop_id,
8149+ GValue *value,
8150+ GParamSpec *pspec)
8151+ {
8152+ auto options = garrow_pad_options_get_raw (GARROW_PAD_OPTIONS (object));
8153+
8154+ switch (prop_id) {
8155+ case PROP_PAD_OPTIONS_WIDTH:
8156+ g_value_set_int64 (value, options->width );
8157+ break ;
8158+ case PROP_PAD_OPTIONS_PADDING:
8159+ g_value_set_string (value, options->padding .c_str ());
8160+ break ;
8161+ case PROP_PAD_OPTIONS_LEAN_LEFT_ON_ODD_PADDING:
8162+ g_value_set_boolean (value, options->lean_left_on_odd_padding );
8163+ break ;
8164+ default :
8165+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
8166+ break ;
8167+ }
8168+ }
8169+
8170+ static void
8171+ garrow_pad_options_init (GArrowPadOptions *object)
8172+ {
8173+ auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
8174+ priv->options =
8175+ static_cast <arrow::compute::FunctionOptions *>(new arrow::compute::PadOptions ());
8176+ }
8177+
8178+ static void
8179+ garrow_pad_options_class_init (GArrowPadOptionsClass *klass)
8180+ {
8181+ auto gobject_class = G_OBJECT_CLASS (klass);
8182+
8183+ gobject_class->set_property = garrow_pad_options_set_property;
8184+ gobject_class->get_property = garrow_pad_options_get_property;
8185+
8186+ arrow::compute::PadOptions options;
8187+
8188+ GParamSpec *spec;
8189+ /* *
8190+ * GArrowPadOptions:width:
8191+ *
8192+ * The desired string length.
8193+ *
8194+ * Since: 23.0.0
8195+ */
8196+ spec = g_param_spec_int64 (" width" ,
8197+ " Width" ,
8198+ " The desired string length" ,
8199+ 0 ,
8200+ G_MAXINT64,
8201+ options.width ,
8202+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8203+ g_object_class_install_property (gobject_class, PROP_PAD_OPTIONS_WIDTH, spec);
8204+
8205+ /* *
8206+ * GArrowPadOptions:padding:
8207+ *
8208+ * What to pad the string with. Should be one codepoint (Unicode)/byte (ASCII).
8209+ *
8210+ * Since: 23.0.0
8211+ */
8212+ spec = g_param_spec_string (
8213+ " padding" ,
8214+ " Padding" ,
8215+ " What to pad the string with. Should be one codepoint (Unicode)/byte (ASCII)" ,
8216+ options.padding .c_str (),
8217+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8218+ g_object_class_install_property (gobject_class, PROP_PAD_OPTIONS_PADDING, spec);
8219+
8220+ /* *
8221+ * GArrowPadOptions:lean-left-on-odd-padding:
8222+ *
8223+ * What to do if there is an odd number of padding characters (in case of centered
8224+ * padding). Defaults to aligning on the left (i.e. adding the extra padding character
8225+ * on the right).
8226+ *
8227+ * Since: 23.0.0
8228+ */
8229+ spec =
8230+ g_param_spec_boolean (" lean-left-on-odd-padding" ,
8231+ " Lean left on odd padding" ,
8232+ " What to do if there is an odd number of padding characters (in "
8233+ " case of centered padding). Defaults to aligning on the left "
8234+ " (i.e. adding the extra padding character on the right)" ,
8235+ options.lean_left_on_odd_padding ,
8236+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8237+ g_object_class_install_property (gobject_class,
8238+ PROP_PAD_OPTIONS_LEAN_LEFT_ON_ODD_PADDING,
8239+ spec);
8240+ }
8241+
8242+ /* *
8243+ * garrow_pad_options_new:
8244+ *
8245+ * Returns: A newly created #GArrowPadOptions.
8246+ *
8247+ * Since: 23.0.0
8248+ */
8249+ GArrowPadOptions *
8250+ garrow_pad_options_new (void )
8251+ {
8252+ return GARROW_PAD_OPTIONS (g_object_new (GARROW_TYPE_PAD_OPTIONS, NULL ));
8253+ }
8254+
81108255G_END_DECLS
81118256
81128257arrow::Result<arrow::FieldRef>
@@ -8301,6 +8446,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
83018446 static_cast <const arrow::compute::NullOptions *>(arrow_options);
83028447 auto options = garrow_null_options_new_raw (arrow_null_options);
83038448 return GARROW_FUNCTION_OPTIONS (options);
8449+ } else if (arrow_type_name == " PadOptions" ) {
8450+ const auto arrow_pad_options =
8451+ static_cast <const arrow::compute::PadOptions *>(arrow_options);
8452+ auto options = garrow_pad_options_new_raw (arrow_pad_options);
8453+ return GARROW_FUNCTION_OPTIONS (options);
83048454 } else {
83058455 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
83068456 return GARROW_FUNCTION_OPTIONS (options);
@@ -9091,3 +9241,23 @@ garrow_null_options_get_raw(GArrowNullOptions *options)
90919241 return static_cast <arrow::compute::NullOptions *>(
90929242 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
90939243}
9244+
9245+ GArrowPadOptions *
9246+ garrow_pad_options_new_raw (const arrow::compute::PadOptions *arrow_options)
9247+ {
9248+ return GARROW_PAD_OPTIONS (g_object_new (GARROW_TYPE_PAD_OPTIONS,
9249+ " width" ,
9250+ arrow_options->width ,
9251+ " padding" ,
9252+ arrow_options->padding .c_str (),
9253+ " lean-left-on-odd-padding" ,
9254+ arrow_options->lean_left_on_odd_padding ,
9255+ NULL ));
9256+ }
9257+
9258+ arrow::compute::PadOptions *
9259+ garrow_pad_options_get_raw (GArrowPadOptions *options)
9260+ {
9261+ return static_cast <arrow::compute::PadOptions *>(
9262+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
9263+ }
0 commit comments