From bc1ec50f0a2f4d4ff479b5d9de0d71d40ea3611f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Szczekutek?= Date: Mon, 27 Jun 2016 15:49:05 +0200 Subject: [PATCH] [Base-utils][Field Position] Complete module added implementation + documentation Change-Id: I94097bf9ef2072e73c8274be3492aad380dc9d7f Signed-off-by: Beata Stefaniuk --- src/CMakeLists.txt | 2 + src/include/mobile/utils_i18n.h | 57 ++++- .../mobile/utils_i18n_field_position.h | 204 ++++++++++++++++++ src/include/mobile/utils_i18n_types.h | 16 +- src/include/wearable/utils_i18n.h | 57 ++++- .../wearable/utils_i18n_field_position.h | 200 +++++++++++++++++ src/include/wearable/utils_i18n_types.h | 14 ++ src/utils_i18n_field_position.cpp | 116 ++++++++++ 8 files changed, 663 insertions(+), 3 deletions(-) create mode 100644 src/include/mobile/utils_i18n_field_position.h create mode 100644 src/include/wearable/utils_i18n_field_position.h create mode 100644 src/utils_i18n_field_position.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d0da72a..8a2df2e 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/include/mobile/utils_i18n.h b/src/include/mobile/utils_i18n.h index d822a18..b155f4d 100644 --- a/src/include/mobile/utils_i18n.h +++ b/src/include/mobile/utils_i18n.h @@ -38,6 +38,7 @@ #include #include #include +#include /** * @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. * @@ -152,6 +153,10 @@ extern "C" { * * * + * + * + * + * *
@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULEThe Measure Format module represents a formatter for measure objects.
@ref CAPI_BASE_UTILS_I18N_FIELD_POSITIONThe Field Position module is used to identify fields in a formatted output.
* * @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table @@ -2853,6 +2858,56 @@ extern "C" { * #i18n_measure_format_create_currency_format * createCurrencyFormat * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_create + * FieldPosition + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_create_for_field + * FieldPosition + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_destroy + * ~FieldPosition + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_clone + * clone + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_get_field + * getField + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_get_begin_index + * getBeginIndex + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_get_end_index + * getEndIndex + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_set_field + * setField + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_set_begin_index + * setBeginIndex + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_set_end_index + * setEndIndex + * * */ diff --git a/src/include/mobile/utils_i18n_field_position.h b/src/include/mobile/utils_i18n_field_position.h new file mode 100644 index 0000000..a80ae77 --- /dev/null +++ b/src/include/mobile/utils_i18n_field_position.h @@ -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 + +/** + * @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 + * + * @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__*/ diff --git a/src/include/mobile/utils_i18n_types.h b/src/include/mobile/utils_i18n_types.h index 9f8943d..a4e480c 100644 --- a/src/include/mobile/utils_i18n_types.h +++ b/src/include/mobile/utils_i18n_types.h @@ -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 diff --git a/src/include/wearable/utils_i18n.h b/src/include/wearable/utils_i18n.h index f0dda02..1cd482b 100644 --- a/src/include/wearable/utils_i18n.h +++ b/src/include/wearable/utils_i18n.h @@ -38,6 +38,7 @@ #include #include #include +#include /** * @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. * @@ -152,6 +153,10 @@ extern "C" { * * * + * + * + * + * *
@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULEThe Measure Format module represents a formatter for measure objects.
@ref CAPI_BASE_UTILS_I18N_FIELD_POSITIONThe Field Position module is used to identify fields in a formatted output.
* * @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table @@ -2853,6 +2858,56 @@ extern "C" { * #i18n_measure_format_create_currency_format * createCurrencyFormat * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_create + * FieldPosition + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_create_for_field + * FieldPosition + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_destroy + * ~FieldPosition + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_clone + * clone + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_get_field + * getField + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_get_begin_index + * getBeginIndex + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_get_end_index + * getEndIndex + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_set_field + * setField + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_set_begin_index + * setBeginIndex + * + * + * @ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE + * #i18n_field_position_set_end_index + * setEndIndex + * * */ diff --git a/src/include/wearable/utils_i18n_field_position.h b/src/include/wearable/utils_i18n_field_position.h new file mode 100644 index 0000000..a0564ad --- /dev/null +++ b/src/include/wearable/utils_i18n_field_position.h @@ -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 + +/** + * @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 + * + * @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__*/ diff --git a/src/include/wearable/utils_i18n_types.h b/src/include/wearable/utils_i18n_types.h index 26ec56d..26efc0d 100644 --- a/src/include/wearable/utils_i18n_types.h +++ b/src/include/wearable/utils_i18n_types.h @@ -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 index 0000000..8c4c9d7 --- /dev/null +++ b/src/utils_i18n_field_position.cpp @@ -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 +#include + +#include + +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; +} -- 2.34.1