From 10aa25c206ddd272ee19e039b213cab3e5c76bc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Szczekutek?= Date: Thu, 23 Jun 2016 12:03:07 +0200 Subject: [PATCH] [Base-utils][Unumber] Missing description added MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The description for the possible values that can be set with the i18n_unumber_set_attribute() function for the I18N_UNUMBER_PADDING_POSITION attribute. Related enumeration added. Validation added, to prevent from casting invalid values to the enumeration. Change-Id: I97bec5c1c8238a49732dfd20b520b8a730438856 Signed-off-by: Rafał Szczekutek --- src/include/mobile/utils_i18n_types.h | 11 +++++++++++ src/include/mobile/utils_i18n_unumber.h | 4 ++++ src/include/wearable/utils_i18n_types.h | 11 +++++++++++ src/include/wearable/utils_i18n_unumber.h | 4 ++++ src/utils_i18n_unumber.c | 9 +++++++-- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/include/mobile/utils_i18n_types.h b/src/include/mobile/utils_i18n_types.h index 833d356..24b92ce 100644 --- a/src/include/mobile/utils_i18n_types.h +++ b/src/include/mobile/utils_i18n_types.h @@ -2179,6 +2179,17 @@ typedef enum { Has no effect on formatting. Default: 0 (unset) */ } i18n_unumber_format_attribute_e; +/** + * @brief Enumeration for the possible values of the #I18N_UNUMBER_PADDING_POSITION attribute. + * @since_tizen 3.0 + */ +typedef enum { + I18N_UNUMBER_PAD_BEFORE_PREFIX, + I18N_UNUMBER_PAD_AFTER_PREFIX, + I18N_UNUMBER_PAD_BEFORE_SUFFIX, + I18N_UNUMBER_PAD_AFTER_SUFFIX, +} i18n_unumber_pad_position_e; + /** * @brief The possible #i18n_unumber_format_h text attributes. * @since_tizen 2.3.1 diff --git a/src/include/mobile/utils_i18n_unumber.h b/src/include/mobile/utils_i18n_unumber.h index 996bb25..b0ab229 100644 --- a/src/include/mobile/utils_i18n_unumber.h +++ b/src/include/mobile/utils_i18n_unumber.h @@ -481,6 +481,9 @@ int32_t i18n_unumber_get_attribute(const i18n_unumber_format_h fmt, i18n_unumber * @details An example of a numeric attribute is the number of integer digits a formatter will produce. * If the formatter does not understand the attribute, the call is ignored. Rule-based formatters only understand * the lenient-parse attribute. The #I18N_UNUMBER_ROUNDING_INCREMENT attribute is not supported. + * + * Note that the value for the #I18N_UNUMBER_PADDING_POSITION attribute should be one of the #i18n_unumber_pad_position_e + * enumeration values. * @remarks Error codes are described in #i18n_error_code_e description. * @since_tizen 2.3.1 * @@ -498,6 +501,7 @@ int32_t i18n_unumber_get_attribute(const i18n_unumber_format_h fmt, i18n_unumber * @return The obtained error code. * @retval #I18N_ERROR_NONE Successful. * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @retval #I18N_ERROR_NOT_SUPPORTED Not supported */ int i18n_unumber_set_attribute(i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, int32_t new_value); diff --git a/src/include/wearable/utils_i18n_types.h b/src/include/wearable/utils_i18n_types.h index 4800a5d..e999e64 100644 --- a/src/include/wearable/utils_i18n_types.h +++ b/src/include/wearable/utils_i18n_types.h @@ -2179,6 +2179,17 @@ typedef enum { Has no effect on formatting. Default: 0 (unset) */ } i18n_unumber_format_attribute_e; +/** + * @brief Enumeration for the possible values of the #I18N_UNUMBER_PADDING_POSITION attribute. + * @since_tizen 3.0 + */ +typedef enum { + I18N_UNUMBER_PAD_BEFORE_PREFIX, + I18N_UNUMBER_PAD_AFTER_PREFIX, + I18N_UNUMBER_PAD_BEFORE_SUFFIX, + I18N_UNUMBER_PAD_AFTER_SUFFIX, +} i18n_unumber_pad_position_e; + /** * @brief The possible #i18n_unumber_format_h text attributes. * @since_tizen 2.3.1 diff --git a/src/include/wearable/utils_i18n_unumber.h b/src/include/wearable/utils_i18n_unumber.h index 996bb25..b0ab229 100644 --- a/src/include/wearable/utils_i18n_unumber.h +++ b/src/include/wearable/utils_i18n_unumber.h @@ -481,6 +481,9 @@ int32_t i18n_unumber_get_attribute(const i18n_unumber_format_h fmt, i18n_unumber * @details An example of a numeric attribute is the number of integer digits a formatter will produce. * If the formatter does not understand the attribute, the call is ignored. Rule-based formatters only understand * the lenient-parse attribute. The #I18N_UNUMBER_ROUNDING_INCREMENT attribute is not supported. + * + * Note that the value for the #I18N_UNUMBER_PADDING_POSITION attribute should be one of the #i18n_unumber_pad_position_e + * enumeration values. * @remarks Error codes are described in #i18n_error_code_e description. * @since_tizen 2.3.1 * @@ -498,6 +501,7 @@ int32_t i18n_unumber_get_attribute(const i18n_unumber_format_h fmt, i18n_unumber * @return The obtained error code. * @retval #I18N_ERROR_NONE Successful. * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @retval #I18N_ERROR_NOT_SUPPORTED Not supported */ int i18n_unumber_set_attribute(i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, int32_t new_value); diff --git a/src/utils_i18n_unumber.c b/src/utils_i18n_unumber.c index 6edabac..de5229d 100644 --- a/src/utils_i18n_unumber.c +++ b/src/utils_i18n_unumber.c @@ -320,8 +320,13 @@ int32_t i18n_unumber_get_attribute(const i18n_unumber_format_h fmt, int i18n_unumber_set_attribute(i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, int32_t new_value) { - if (fmt == NULL || attr == I18N_UNUMBER_ROUNDING_INCREMENT) - return I18N_ERROR_INVALID_PARAMETER; + if (fmt == NULL) return I18N_ERROR_INVALID_PARAMETER; + + if (attr == I18N_UNUMBER_ROUNDING_INCREMENT) return I18N_ERROR_NOT_SUPPORTED; + + if (attr == I18N_UNUMBER_PADDING_POSITION && + (new_value < I18N_UNUMBER_PAD_BEFORE_PREFIX || new_value > I18N_UNUMBER_PAD_AFTER_SUFFIX)) + return I18N_ERROR_INVALID_PARAMETER; unum_setAttribute(fmt, attr, new_value); return I18N_ERROR_NONE; -- 2.34.1