@@ -287,6 +287,10 @@ G_BEGIN_DECLS
287287 *
288288 * #GArrowModeOptions is a class to customize the `mode` function.
289289 *
290+ * #GArrowPadOptions is a class to customize the padding functions such as
291+ * `utf8_lpad`, `utf8_rpad`, `utf8_center`, `ascii_lpad`, `ascii_rpad`, and
292+ * `ascii_center`.
293+ *
290294 * There are many functions to compute data on an array.
291295 */
292296
@@ -8016,6 +8020,147 @@ garrow_mode_options_new(void)
80168020 return GARROW_MODE_OPTIONS (g_object_new (GARROW_TYPE_MODE_OPTIONS, NULL ));
80178021}
80188022
8023+ enum {
8024+ PROP_PAD_OPTIONS_WIDTH = 1 ,
8025+ PROP_PAD_OPTIONS_PADDING,
8026+ PROP_PAD_OPTIONS_LEAN_LEFT_ON_ODD_PADDING,
8027+ };
8028+
8029+ G_DEFINE_TYPE (GArrowPadOptions, garrow_pad_options, GARROW_TYPE_FUNCTION_OPTIONS)
8030+
8031+ static void
8032+ garrow_pad_options_set_property(GObject *object,
8033+ guint prop_id,
8034+ const GValue *value,
8035+ GParamSpec *pspec)
8036+ {
8037+ auto options = garrow_pad_options_get_raw (GARROW_PAD_OPTIONS (object));
8038+
8039+ switch (prop_id) {
8040+ case PROP_PAD_OPTIONS_WIDTH:
8041+ options->width = g_value_get_int64 (value);
8042+ break ;
8043+ case PROP_PAD_OPTIONS_PADDING:
8044+ options->padding = g_value_get_string (value);
8045+ break ;
8046+ case PROP_PAD_OPTIONS_LEAN_LEFT_ON_ODD_PADDING:
8047+ options->lean_left_on_odd_padding = g_value_get_boolean (value);
8048+ break ;
8049+ default :
8050+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
8051+ break ;
8052+ }
8053+ }
8054+
8055+ static void
8056+ garrow_pad_options_get_property (GObject *object,
8057+ guint prop_id,
8058+ GValue *value,
8059+ GParamSpec *pspec)
8060+ {
8061+ auto options = garrow_pad_options_get_raw (GARROW_PAD_OPTIONS (object));
8062+
8063+ switch (prop_id) {
8064+ case PROP_PAD_OPTIONS_WIDTH:
8065+ g_value_set_int64 (value, options->width );
8066+ break ;
8067+ case PROP_PAD_OPTIONS_PADDING:
8068+ g_value_set_string (value, options->padding .c_str ());
8069+ break ;
8070+ case PROP_PAD_OPTIONS_LEAN_LEFT_ON_ODD_PADDING:
8071+ g_value_set_boolean (value, options->lean_left_on_odd_padding );
8072+ break ;
8073+ default :
8074+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
8075+ break ;
8076+ }
8077+ }
8078+
8079+ static void
8080+ garrow_pad_options_init (GArrowPadOptions *object)
8081+ {
8082+ auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
8083+ priv->options =
8084+ static_cast <arrow::compute::FunctionOptions *>(new arrow::compute::PadOptions ());
8085+ }
8086+
8087+ static void
8088+ garrow_pad_options_class_init (GArrowPadOptionsClass *klass)
8089+ {
8090+ auto gobject_class = G_OBJECT_CLASS (klass);
8091+
8092+ gobject_class->set_property = garrow_pad_options_set_property;
8093+ gobject_class->get_property = garrow_pad_options_get_property;
8094+
8095+ arrow::compute::PadOptions options;
8096+
8097+ GParamSpec *spec;
8098+ /* *
8099+ * GArrowPadOptions:width:
8100+ *
8101+ * The desired string length.
8102+ *
8103+ * Since: 23.0.0
8104+ */
8105+ spec = g_param_spec_int64 (" width" ,
8106+ " Width" ,
8107+ " The desired string length" ,
8108+ 0 ,
8109+ G_MAXINT64,
8110+ options.width ,
8111+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8112+ g_object_class_install_property (gobject_class, PROP_PAD_OPTIONS_WIDTH, spec);
8113+
8114+ /* *
8115+ * GArrowPadOptions:padding:
8116+ *
8117+ * What to pad the string with. Should be one codepoint (Unicode)/byte (ASCII).
8118+ *
8119+ * Since: 23.0.0
8120+ */
8121+ spec = g_param_spec_string (
8122+ " padding" ,
8123+ " Padding" ,
8124+ " What to pad the string with. Should be one codepoint (Unicode)/byte (ASCII)" ,
8125+ options.padding .c_str (),
8126+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8127+ g_object_class_install_property (gobject_class, PROP_PAD_OPTIONS_PADDING, spec);
8128+
8129+ /* *
8130+ * GArrowPadOptions:lean-left-on-odd-padding:
8131+ *
8132+ * What to do if there is an odd number of padding characters (in case of centered
8133+ * padding). Defaults to aligning on the left (i.e. adding the extra padding character
8134+ * on the right).
8135+ *
8136+ * Since: 23.0.0
8137+ */
8138+ spec =
8139+ g_param_spec_boolean (" lean-left-on-odd-padding" ,
8140+ " Lean left on odd padding" ,
8141+ " What to do if there is an odd number of padding characters (in "
8142+ " case of centered padding). Defaults to aligning on the left "
8143+ " (i.e. adding the extra padding character on the right)" ,
8144+ options.lean_left_on_odd_padding ,
8145+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8146+ g_object_class_install_property (gobject_class,
8147+ PROP_PAD_OPTIONS_LEAN_LEFT_ON_ODD_PADDING,
8148+ spec);
8149+ }
8150+
8151+ /* *
8152+ * garrow_pad_options_new:
8153+ *
8154+ * Returns: A newly created #GArrowPadOptions.
8155+ *
8156+ * Since: 23.0.0
8157+ */
8158+ GArrowPadOptions *
8159+ garrow_pad_options_new (void )
8160+ {
8161+ return GARROW_PAD_OPTIONS (g_object_new (GARROW_TYPE_PAD_OPTIONS, NULL ));
8162+ }
8163+
80198164G_END_DECLS
80208165
80218166arrow::Result<arrow::FieldRef>
@@ -8205,6 +8350,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
82058350 static_cast <const arrow::compute::ModeOptions *>(arrow_options);
82068351 auto options = garrow_mode_options_new_raw (arrow_mode_options);
82078352 return GARROW_FUNCTION_OPTIONS (options);
8353+ } else if (arrow_type_name == " PadOptions" ) {
8354+ const auto arrow_pad_options =
8355+ static_cast <const arrow::compute::PadOptions *>(arrow_options);
8356+ auto options = garrow_pad_options_new_raw (arrow_pad_options);
8357+ return GARROW_FUNCTION_OPTIONS (options);
82088358 } else {
82098359 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
82108360 return GARROW_FUNCTION_OPTIONS (options);
@@ -8979,3 +9129,23 @@ garrow_mode_options_get_raw(GArrowModeOptions *options)
89799129 return static_cast <arrow::compute::ModeOptions *>(
89809130 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
89819131}
9132+
9133+ GArrowPadOptions *
9134+ garrow_pad_options_new_raw (const arrow::compute::PadOptions *arrow_options)
9135+ {
9136+ return GARROW_PAD_OPTIONS (g_object_new (GARROW_TYPE_PAD_OPTIONS,
9137+ " width" ,
9138+ arrow_options->width ,
9139+ " padding" ,
9140+ arrow_options->padding .c_str (),
9141+ " lean-left-on-odd-padding" ,
9142+ arrow_options->lean_left_on_odd_padding ,
9143+ NULL ));
9144+ }
9145+
9146+ arrow::compute::PadOptions *
9147+ garrow_pad_options_get_raw (GArrowPadOptions *options)
9148+ {
9149+ return static_cast <arrow::compute::PadOptions *>(
9150+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
9151+ }
0 commit comments