Name: capi-base-utils
Summary: Base Utils
-Version: 1.2.3
+Version: 1.2.4
Release: 1
Group: Base
License: Apache-2.0 and ICU
utils_i18n_uset.c
utils_i18n_ubrk.c
utils_i18n_timezone.cpp
+ utils_i18n_alpha_idx.cpp
)
ADD_LIBRARY(${target_name} SHARED ${BASEUTILS_SRCS}
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_uenumeration.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_uset.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_ubrk.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_alpha_idx.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)
#include <utils_i18n_uenumeration.h>
#include <utils_i18n_uset.h>
#include <utils_i18n_ubrk.h>
+#include <utils_i18n_alpha_idx.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 and unumber.
+ * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber and alpha_idx.
* 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_UNUMBER_MODULE</td>
* <td>Unumber helps you format and parse numbers for any locale.</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>Alpha_idx supports the creation of a UI index appropriate for a given language.</td>
+ * </tr>
* </table>
*
* @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
* <td>#i18n_ustring_from_UTF32_with_sub</td>
* <td>u_strFromUTF32WithSub</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_create</td>
+ * <td>AlphabeticIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_destroy</td>
+ * <td>~AlphabeticIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_add_labels</td>
+ * <td>addLabels</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_add_record</td>
+ * <td>addRecord</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_next_bucket</td>
+ * <td>nextBucket</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_next_record</td>
+ * <td>nextRecord</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_record_count</td>
+ * <td>getBucketRecordCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_label</td>
+ * <td>getBucketLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_record_data</td>
+ * <td>getRecordData</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_inflow_label</td>
+ * <td>getInflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_set_inflow_label</td>
+ * <td>setInflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_overflow_label</td>
+ * <td>getOverflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_set_overflow_label</td>
+ * <td>setOverflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_underflow_label</td>
+ * <td>getUnderflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_set_underflow_label</td>
+ * <td>setUnderflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_max_label_count</td>
+ * <td>getMaxLabelCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_set_max_label_count</td>
+ * <td>setMaxLabelCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_clear_records</td>
+ * <td>clearRecords</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_count</td>
+ * <td>getBucketCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_record_count</td>
+ * <td>getRecordCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_index</td>
+ * <td>getBucketIndex(const UnicodeString &itemName, UErrorCode &status)</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_current_bucket_index</td>
+ * <td>getBucketIndex()</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_label_type</td>
+ * <td>getBucketLabelType</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_record_name</td>
+ * <td>getRecordName</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_reset_bucket_iter</td>
+ * <td>resetBucketIterator</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_reset_record_iter</td>
+ * <td>resetRecordIterator</td>
+ * </tr>
* </table>
*/
--- /dev/null
+/*
+ * Copyright (c) 2016 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_ALPHA_IDX_H__
+#define __UTILS_I18N_ALPHA_IDX_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_alpha_idx.h
+ * @version 0.1
+ * @brief utils_i18n_alpha_idx
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE AlphabeticIndex
+ * @brief AlphabeticIndex supports the creation of a UI index appropriate for a given language.
+ * @section CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE_HEADER Required Header
+ * \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE_OVERVIEW Overview
+ * @details The module can generate a list of labels for use as a UI "index",
+ * that is, a list of clickable characters (or character sequences)
+ * that allow the user to see a segment (bucket) of a larger "target" list.
+ * That is, each label corresponds to a bucket in the target list, where
+ * everything in the bucket is greater than or equal to the character
+ * (according to the locale's collation). Strings can be added to the index;
+ * they will be in sorted order in the right bucket.
+ * The module also supports having buckets for strings before the first (underflow),
+ * after the last (overflow), and between scripts (inflow). For example,
+ * if the index is constructed with labels for Russian and English,
+ * Greek characters would fall into an inflow bucket between the other two scripts.
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates an alphabetic index object for the specified locale.
+ * @remarks The created object should be released by the caller with the
+ * #i18n_alpha_idx_destroy() function.
+ *
+ * @param[in] language The language of the locale
+ * @param[in] country The country of the locale
+ * @param[out] index The created alphabetic index 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_alpha_idx_create(const char *language, const char *country,
+ i18_alpha_idx_h *index);
+
+/**
+ * @brief Destroys the alphabetic index object.
+ *
+ * @param[in] index The alphabetic index to be destroyed
+ *
+ * @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_alpha_idx_destroy(i18_alpha_idx_h index);
+
+/**
+ * @brief Adds the index characters from a specified locale to the index.
+ *
+ * @param[in] index Label will be added to this alphabetic index
+ * @param[in] language The language of the locale
+ * @param[in] country The country of the locale
+ *
+ * @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_alpha_idx_add_labels(i18_alpha_idx_h index, const char *language,
+ const char *country);
+
+/**
+ * @brief Adds the record to the alphabetic index.
+ *
+ * @param[in] index Record will be added to this alphabetic index
+ * @param[in] name The display name for the record
+ * @param[in] data An optional pointer to user data associated with this item
+ *
+ * @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_alpha_idx_add_record(i18_alpha_idx_h index, const char *name,
+ const void *data);
+
+/**
+ * @brief Sets the next bucket as current bucket in the index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets
+ * @param[out] success A flag set to @c true if the iteration succeeded,
+ * or @c false at the end of iteration.
+ *
+ * @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_alpha_idx_get_next_bucket(i18_alpha_idx_h index, bool *success);
+
+/**
+ * @brief Sets the next record as current record in current bucket of the index.
+ * @details When i18n_alpha_idx_next_bucket() is called, record iteration is reset
+ * to just before the first record in the new bucket.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] success A flag set to @c true if the iteration succeeded,
+ * or @c false at the end of iteration.
+ *
+ * @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_alpha_idx_get_next_record(i18_alpha_idx_h index, bool *success);
+
+/**
+ * @brief Gets the number of <name, data> records in the current bucket.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] records_count Number of <name, data> records in the current bucket
+ *
+ * @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_alpha_idx_get_bucket_record_count(i18_alpha_idx_h index, int32_t *records_count);
+
+/**
+ * @brief Gets the name of the label of the current bucket in alphabetic index.
+ * @remarks The obtained @a label should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets
+ * @param[out] label The name of the label of the current bucket
+ *
+ * @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_alpha_idx_get_bucket_label(i18_alpha_idx_h index, char **label);
+
+/**
+ * @brief Gets the data pointer of the current record in current bucket in alphabetic index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] data The data pointer of the current record
+ *
+ * @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_INDEX_OUTOFBOUNDS Trying to access the index that is out of bounds
+ */
+int i18n_alpha_idx_get_record_data(i18_alpha_idx_h index, const void **data);
+
+/**
+ * @brief Gets the default label used for abbreviated buckets between other index characters.
+ * @details For example, consider the labels when Latin and Greek are used: X Y Z ... Α Β
+ * Γ.
+ * @remarks The obtained @a label should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] label The default label used for abbreviated bucket between other index characters
+ *
+ * @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_alpha_idx_get_inflow_label(i18_alpha_idx_h index, char **label);
+
+/**
+ * @brief Sets the default label used for abbreviated buckets between other index characters.
+ * @details An inflow label will be automatically inserted if two otherwise-adjacent label characters
+ * are from different scripts, e.g. Latin and Cyrillic, and a third script,
+ * e.g. Greek, sorts between the two. The default inflow character is an ellipsis (...)
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] label The default label used for abbreviated bucket between other index characters
+ *
+ * @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_alpha_idx_set_inflow_label(i18_alpha_idx_h index, const char *label);
+
+/**
+ * @brief Gets the special label used for items that sort after the last normal label,
+ * and that would not otherwise have an appropriate label.
+ * @remarks The obtained @a label should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] label The special label used for items that sort after the last normal label
+ *
+ * @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_alpha_idx_get_overflow_label(i18_alpha_idx_h index, char **label);
+
+/**
+ * @brief Sets the special label used for items that sort after the last normal label,
+ * and that would not otherwise have an appropriate label.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] label The special label used for items that sort after the last normal label
+ *
+ * @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_alpha_idx_set_overflow_label(i18_alpha_idx_h index, const char *label);
+
+/**
+ * @brief Gets the special label used for items that sort before the first normal label,
+ * and that would not otherwise have an appropriate label.
+ * @remarks The obtained @a label should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] label The special label used for items that sort before the first normal label
+ *
+ * @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_alpha_idx_get_underflow_label(i18_alpha_idx_h index, char **label);
+
+/**
+ * @brief Sets the special label used for items that sort before the first normal label,
+ * and that would not otherwise have an appropriate label.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] label The special label used for items that sort before the first normal label
+ *
+ * @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_alpha_idx_set_underflow_label(i18_alpha_idx_h index, const char *label);
+
+/**
+ * @brief Gets the limit on the number of labels permitted in the index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] max_label_count The maximum number of labels
+ *
+ * @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_alpha_idx_get_max_label_count(i18_alpha_idx_h index, int32_t *max_label_count);
+
+/**
+ * @brief Gets the limit on the number of labels permitted in the index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] max_label_count The maximum number of labels
+ *
+ * @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_alpha_idx_set_max_label_count(i18_alpha_idx_h index, int32_t max_label_count);
+
+/**
+ * @brief Remove all records from the index.
+ * @details The set of Buckets, which define the headings under which records are classified,
+ * is not altered.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ *
+ * @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_alpha_idx_clear_records(i18_alpha_idx_h index);
+
+/**
+ * @brief Gets the number of labels in this index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] bucket_count The number of labels in this index, including any under,
+ * over or inflow labels
+ *
+ * @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_alpha_idx_get_bucket_count(i18_alpha_idx_h index, int32_t *bucket_count);
+
+/**
+ * @brief Gets the total number of records in this index, that is, the number of
+ * <name, data> pairs added.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] record_count The number of records in this index, that is,
+ * the total number of (name, data) items added with
+ * i18n_alpha_idx_add_record()
+ *
+ * @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_alpha_idx_get_record_count(i18_alpha_idx_h index, int32_t *record_count);
+
+/**
+ * @brief Given the name of a record, returns the zero-based index of the bucket
+ * in which the item should appear.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] item_name The name whose bucket position in the index is to be determined
+ * @param[out] bucket_index The bucket number for this name
+ *
+ * @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_alpha_idx_get_bucket_index(i18_alpha_idx_h index, const char *item_name, int32_t *bucket_index);
+
+/**
+ * @brief Gets the zero based index of the current bucket of this index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] bucket_index The number of current bucket
+ *
+ * @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_alpha_idx_get_current_bucket_index(i18_alpha_idx_h index, int32_t *bucket_index);
+
+/**
+ * @brief Gets the type of the label for the current bucket.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] type The alphabetic index label type
+ *
+ * @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_alpha_idx_get_bucket_label_type(i18_alpha_idx_h index,
+ i18_alpha_idx_label_type_e *type);
+
+/**
+ * @brief Gets the name of the current record.
+ * @details Returns NULL if the Record iteration position is before first or after the last.
+ * @remarks The obtained @a record_name should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] record_name The name of the current index item
+ *
+ * @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_INDEX_OUTOFBOUNDS Trying to access the index that is out of bounds
+ */
+int i18n_alpha_idx_get_record_name(i18_alpha_idx_h index, char **record_name);
+
+/**
+ * @brief Resets the bucket iteration for this index.
+ * @details The next call to i18n_alpha_idx_next_bucket() will restart the iteration at the first label.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ *
+ * @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_alpha_idx_reset_bucket_iter(i18_alpha_idx_h index);
+
+/**
+ * @brief Resets the record iteration for this index.
+ * @details The next call to i18n_alpha_idx_next_record() will restart the iteration at the first label.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ *
+ * @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_alpha_idx_reset_record_iter(i18_alpha_idx_h index);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_ALPHA_IDX_H__ */
I18N_ULOC_REQUESTED_LOCALE = 2, /**< This is the requested locale (deprecated) */
} i18n_uloc_data_locale_type_e;
+/*
+ * @brief The Alphabetic index handle.
+ * @since_tizen 3.0
+ */
+typedef void *i18_alpha_idx_h;
+
+/**
+ * @brief Enumeration for alphabetic index label types.
+ * @since_tizen 3.0
+ *
+ * @see i18n_alpha_idx_get_bucket_label_type()
+ */
+typedef enum {
+ /**
+ * Normal Label, typically the starting letter of the names in the bucket with this label.
+ */
+ I18_ALPHA_IDX_NORMAL,
+
+ /**
+ * Underflow Label.
+ *
+ * The bucket with this label contains names in scripts that sort before any
+ * of the bucket labels in this index.
+ */
+ I18_ALPHA_IDX_UNDERFLOW,
+
+ /**
+ * Inflow Label.
+ *
+ * The bucket with this label contains names in scripts that sort between
+ * two of the bucket labels in this index. Inflow labels are created when
+ * an index contains normal labels for multiple scripts, and skips other
+ * scripts that sort between some of the included scripts.
+ */
+ I18_ALPHA_IDX_INFLOW,
+
+ /**
+ * Overflow Label.
+ *
+ * The bucket with this label contains names in scripts that sort after
+ * all of the bucket labels in this index.
+ */
+ I18_ALPHA_IDX_OVERFLOW,
+} i18_alpha_idx_label_type_e;
+
#ifdef __cplusplus
}
#endif
#include <utils_i18n_uenumeration.h>
#include <utils_i18n_uset.h>
#include <utils_i18n_ubrk.h>
+#include <utils_i18n_alpha_idx.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 and unumber.
+ * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber and alpha_idx.
* 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_UNUMBER_MODULE</td>
* <td>Unumber helps you format and parse numbers for any locale.</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>Alpha_idx supports the creation of a UI index appropriate for a given language.</td>
+ * </tr>
* </table>
*
* @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
* <td>#i18n_ustring_from_UTF32_with_sub</td>
* <td>u_strFromUTF32WithSub</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_create</td>
+ * <td>AlphabeticIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_destroy</td>
+ * <td>~AlphabeticIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_add_labels</td>
+ * <td>addLabels</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_add_record</td>
+ * <td>addRecord</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_next_bucket</td>
+ * <td>nextBucket</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_next_record</td>
+ * <td>nextRecord</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_record_count</td>
+ * <td>getBucketRecordCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_label</td>
+ * <td>getBucketLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_record_data</td>
+ * <td>getRecordData</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_inflow_label</td>
+ * <td>getInflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_set_inflow_label</td>
+ * <td>setInflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_overflow_label</td>
+ * <td>getOverflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_set_overflow_label</td>
+ * <td>setOverflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_underflow_label</td>
+ * <td>getUnderflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_set_underflow_label</td>
+ * <td>setUnderflowLabel</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_max_label_count</td>
+ * <td>getMaxLabelCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_set_max_label_count</td>
+ * <td>setMaxLabelCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_clear_records</td>
+ * <td>clearRecords</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_count</td>
+ * <td>getBucketCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_record_count</td>
+ * <td>getRecordCount</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_index</td>
+ * <td>getBucketIndex(const UnicodeString &itemName, UErrorCode &status)</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_current_bucket_index</td>
+ * <td>getBucketIndex()</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_bucket_label_type</td>
+ * <td>getBucketLabelType</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_get_record_name</td>
+ * <td>getRecordName</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_reset_bucket_iter</td>
+ * <td>resetBucketIterator</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_reset_record_iter</td>
+ * <td>resetRecordIterator</td>
+ * </tr>
* </table>
*/
--- /dev/null
+/*
+ * Copyright (c) 2016 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_ALPHA_IDX_H__
+#define __UTILS_I18N_ALPHA_IDX_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_alpha_idx.h
+ * @version 0.1
+ * @brief utils_i18n_alpha_idx
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE AlphabeticIndex
+ * @brief AlphabeticIndex supports the creation of a UI index appropriate for a given language.
+ * @section CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE_HEADER Required Header
+ * \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE_OVERVIEW Overview
+ * @details The module can generate a list of labels for use as a UI "index",
+ * that is, a list of clickable characters (or character sequences)
+ * that allow the user to see a segment (bucket) of a larger "target" list.
+ * That is, each label corresponds to a bucket in the target list, where
+ * everything in the bucket is greater than or equal to the character
+ * (according to the locale's collation). Strings can be added to the index;
+ * they will be in sorted order in the right bucket.
+ * The module also supports having buckets for strings before the first (underflow),
+ * after the last (overflow), and between scripts (inflow). For example,
+ * if the index is constructed with labels for Russian and English,
+ * Greek characters would fall into an inflow bucket between the other two scripts.
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates an alphabetic index object for the specified locale.
+ * @remarks The created object should be released by the caller with the
+ * #i18n_alpha_idx_destroy() function.
+ *
+ * @param[in] language The language of the locale
+ * @param[in] country The country of the locale
+ * @param[out] index The created alphabetic index 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_alpha_idx_create(const char *language, const char *country,
+ i18_alpha_idx_h *index);
+
+/**
+ * @brief Destroys the alphabetic index object.
+ *
+ * @param[in] index The alphabetic index to be destroyed
+ *
+ * @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_alpha_idx_destroy(i18_alpha_idx_h index);
+
+/**
+ * @brief Adds the index characters from a specified locale to the index.
+ *
+ * @param[in] index Label will be added to this alphabetic index
+ * @param[in] language The language of the locale
+ * @param[in] country The country of the locale
+ *
+ * @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_alpha_idx_add_labels(i18_alpha_idx_h index, const char *language,
+ const char *country);
+
+/**
+ * @brief Adds the record to the alphabetic index.
+ *
+ * @param[in] index Record will be added to this alphabetic index
+ * @param[in] name The display name for the record
+ * @param[in] data An optional pointer to user data associated with this item
+ *
+ * @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_alpha_idx_add_record(i18_alpha_idx_h index, const char *name,
+ const void *data);
+
+/**
+ * @brief Sets the next bucket as current bucket in the index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets
+ * @param[out] success A flag set to @c true if the iteration succeeded,
+ * or @c false at the end of iteration.
+ *
+ * @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_alpha_idx_get_next_bucket(i18_alpha_idx_h index, bool *success);
+
+/**
+ * @brief Sets the next record as current record in current bucket of the index.
+ * @details When i18n_alpha_idx_next_bucket() is called, record iteration is reset
+ * to just before the first record in the new bucket.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] success A flag set to @c true if the iteration succeeded,
+ * or @c false at the end of iteration.
+ *
+ * @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_alpha_idx_get_next_record(i18_alpha_idx_h index, bool *success);
+
+/**
+ * @brief Gets the number of <name, data> records in the current bucket.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] records_count Number of <name, data> records in the current bucket
+ *
+ * @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_alpha_idx_get_bucket_record_count(i18_alpha_idx_h index, int32_t *records_count);
+
+/**
+ * @brief Gets the name of the label of the current bucket in alphabetic index.
+ * @remarks The obtained @a label should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets
+ * @param[out] label The name of the label of the current bucket
+ *
+ * @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_alpha_idx_get_bucket_label(i18_alpha_idx_h index, char **label);
+
+/**
+ * @brief Gets the data pointer of the current record in current bucket in alphabetic index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] data The data pointer of the current record
+ *
+ * @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_INDEX_OUTOFBOUNDS Trying to access the index that is out of bounds
+ */
+int i18n_alpha_idx_get_record_data(i18_alpha_idx_h index, const void **data);
+
+/**
+ * @brief Gets the default label used for abbreviated buckets between other index characters.
+ * @details For example, consider the labels when Latin and Greek are used: X Y Z ... Α Β
+ * Γ.
+ * @remarks The obtained @a label should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] label The default label used for abbreviated bucket between other index characters
+ *
+ * @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_alpha_idx_get_inflow_label(i18_alpha_idx_h index, char **label);
+
+/**
+ * @brief Sets the default label used for abbreviated buckets between other index characters.
+ * @details An inflow label will be automatically inserted if two otherwise-adjacent label characters
+ * are from different scripts, e.g. Latin and Cyrillic, and a third script,
+ * e.g. Greek, sorts between the two. The default inflow character is an ellipsis (...)
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] label The default label used for abbreviated bucket between other index characters
+ *
+ * @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_alpha_idx_set_inflow_label(i18_alpha_idx_h index, const char *label);
+
+/**
+ * @brief Gets the special label used for items that sort after the last normal label,
+ * and that would not otherwise have an appropriate label.
+ * @remarks The obtained @a label should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] label The special label used for items that sort after the last normal label
+ *
+ * @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_alpha_idx_get_overflow_label(i18_alpha_idx_h index, char **label);
+
+/**
+ * @brief Sets the special label used for items that sort after the last normal label,
+ * and that would not otherwise have an appropriate label.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] label The special label used for items that sort after the last normal label
+ *
+ * @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_alpha_idx_set_overflow_label(i18_alpha_idx_h index, const char *label);
+
+/**
+ * @brief Gets the special label used for items that sort before the first normal label,
+ * and that would not otherwise have an appropriate label.
+ * @remarks The obtained @a label should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] label The special label used for items that sort before the first normal label
+ *
+ * @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_alpha_idx_get_underflow_label(i18_alpha_idx_h index, char **label);
+
+/**
+ * @brief Sets the special label used for items that sort before the first normal label,
+ * and that would not otherwise have an appropriate label.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] label The special label used for items that sort before the first normal label
+ *
+ * @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_alpha_idx_set_underflow_label(i18_alpha_idx_h index, const char *label);
+
+/**
+ * @brief Gets the limit on the number of labels permitted in the index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] max_label_count The maximum number of labels
+ *
+ * @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_alpha_idx_get_max_label_count(i18_alpha_idx_h index, int32_t *max_label_count);
+
+/**
+ * @brief Gets the limit on the number of labels permitted in the index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] max_label_count The maximum number of labels
+ *
+ * @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_alpha_idx_set_max_label_count(i18_alpha_idx_h index, int32_t max_label_count);
+
+/**
+ * @brief Remove all records from the index.
+ * @details The set of Buckets, which define the headings under which records are classified,
+ * is not altered.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ *
+ * @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_alpha_idx_clear_records(i18_alpha_idx_h index);
+
+/**
+ * @brief Gets the number of labels in this index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] bucket_count The number of labels in this index, including any under,
+ * over or inflow labels
+ *
+ * @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_alpha_idx_get_bucket_count(i18_alpha_idx_h index, int32_t *bucket_count);
+
+/**
+ * @brief Gets the total number of records in this index, that is, the number of
+ * <name, data> pairs added.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] record_count The number of records in this index, that is,
+ * the total number of (name, data) items added with
+ * i18n_alpha_idx_add_record()
+ *
+ * @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_alpha_idx_get_record_count(i18_alpha_idx_h index, int32_t *record_count);
+
+/**
+ * @brief Given the name of a record, returns the zero-based index of the bucket
+ * in which the item should appear.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[in] item_name The name whose bucket position in the index is to be determined
+ * @param[out] bucket_index The bucket number for this name
+ *
+ * @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_alpha_idx_get_bucket_index(i18_alpha_idx_h index, const char *item_name, int32_t *bucket_index);
+
+/**
+ * @brief Gets the zero based index of the current bucket of this index.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] bucket_index The number of current bucket
+ *
+ * @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_alpha_idx_get_current_bucket_index(i18_alpha_idx_h index, int32_t *bucket_index);
+
+/**
+ * @brief Gets the type of the label for the current bucket.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] type The alphabetic index label type
+ *
+ * @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_alpha_idx_get_bucket_label_type(i18_alpha_idx_h index,
+ i18_alpha_idx_label_type_e *type);
+
+/**
+ * @brief Gets the name of the current record.
+ * @details Returns NULL if the Record iteration position is before first or after the last.
+ * @remarks The obtained @a record_name should be released by the caller with the free() function.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ * @param[out] record_name The name of the current index item
+ *
+ * @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_INDEX_OUTOFBOUNDS Trying to access the index that is out of bounds
+ */
+int i18n_alpha_idx_get_record_name(i18_alpha_idx_h index, char **record_name);
+
+/**
+ * @brief Resets the bucket iteration for this index.
+ * @details The next call to i18n_alpha_idx_next_bucket() will restart the iteration at the first label.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ *
+ * @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_alpha_idx_reset_bucket_iter(i18_alpha_idx_h index);
+
+/**
+ * @brief Resets the record iteration for this index.
+ * @details The next call to i18n_alpha_idx_next_record() will restart the iteration at the first label.
+ *
+ * @param[in] index The alphabetic index, which contains buckets with records
+ *
+ * @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_alpha_idx_reset_record_iter(i18_alpha_idx_h index);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_ALPHA_IDX_H__ */
I18N_ULOC_REQUESTED_LOCALE = 2, /**< This is the requested locale (deprecated) */
} i18n_uloc_data_locale_type_e;
+/*
+ * @brief The Alphabetic index handle.
+ * @since_tizen 3.0
+ */
+typedef void *i18_alpha_idx_h;
+
+/**
+ * @brief Enumeration for alphabetic index label types.
+ * @since_tizen 3.0
+ *
+ * @see i18n_alpha_idx_get_bucket_label_type()
+ */
+typedef enum {
+ /**
+ * Normal Label, typically the starting letter of the names in the bucket with this label.
+ */
+ I18_ALPHA_IDX_NORMAL,
+
+ /**
+ * Underflow Label.
+ *
+ * The bucket with this label contains names in scripts that sort before any
+ * of the bucket labels in this index.
+ */
+ I18_ALPHA_IDX_UNDERFLOW,
+
+ /**
+ * Inflow Label.
+ *
+ * The bucket with this label contains names in scripts that sort between
+ * two of the bucket labels in this index. Inflow labels are created when
+ * an index contains normal labels for multiple scripts, and skips other
+ * scripts that sort between some of the included scripts.
+ */
+ I18_ALPHA_IDX_INFLOW,
+
+ /**
+ * Overflow Label.
+ *
+ * The bucket with this label contains names in scripts that sort after
+ * all of the bucket labels in this index.
+ */
+ I18_ALPHA_IDX_OVERFLOW,
+} i18_alpha_idx_label_type_e;
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+ * Copyright (c) 2016 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_alpha_idx.h>
+#include <utils_i18n_private.h>
+
+#include <string.h>
+#include <unicode/locid.h>
+#include <unicode/alphaindex.h>
+
+int i18n_alpha_idx_create(const char *language, const char *country,
+ i18_alpha_idx_h *index)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ Locale locale(language, country, 0, 0);
+ UErrorCode status = U_ZERO_ERROR;
+
+ *index = new AlphabeticIndex(locale, status);
+ retv_if(*index == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_destroy(i18_alpha_idx_h index)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ delete ((AlphabeticIndex *) index);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_add_labels(i18_alpha_idx_h index,
+ const char *language, const char *country)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ Locale locale(language, country, 0, 0);
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->addLabels(locale, status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_add_record(i18_alpha_idx_h index, const char *name,
+ const void *data)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ const UnicodeString _name(name);
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->addRecord(_name, data, status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_next_bucket(i18_alpha_idx_h index, bool *success)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ if(success != NULL)
+ *success = ((AlphabeticIndex *) index)->nextBucket(status);
+ else
+ ((AlphabeticIndex *) index)->nextBucket(status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_next_record(i18_alpha_idx_h index, bool *success)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ if(success != NULL)
+ *success = ((AlphabeticIndex *) index)->nextRecord(status);
+ else
+ ((AlphabeticIndex *) index)->nextRecord(status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_bucket_record_count(i18_alpha_idx_h index,
+ int32_t *records_count)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(records_count == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *records_count = ((AlphabeticIndex *) index)->getBucketRecordCount();
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_get_bucket_label(i18_alpha_idx_h index,
+ char **label)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(label == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UnicodeString _label = ((AlphabeticIndex *) index)->getBucketLabel();
+
+ std::string _label_string;
+ _label.toUTF8String(_label_string);
+
+ *label = strdup(_label_string.c_str());
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_get_record_data(i18_alpha_idx_h index,
+ const void **data)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(data == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *data = ((AlphabeticIndex *) index)->getRecordData();
+ retv_if(*data == NULL, I18N_ERROR_INDEX_OUTOFBOUNDS);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_get_inflow_label(i18_alpha_idx_h index,
+ char **label)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(label == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UnicodeString _label = ((AlphabeticIndex *) index)->getInflowLabel();
+
+ std::string _label_string;
+ _label.toUTF8String(_label_string);
+
+ *label = strdup(_label_string.c_str());
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_set_inflow_label(i18_alpha_idx_h index,
+ const char *label)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(label == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ const UnicodeString inflow_label(label);
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->setInflowLabel(inflow_label, status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_overflow_label(i18_alpha_idx_h index,
+ char **label)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(label == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ const UnicodeString overflow_label = ((AlphabeticIndex *) index)->getOverflowLabel();
+
+ std::string _label_string;
+ overflow_label.toUTF8String(_label_string);
+
+ *label = strdup(_label_string.c_str());
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_set_overflow_label(i18_alpha_idx_h index,
+ const char *label)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(label == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ const UnicodeString overflow_label(label);
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->setOverflowLabel(overflow_label, status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_underflow_label(i18_alpha_idx_h index,
+ char **label)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(label == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ const UnicodeString overflow_label = ((AlphabeticIndex *) index)->getOverflowLabel();
+
+ std::string _label_string;
+ overflow_label.toUTF8String(_label_string);
+
+ *label = strdup(_label_string.c_str());
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_set_underflow_label(i18_alpha_idx_h index,
+ const char *label)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(label == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ const UnicodeString underflow_label(label);
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->setOverflowLabel(underflow_label, status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_max_label_count(i18_alpha_idx_h index,
+ int32_t *max_label_count)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(max_label_count == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *max_label_count = ((AlphabeticIndex *) index)->getMaxLabelCount();
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_set_max_label_count(i18_alpha_idx_h index,
+ int32_t max_label_count)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->setMaxLabelCount(max_label_count, status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_clear_records(i18_alpha_idx_h index)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->clearRecords(status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_bucket_count(i18_alpha_idx_h index,
+ int32_t *bucket_count)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(bucket_count == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ *bucket_count = ((AlphabeticIndex *) index)->getBucketCount(status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_record_count(i18_alpha_idx_h index,
+ int32_t *record_count)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(record_count == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ *record_count = ((AlphabeticIndex *) index)->getRecordCount(status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_bucket_index(i18_alpha_idx_h index,
+ const char *item_name,
+ int32_t *bucket_index)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(item_name == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(bucket_index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UnicodeString _item_name(item_name);
+ UErrorCode status = U_ZERO_ERROR;
+
+ *bucket_index = ((AlphabeticIndex *) index)->getBucketIndex(_item_name, status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_get_current_bucket_index(i18_alpha_idx_h index,
+ int32_t *bucket_index)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(bucket_index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *bucket_index = ((AlphabeticIndex *) index)->getBucketIndex();
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_get_bucket_label_type(i18_alpha_idx_h index,
+ i18_alpha_idx_label_type_e *type)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(type == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *type = (i18_alpha_idx_label_type_e) ((AlphabeticIndex *) index)->getBucketLabelType();
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_get_record_name(i18_alpha_idx_h index,
+ char **record_name)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(record_name == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ const UnicodeString _record_name = ((AlphabeticIndex *) index)->getRecordName();
+
+ std::string _record_name_string;
+ _record_name.toUTF8String(_record_name_string);
+
+ *record_name = strdup(_record_name_string.c_str());
+
+ if(_record_name.isEmpty()) {
+ return I18N_ERROR_INDEX_OUTOFBOUNDS;
+ }
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_alpha_idx_reset_bucket_iter(i18_alpha_idx_h index)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->resetBucketIterator(status);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_reset_record_iter(i18_alpha_idx_h index)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ ((AlphabeticIndex *) index)->resetRecordIterator();
+
+ return I18N_ERROR_NONE;
+}