utils_i18n_format.cpp
utils_i18n_measure_format.cpp
utils_i18n_field_position.cpp
+ utils_i18n_parse_position.cpp
)
ADD_LIBRARY(${target_name} SHARED ${BASEUTILS_SRCS}
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_parse_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
#include <utils_i18n_format.h>
#include <utils_i18n_measure_format.h>
#include <utils_i18n_field_position.h>
+#include <utils_i18n_parse_position.h>
/**
* @file utils_i18n.h
/**
* @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, measure format and field position.
+ * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber, alpha_idx, formattable, measure unit, measure, format, measure format, field position and parse 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>
* <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>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION</td>
+ * <td>The Parse Position module used by Format and its subclasses to keep track of the current position during parsing.</td>
+ * </tr>
* </table>
*
* @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
* <td>#i18n_field_position_set_end_index</td>
* <td>setEndIndex</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_create</td>
+ * <td>ParsePosition</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_create_with_index</td>
+ * <td>ParsePosition</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_destroy</td>
+ * <td>~ParsePosition</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_clone</td>
+ * <td>clone</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_get_index</td>
+ * <td>getIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_set_index</td>
+ * <td>setIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_set_error_index</td>
+ * <td>setErrorIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_get_error_index</td>
+ * <td>getErrorIndex</td>
+ * </tr>
* </table>
*/
--- /dev/null
+/*
+ * 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_PARSE_POSITION_H__
+#define __UTILS_I18N_PARSE_POSITION_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_parse_position.h
+ * @version 0.1
+ * @brief utils_i18n_parse_position
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE ParsePosition
+ * @brief Parse Position is a simple object used by the Format and its subtypes
+ * to keep track of the current position during parsing.
+ * @section CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE_HEADER Required Header
+ * \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE_OVERVIEW Overview
+ * @details The i18n_format_parse_object() method in the Format types requires
+ * a Parse Position object as an argument.
+ * By design, as you parse through a string with different formats, you can use
+ * the same Parse Position, since the index parameter records the current position.
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a parse position object.
+ * @remarks The created object should be released by the caller with the
+ * i18n_parse_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[out] parse_position The created parse 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_parse_position_create(i18n_parse_position_h *parse_position);
+
+/**
+ * @brief Creates a parse position object with the given initial index.
+ * @remarks The created object should be released by the caller with the
+ * i18n_parse_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[out] parse_position The parse position object
+ * @param[in] new_index The new text offset
+ *
+ * @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_parse_position_create_with_index(int32_t new_index, i18n_parse_position_h *parse_position);
+
+/**
+ * @brief Destroys the parse position object.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse 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_parse_position_destroy(i18n_parse_position_h parse_position);
+
+/**
+ * @brief Creates a polymorphic clone of the given @a parse_position object.
+ * @remarks The @a clone object should be released by the caller with the
+ * i18n_parse_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object to be cloned
+ * @param[out] clone The created parse 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_parse_position_clone(i18n_parse_position_h parse_position, i18n_parse_position_h *clone);
+
+/**
+ * @brief Retrieves the current parse position.
+ * @details On input to a parse method, this is the index of the character
+ * at which parsing will begin; on output, it is the index of the character
+ * following the last character parsed.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object
+ * @param[out] index The current 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_parse_position_get_index(i18n_parse_position_h parse_position, int32_t *index);
+
+/**
+ * @brief Sets the current parse position.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object
+ * @param[in] index The new 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_parse_position_set_index(i18n_parse_position_h parse_position, int32_t index);
+
+/**
+ * @brief Sets the index at which a parse error occurred.
+ * @details Formatters should set this before returning an error code
+ * from their parse_object() method. The default value is -1
+ * if this is not set.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object
+ * @param[in] error_index The error 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_parse_position_set_error_index(i18n_parse_position_h parse_position, int32_t error_index);
+
+/**
+ * @brief Retrieves the index at which an error occurred, or -1 if the error index
+ * has not been set.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object
+ * @param[out] error_index The index at which an error occurred
+ *
+ * @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_parse_position_get_error_index(i18n_parse_position_h parse_position, int32_t *error_index);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_PARSE_POSITION_H__*/
I18N_UMEASFMT_WIDTH_NARROW = 2, /**< Use symbols for measure units when possible */
I18N_UMEASFMT_WIDTH_NUMERIC = 3, /**< Completely omit measure units when possible
For example, format '5 hours, 37 minutes' as '5:37' */
- I18N_UMEASFMT_WIDTH_COUNT = 4, /**< Count of values in this enumeration. */
+ I18N_UMEASFMT_WIDTH_COUNT = 4, /**< Count of values in this enumeration */
} i18n_umeasure_format_width_e;
/**
} 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
+ * @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;
I18N_FIELD_POSITION_DONT_CARE = -1,
} i18n_field_position_dont_care_e;
+/**
+ * @brief Handle to the object used by the Format and its subtypes to keep track of the current position during parsing.
+ * @since_tizen 3.0
+ */
+typedef void *i18n_parse_position_h;
+
#ifdef __cplusplus
}
#endif
#include <utils_i18n_format.h>
#include <utils_i18n_measure_format.h>
#include <utils_i18n_field_position.h>
+#include <utils_i18n_parse_position.h>
/**
* @file utils_i18n.h
/**
* @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, measure format and field position.
+ * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber, alpha_idx, formattable, measure, format, measure format, field position and parse 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>
* <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>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION</td>
+ * <td>The Parse Position module used by Format and its subclasses to keep track of the current position during parsing.</td>
+ * </tr>
* </table>
*
* @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
* <td>#i18n_field_position_set_end_index</td>
* <td>setEndIndex</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_create</td>
+ * <td>ParsePosition</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_create_with_index</td>
+ * <td>ParsePosition</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_destroy</td>
+ * <td>~ParsePosition</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_clone</td>
+ * <td>clone</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_get_index</td>
+ * <td>getIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_set_index</td>
+ * <td>setIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_set_error_index</td>
+ * <td>setErrorIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE</td>
+ * <td>#i18n_parse_position_get_error_index</td>
+ * <td>getErrorIndex</td>
+ * </tr>
* </table>
*/
*/
int i18n_field_position_set_end_index(i18n_field_position_h field_position, int32_t end_index);
+/**
+ * @}
+ */
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+ * 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_PARSE_POSITION_H__
+#define __UTILS_I18N_PARSE_POSITION_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_parse_position.h
+ * @version 0.1
+ * @brief utils_i18n_parse_position
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE ParsePosition
+ * @brief Parse Position is a simple object used by the Format and its subtypes
+ * to keep track of the current position during parsing.
+ * @section CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE_HEADER Required Header
+ * \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE_OVERVIEW Overview
+ * @details The i18n_format_parse_object() method in the Format types requires
+ * a Parse Position object as an argument.
+ * By design, as you parse through a string with different formats, you can use
+ * the same Parse Position, since the index parameter records the current position.
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_PARSE_POSITION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a parse position object.
+ * @remarks The created object should be released by the caller with the
+ * i18n_parse_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[out] parse_position The created parse 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_parse_position_create(i18n_parse_position_h *parse_position);
+
+/**
+ * @brief Creates a parse position object with the given initial index.
+ * @remarks The created object should be released by the caller with the
+ * i18n_parse_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[out] parse_position The parse position object
+ * @param[in] new_index The new text offset
+ *
+ * @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_parse_position_create_with_index(int32_t new_index, i18n_parse_position_h *parse_position);
+
+/**
+ * @brief Destroys the parse position object.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse 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_parse_position_destroy(i18n_parse_position_h parse_position);
+
+/**
+ * @brief Creates a polymorphic clone of the given @a parse_position object.
+ * @remarks The @a clone object should be released by the caller with the
+ * i18n_parse_position_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object to be cloned
+ * @param[out] clone The created parse 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_parse_position_clone(i18n_parse_position_h parse_position, i18n_parse_position_h *clone);
+
+/**
+ * @brief Retrieves the current parse position.
+ * @details On input to a parse method, this is the index of the character
+ * at which parsing will begin; on output, it is the index of the character
+ * following the last character parsed.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object
+ * @param[out] index The current 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_parse_position_get_index(i18n_parse_position_h parse_position, int32_t *index);
+
+/**
+ * @brief Sets the current parse position.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object
+ * @param[in] index The new 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_parse_position_set_index(i18n_parse_position_h parse_position, int32_t index);
+
+/**
+ * @brief Sets the index at which a parse error occurred.
+ * @details Formatters should set this before returning an error code
+ * from their parse_object() method. The default value is -1
+ * if this is not set.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object
+ * @param[in] error_index The error 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_parse_position_set_error_index(i18n_parse_position_h parse_position, int32_t error_index);
+
+/**
+ * @brief Retrieves the index at which an error occurred, or -1 if the error index
+ * has not been set.
+ * @since_tizen 3.0
+ *
+ * @param[in] parse_position The parse position object
+ * @param[out] error_index The index at which an error occurred
+ *
+ * @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_parse_position_get_error_index(i18n_parse_position_h parse_position, int32_t *error_index);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_PARSE_POSITION_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
*
I18N_FIELD_POSITION_DONT_CARE = -1,
} i18n_field_position_dont_care_e;
+/**
+ * @brief Handle to the object used by the Format and its subtypes to keep track of the current position during parsing.
+ * @since_tizen 3.0
+ */
+typedef void *i18n_parse_position_h;
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+ * 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_parse_position.h>
+#include <utils_i18n_private.h>
+
+#include <unicode/parsepos.h>
+
+int i18n_parse_position_create(i18n_parse_position_h *parse_position)
+{
+ retv_if(parse_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *parse_position = new ParsePosition();
+ retv_if(*parse_position == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_parse_position_create_with_index(int32_t new_index, i18n_parse_position_h *parse_position)
+{
+ retv_if(parse_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *parse_position = new ParsePosition(new_index);
+ retv_if(*parse_position == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_parse_position_destroy(i18n_parse_position_h parse_position)
+{
+ retv_if(parse_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ delete((ParsePosition *) parse_position);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_parse_position_clone(i18n_parse_position_h parse_position, i18n_parse_position_h *clone)
+{
+ retv_if(parse_position == NULL || clone == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *clone = ((ParsePosition *) parse_position)->clone();
+ retv_if(*clone == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_parse_position_get_index(i18n_parse_position_h parse_position, int32_t *index)
+{
+ retv_if(parse_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *index = ((ParsePosition *) parse_position)->getIndex();
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_parse_position_set_index(i18n_parse_position_h parse_position, int32_t index)
+{
+ retv_if(parse_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ ((ParsePosition *) parse_position)->setIndex(index);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_parse_position_set_error_index(i18n_parse_position_h parse_position, int32_t error_index)
+{
+ retv_if(parse_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ ((ParsePosition *) parse_position)->setErrorIndex(error_index);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_parse_position_get_error_index(i18n_parse_position_h parse_position, int32_t *error_index)
+{
+ retv_if(parse_position == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(error_index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *error_index = ((ParsePosition *) parse_position)->getErrorIndex();
+
+ return I18N_ERROR_NONE;
+}