[Base-utils][Unumber] Missing description added 04/76304/1 accepted/tizen/common/20160624.134233 accepted/tizen/ivi/20160624.064955 accepted/tizen/mobile/20160624.065001 accepted/tizen/tv/20160624.064908 accepted/tizen/wearable/20160624.065016 submit/tizen/20160624.055318
authorRafał Szczekutek <r.szczekutek@samsung.com>
Thu, 23 Jun 2016 10:03:07 +0000 (12:03 +0200)
committerRafał Szczekutek <r.szczekutek@samsung.com>
Thu, 23 Jun 2016 10:03:07 +0000 (12:03 +0200)
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 <r.szczekutek@samsung.com>
src/include/mobile/utils_i18n_types.h
src/include/mobile/utils_i18n_unumber.h
src/include/wearable/utils_i18n_types.h
src/include/wearable/utils_i18n_unumber.h
src/utils_i18n_unumber.c

index 833d3567ba969b3ce0cc003eaeea98f726dbe589..24b92ce86664cd6357e231580845cbc647667994 100644 (file)
@@ -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
index 996bb255c2a53716d9150d6789dc1a0881710769..b0ab229b3f8c7bc4de2a5dbad5fe240c0b22d869 100644 (file)
@@ -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);
 
index 4800a5d66d0de46d9646a48099162f91e96da5f6..e999e64ac199f3f0588a0afb51aa5302eaac6118 100644 (file)
@@ -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
index 996bb255c2a53716d9150d6789dc1a0881710769..b0ab229b3f8c7bc4de2a5dbad5fe240c0b22d869 100644 (file)
@@ -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);
 
index 6edabac1cebff38e4ec0d26fd0da46a0425c63d1..de5229deecf62651b3e4024da7b05f61fa3b0020 100644 (file)
@@ -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;