[Base-utils][Field Position] Complete module added 78/70778/18
authorRafał Szczekutek <r.szczekutek@samsung.com>
Mon, 27 Jun 2016 13:49:05 +0000 (15:49 +0200)
committerRafał Szczekutek <r.szczekutek@samsung.com>
Mon, 27 Jun 2016 13:49:05 +0000 (15:49 +0200)
implementation + documentation

Change-Id: I94097bf9ef2072e73c8274be3492aad380dc9d7f
Signed-off-by: Beata Stefaniuk <b.stefaniuk@samsung.com>
src/CMakeLists.txt
src/include/mobile/utils_i18n.h
src/include/mobile/utils_i18n_field_position.h [new file with mode: 0644]
src/include/mobile/utils_i18n_types.h
src/include/wearable/utils_i18n.h
src/include/wearable/utils_i18n_field_position.h [new file with mode: 0644]
src/include/wearable/utils_i18n_types.h
src/utils_i18n_field_position.cpp [new file with mode: 0644]

index d0da72a17da2525dc0c74c6f7c43cd9b0cc68d7f..8a2df2e19bff6ea06abe3f9ef19e63b26f891773 100755 (executable)
@@ -39,6 +39,7 @@ SET(BASEUTILS_SRCS
     utils_i18n_measure.cpp
     utils_i18n_format.cpp
     utils_i18n_measure_format.cpp
+    utils_i18n_field_position.cpp
 )
 
 ADD_LIBRARY(${target_name} SHARED ${BASEUTILS_SRCS}
@@ -79,5 +80,6 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_measure_unit.h D
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_measure.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_format.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_measure_format.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_field_position.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pc_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
\ No newline at end of file
index d822a18f47269b65b41d33b94a57fbdcade647d2..b155f4d04edb27b1ae5c709a81d90e7db7cdc771 100644 (file)
@@ -38,6 +38,7 @@
 #include <utils_i18n_measure.h>
 #include <utils_i18n_format.h>
 #include <utils_i18n_measure_format.h>
+#include <utils_i18n_field_position.h>
 
 /**
  * @file utils_i18n.h
@@ -52,7 +53,7 @@ extern "C" {
 /**
  * @ingroup CAPI_BASE_UTILS_MODULE
  * @defgroup CAPI_BASE_UTILS_I18N_MODULE i18n
- * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber, alpha_idx, formattable, measure unit, measure, format and measure format.
+ * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber, alpha_idx, formattable, measure unit, measure, format, measure format and field position.
  *        This module provides flexible generation of number or date format patterns and helps you format and parse dates/number for any locale.
  * The i18n module provides various features based on data from ICU. The following table shows the version of ICU used in each Tizen platform.
  * <table>
@@ -152,6 +153,10 @@ extern "C" {
  *       <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
  *       <td>The Measure Format module represents a formatter for measure objects.</td>
  * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION</td>
+ *       <td>The Field Position module is used to identify fields in a formatted output.</td>
+ * </tr>
  * </table>
  *
  * @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
@@ -2853,6 +2858,56 @@ extern "C" {
  *       <td>#i18n_measure_format_create_currency_format</td>
  *       <td>createCurrencyFormat</td>
  * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_create</td>
+ *       <td>FieldPosition</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_create_for_field</td>
+ *       <td>FieldPosition</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_destroy</td>
+ *       <td>~FieldPosition</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_clone</td>
+ *       <td>clone</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_get_field</td>
+ *       <td>getField</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_get_begin_index</td>
+ *       <td>getBeginIndex</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_get_end_index</td>
+ *       <td>getEndIndex</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_set_field</td>
+ *       <td>setField</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_set_begin_index</td>
+ *       <td>setBeginIndex</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_set_end_index</td>
+ *       <td>setEndIndex</td>
+ * </tr>
  * </table>
  */
 
diff --git a/src/include/mobile/utils_i18n_field_position.h b/src/include/mobile/utils_i18n_field_position.h
new file mode 100644 (file)
index 0000000..a80ae77
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef __UTILS_I18N_FIELD_POSITION_H__
+#define __UTILS_I18N_FIELD_POSITION_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_field_position.h
+ * @version 0.1
+ * @brief utils_i18n_field_position
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE FieldPosition
+ * @brief Field Position is a simple type used by the Format module and its submodules
+ *        to identify fields in formatted output.
+ * @section CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE_HEADER Required Header
+ *        \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE_OVERVIEW Overview
+ * @details Fields are identified by constants, whose names typically end with _FIELD,
+ * defined in the various subclasses of Format. Field position keeps track of the position
+ * of the field within the formatted output with two indices: the index of the first
+ * character of the field and the index of the last character of the field. One version
+ * of the format method in the various Format classes requires a Field Position object
+ * as an argument. You use this format method to perform partial formatting or to get
+ * information about the formatted output (such as the position of a field).
+ * The FieldPosition class is not suitable for subclassing.
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a field position object with a non-specified field.
+ * @remarks The created object should be released by the caller with the
+ *          i18n_field_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[out] field_position  The created field position object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_field_position_create(i18n_field_position_h *field_position);
+
+/**
+ * @brief Creates a field position object for the given field.
+ * @details Fields are identified by constants, whose names typically end with _FIELD,
+ *          in the various subtypes of Format.
+ * @remarks The created object should be released by the caller with the
+ *          i18n_field_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] field            The field value
+ * @param[out] field_position  The created field position object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_field_position_create_for_field(int32_t field, i18n_field_position_h *field_position);
+
+/**
+ * @brief Destroys the field position object.
+ * @since_tizen 3.0
+ *
+ * @param[in] field_position  The field position object to destroy
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_destroy(i18n_field_position_h field_position);
+
+/**
+ * @brief Creates a polymorphic clone of the given @a field_position object.
+ * @remarks The @a clone object should be released by the caller with the
+ *          i18n_field_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in]  field_position  The field position object to be cloned
+ * @param[out] clone           The created field position object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_field_position_clone(i18n_field_position_h field_position, i18n_field_position_h *clone);
+
+/**
+ * @brief Retrieves the field identifier.
+ * @since_tizen 3.0
+ *
+ * @param[in]  field_position  The field_position object
+ * @param[out] field           The field identifier
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_get_field(i18n_field_position_h field_position, int32_t *field);
+
+/**
+ * @brief Retrieves the index of the first character in the requested field.
+ * @since_tizen 3.0
+ *
+ * @param[in]  field_position  The field position object
+ * @param[out] begin_index     The index of the first character in the requested field
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_get_begin_index(i18n_field_position_h field_position, int32_t *begin_index);
+
+/**
+ * @brief Retrieves the index of the character following the last character in the requested field.
+ * @since_tizen 3.0
+ *
+ * @param[in]  field_position  The field position object
+ * @param[out] end_index       The index of the character following the last character
+ *                             in the requested field
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_get_end_index(i18n_field_position_h field_position, int32_t *end_index);
+
+/**
+ * @brief Sets the field.
+ * @since_tizen 3.0
+ *
+ * @param[in] field_position  The field_position object
+ * @param[in] field           The new value of the field
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_set_field(i18n_field_position_h field_position, int32_t field);
+
+/**
+ * @brief Sets the begin index.
+ * @since_tizen 3.0
+ *
+ * @param[in] field_position  The field_position object
+ * @param[in] begin_index     The new value of the begin index
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_set_begin_index(i18n_field_position_h field_position, int32_t begin_index);
+
+/**
+ * @brief Sets the end index.
+ * @since_tizen 3.0
+ *
+ * @param[in] field_position  The field_position object
+ * @param[in] end_position    The new value of the end index
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_set_end_index(i18n_field_position_h field_position, int32_t end_index);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_FIELD_POSITION_H__*/
index 9f8943db7f4d50056bff53129204067308b89255..a4e480c10482d39a8be42a7d08bb4ae97bab3b8b 100644 (file)
@@ -2886,7 +2886,7 @@ typedef void *i18n_measure_h;
 typedef void *i18n_measure_unit_h;
 
 /**
- * @brief Callback function for the #i18n_measure_unit_get_available_types()
+ * @brief Callback function for the i18n_measure_unit_get_available_types()
  *        that returns an enumeration over all recognized types.
  * @since_tizen 3.0
  *
@@ -2953,6 +2953,20 @@ typedef enum {
        I18_ALPHA_IDX_OVERFLOW,
 } i18_alpha_idx_label_type_e;
 
+/**
+ * @brief Handle to the object used by the Format and its subtypes to identify fields in a formatted output
+ * @since_tizen 3.0
+ */
+typedef void *i18n_field_position_h;
+
+/**
+ * @brief DONT_CARE may be specified as the field to indicate that the caller doesn't need to specify a field.
+ * @since_tizen 3.0
+ */
+typedef enum {
+    I18N_FIELD_POSITION_DONT_CARE = -1,
+} i18n_field_position_dont_care_e;
+
 #ifdef __cplusplus
 }
 #endif
index f0dda02a095d4f358671c1ce6746c613d12c70a6..1cd482b0bfea57dc8af6919c1b9d030d78d5d0b4 100644 (file)
@@ -38,6 +38,7 @@
 #include <utils_i18n_measure.h>
 #include <utils_i18n_format.h>
 #include <utils_i18n_measure_format.h>
+#include <utils_i18n_field_position.h>
 
 /**
  * @file utils_i18n.h
@@ -52,7 +53,7 @@ extern "C" {
 /**
  * @ingroup CAPI_BASE_UTILS_MODULE
  * @defgroup CAPI_BASE_UTILS_I18N_MODULE i18n
- * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber, alpha_idx, formattable, measure, format and measure format.
+ * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber, alpha_idx, formattable, measure, format, measure format and field position.
  *        This module provides flexible generation of number or date format patterns and helps you format and parse dates/number for any locale.
  * The i18n module provides various features based on data from ICU. The following table shows the version of ICU used in each Tizen platform.
  * <table>
@@ -152,6 +153,10 @@ extern "C" {
  *       <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
  *       <td>The Measure Format module represents a formatter for measure objects.</td>
  * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION</td>
+ *       <td>The Field Position module is used to identify fields in a formatted output.</td>
+ * </tr>
  * </table>
  *
  * @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
@@ -2853,6 +2858,56 @@ extern "C" {
  *       <td>#i18n_measure_format_create_currency_format</td>
  *       <td>createCurrencyFormat</td>
  * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_create</td>
+ *       <td>FieldPosition</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_create_for_field</td>
+ *       <td>FieldPosition</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_destroy</td>
+ *       <td>~FieldPosition</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_clone</td>
+ *       <td>clone</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_get_field</td>
+ *       <td>getField</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_get_begin_index</td>
+ *       <td>getBeginIndex</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_get_end_index</td>
+ *       <td>getEndIndex</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_set_field</td>
+ *       <td>setField</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_set_begin_index</td>
+ *       <td>setBeginIndex</td>
+ * </tr>
+ * <tr>
+ *       <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
+ *       <td>#i18n_field_position_set_end_index</td>
+ *       <td>setEndIndex</td>
+ * </tr>
  * </table>
  */
 
diff --git a/src/include/wearable/utils_i18n_field_position.h b/src/include/wearable/utils_i18n_field_position.h
new file mode 100644 (file)
index 0000000..a0564ad
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef __UTILS_I18N_FIELD_POSITION_H__
+#define __UTILS_I18N_FIELD_POSITION_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_field_position.h
+ * @version 0.1
+ * @brief utils_i18n_field_position
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE FieldPosition
+ * @brief Field Position is a simple type used by the Format module and its submodules
+ *        to identify fields in formatted output.
+ * @section CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE_HEADER Required Header
+ *        \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE_OVERVIEW Overview
+ * @details Fields are identified by constants, whose names typically end with _FIELD,
+ * defined in the various subclasses of Format. Field position keeps track of the position
+ * of the field within the formatted output with two indices: the index of the first
+ * character of the field and the index of the last character of the field. One version
+ * of the format method in the various Format classes requires a Field Position object
+ * as an argument. You use this format method to perform partial formatting or to get
+ * information about the formatted output (such as the position of a field).
+ * The FieldPosition class is not suitable for subclassing.
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a field position object with a non-specified field.
+ * @remarks The created object should be released by the caller with the
+ *          i18n_field_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[out] field_position  The created field position object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_field_position_create(i18n_field_position_h *field_position);
+
+/**
+ * @brief Creates a field position object for the given field.
+ * @details Fields are identified by constants, whose names typically end with _FIELD,
+ *          in the various subtypes of Format.
+ * @remarks The created object should be released by the caller with the
+ *          i18n_field_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] field            The field value
+ * @param[out] field_position  The created field position object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_field_position_create_for_field(int32_t field, i18n_field_position_h *field_position);
+
+/**
+ * @brief Destroys the field position object.
+ * @since_tizen 3.0
+ *
+ * @param[in] field_position  The field position object to destroy
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_destroy(i18n_field_position_h field_position);
+
+/**
+ * @brief Creates a polymorphic clone of the given @a field_position object.
+ * @remarks The @a clone object should be released by the caller with the
+ *          i18n_field_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in]  field_position  The field position object to be cloned
+ * @param[out] clone           The created field position object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_field_position_clone(i18n_field_position_h field_position, i18n_field_position_h *clone);
+
+/**
+ * @brief Retrieves the field identifier.
+ * @since_tizen 3.0
+ *
+ * @param[in]  field_position  The field_position object
+ * @param[out] field           The field identifier
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_get_field(i18n_field_position_h field_position, int32_t *field);
+
+/**
+ * @brief Retrieves the index of the first character in the requested field.
+ * @since_tizen 3.0
+ *
+ * @param[in]  field_position  The field position object
+ * @param[out] begin_index     The index of the first character in the requested field
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_get_begin_index(i18n_field_position_h field_position, int32_t *begin_index);
+
+/**
+ * @brief Retrieves the index of the character following the last character in the requested field.
+ * @since_tizen 3.0
+ *
+ * @param[in]  field_position  The field position object
+ * @param[out] end_index       The index of the character following the last character
+ *                             in the requested field
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_get_end_index(i18n_field_position_h field_position, int32_t *end_index);
+
+/**
+ * @brief Sets the field.
+ * @since_tizen 3.0
+ *
+ * @param[in] field_position  The field_position object
+ * @param[in] field           The new value of the field
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_set_field(i18n_field_position_h field_position, int32_t field);
+
+/**
+ * @brief Sets the begin index.
+ * @since_tizen 3.0
+ *
+ * @param[in] field_position  The field_position object
+ * @param[in] begin_index     The new value of the begin index
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_set_begin_index(i18n_field_position_h field_position, int32_t begin_index);
+
+/**
+ * @brief Sets the end index.
+ * @since_tizen 3.0
+ *
+ * @param[in] field_position  The field_position object
+ * @param[in] end_position    The new value of the end index
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_field_position_set_end_index(i18n_field_position_h field_position, int32_t end_index);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_FIELD_POSITION_H__*/
index 26ec56d01de38c92546130ca4d98d194bd260d27..26efc0d97674ed79e7bb346faad7c9cdecb75d28 100644 (file)
@@ -2953,6 +2953,20 @@ typedef enum {
        I18_ALPHA_IDX_OVERFLOW,
 } i18_alpha_idx_label_type_e;
 
+/**
+ * @brief Handle to the object used by the Format and its subtypes to identify fields in a formatted output
+ * @since_tizen 3.0
+ */
+typedef void *i18n_field_position_h;
+
+/**
+ * @brief DONT_CARE may be specified as the field to indicate that the caller doesn't need to specify a field.
+ * @since_tizen 3.0
+ */
+typedef enum {
+    I18N_FIELD_POSITION_DONT_CARE = -1,
+} i18n_field_position_dont_care_e;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/utils_i18n_field_position.cpp b/src/utils_i18n_field_position.cpp
new file mode 100644 (file)
index 0000000..8c4c9d7
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include <utils_i18n_field_position.h>
+#include <utils_i18n_private.h>
+
+#include <unicode/fieldpos.h>
+
+int i18n_field_position_create(i18n_field_position_h *field_position)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    *field_position = new FieldPosition();
+    retv_if(*field_position == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_create_for_field(int32_t field, i18n_field_position_h *field_position)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    *field_position = new FieldPosition(field);
+    retv_if(*field_position == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_destroy(i18n_field_position_h field_position)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    delete((FieldPosition *) field_position);
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_clone(i18n_field_position_h field_position, i18n_field_position_h *clone)
+{
+    retv_if(field_position == NULL || clone == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    *clone = ((FieldPosition *) field_position)->clone();
+    retv_if(*clone == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_get_field(i18n_field_position_h field_position, int32_t *field)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+    retv_if(field == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    *field = ((FieldPosition *) field_position)->getField();
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_get_begin_index(i18n_field_position_h field_position, int32_t *begin_index)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+    retv_if(begin_index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    *begin_index = ((FieldPosition *) field_position)->getBeginIndex();
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_get_end_index(i18n_field_position_h field_position, int32_t *end_index)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+    retv_if(end_index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    *end_index = ((FieldPosition *) field_position)->getEndIndex();
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_set_field(i18n_field_position_h field_position, int32_t field)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    ((FieldPosition *) field_position)->setField(field);
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_set_begin_index(i18n_field_position_h field_position, int32_t begin_index)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    ((FieldPosition *) field_position)->setBeginIndex(begin_index);
+
+    return I18N_ERROR_NONE;
+}
+
+int i18n_field_position_set_end_index(i18n_field_position_h field_position, int32_t end_index)
+{
+    retv_if(field_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    ((FieldPosition *) field_position)->setEndIndex(end_index);
+
+    return I18N_ERROR_NONE;
+}