Name: capi-base-utils
Summary: Base Utils
-Version: 2.0.0
+Version: 2.0.1
Release: 1
Group: Base
License: Apache-2.0 and ICU
utils_i18n_ushape.c
utils_i18n_utmscale.c
utils_i18n_ubidi.c
+ utils_i18n_uversion.c
)
ADD_LIBRARY(${target_name} SHARED ${BASEUTILS_SRCS}
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_ushape.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_utmscale.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_ubidi.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_uversion.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_ushape.h>
#include <utils_i18n_utmscale.h>
#include <utils_i18n_ubidi.h>
+#include <utils_i18n_uversion.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
- * - field position
- * - parse position
- * - ushape
- * - utmscale
- * - ubidi
+ * - uchar
+ * - ucollator
+ * - unormalization
+ * - usearch
+ * - ustring
+ * - ucalendar
+ * - udate
+ * - udatepg
+ * - ulocale
+ * - unumber
+ * - alpha_idx
+ * - formattable
+ * - measure unit
+ * - measure
+ * - format
+ * - measure format
+ * - field position
+ * - parse position
+ * - ushape
+ * - utmscale
+ * - ubidi
+ * - uversion
*
* 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.
* <td>@ref CAPI_BASE_UTILS_I18N_UBIDI_MODULE</td>
* <td>Ubidi module provides implementation of the Unicode Bidirectional Algorithm.</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_UVERSION_MODULE</td>
+ * <td>Uversion module provides API for accessing ICU version numbers.</td>
+ * </tr>
* </table>
*
* @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
* <td>#i18n_ubidi_write_reverse</td>
* <td>ubidi_writeReverse</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_UVERSION_MODULE</td>
+ * <td>#i18n_uversion_get_version</td>
+ * <td>u_getVersion</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_UVERSION_MODULE</td>
+ * <td>#i18n_uversion_from_string</td>
+ * <td>u_versionFromString</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_UVERSION_MODULE</td>
+ * <td>#i18n_uversion_from_ustring</td>
+ * <td>u_versionFromUString</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_UVERSION_MODULE</td>
+ * <td>#i18n_uversion_to_string</td>
+ * <td>u_versionToString</td>
+ * </tr>
* </table>
*/
* @}
*/
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_UVERSION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Maximum length of the copyright string.
+ * @since_tizen 4.0
+ */
+#define I18N_UVERSION_COPYRIGHT_STRING_LENGTH 128
+
+/**
+ * @brief Maximum number of numbers ICU version consists of.
+ * @details Each number has value from 0 to 255.
+ * @since_tizen 4.0
+ */
+#define I18N_UVERSION_MAX_VERSION_LENGTH 4
+
+/**
+ * @brief The maximum length of an ICU version string.
+ * @since_tizen 4.0
+ */
+#define I18N_UVERSION_MAX_VERSION_STRING_LENGTH 20
+
+/**
+ * @brief Delimiter used to delimit ICU version fields in a string.
+ * @since_tizen 4.0
+ */
+#define I18N_UVERSION_DELIMITER '.'
+
+/**
+ * @brief The binary form of a version on ICU APIs.
+ * @details To compare two versions, use memcmp(v1,v2,sizeof(i18n_uversion_info)).
+ * @since_tizen 4.0
+ */
+typedef uint8_t i18n_uversion_info[I18N_UVERSION_MAX_VERSION_LENGTH];
+
+/**
+ * @}
+ */
+
#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.
+ */
+
+#ifndef __UTILS_I18N_UVERSION_H__
+#define __UTILS_I18N_UVERSION_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_uversion.h
+ * @version 0.1
+ * @brief utils_i18n_uversion
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_UVERSION_MODULE Uversion
+ * @brief Uversion module provides API for accessing ICU version numbers.
+ *
+ * @section CAPI_BASE_UTILS_I18N_UVERSION_MODULE_HEADER Required Header
+ * \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_UVERSION_MODULE_OVERVIEW Overview
+ * @details Uversion module provides API for accessing ICU version numbers.
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_UVERSION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Gets the ICU release version.
+ * @details The version array stores the version information for ICU. For example, release
+ * "1.3.31.2" is then represented as 0x01031F02.
+ * @since_tizen 4.0
+ *
+ * @param[out] version_array An array which will contain the version
+ *
+ * @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_uversion_get_version(i18n_uversion_info version_array);
+
+/**
+ * @brief Parses a string with dotted-decimal version information and fills in an #i18n_uversion_info
+ * array with the result.
+ * @since_tizen 4.0
+ *
+ * @param[in] version_string A string with dotted-decimal version information, with up to
+ * #I18N_UVERSION_MAX_VERSION_LENGTH non-negative number fields
+ * with values of up to 255 each
+ * @param[out] version_array An array which will contain the version
+ *
+ * @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_uversion_from_string(const char *version_string, i18n_uversion_info version_array);
+
+/**
+ * @brief Parses a Unicode string with dotted-decimal version information and fills in
+ * an #i18n_uversion_info array with the result.
+ * @since_tizen 4.0
+ *
+ * @param[in] version_string A Unicode string with dotted-decimal version information,
+ * with up to #I18N_UVERSION_MAX_VERSION_LENGTH non-negative
+ * number fields with values of up to 255 each
+ * @param[out] version_array An array which will contain the version
+ *
+ * @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_uversion_from_ustring(const i18n_uchar *version_string, i18n_uversion_info version_array);
+
+/**
+ * @brief Writes a string with dotted-decimal version information according to the input
+ * #i18n_uversion_info object.
+ * @since_tizen 4.0
+ *
+ * @param[in] version_array The version information to be written as a string.
+ * @param[out] version_string A string buffer that will be filled in with a string
+ * corresponding to the numeric version information in
+ * @a version_array. The buffer size must be at least
+ * #I18N_UVERSION_MAX_VERSION_STRING_LENGTH.
+ *
+ * @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_uversion_to_string(const i18n_uversion_info version_array, char *version_string);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_UVERSION_H__ */
* UTF-16 uses at least two bytes, growing up to four bytes as necessary,
* that is why we multiply UChar by 4.
*/
- char *_text = NULL;
- _text = (char *)malloc(4 * ulen + 1);
- retv_if(_text == NULL, I18N_ERROR_OUT_OF_MEMORY);
- memset(_text, 0x0, 4 * ulen + 1);
-
+ char _text[4*ulen+4];
+ memset(_text, 0x0, 4 * ulen + 4);
u_austrcpy(_text, _ubidi_text);
int32_t len = strlen(_text);
--- /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 <unicode/umachine.h>
+#include <unicode/uvernum.h>
+
+#include <utils_i18n_uversion.h>
+#include <utils_i18n_private.h>
+
+int i18n_uversion_get_version(i18n_uversion_info version_array)
+{
+ retv_if(version_array == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ u_getVersion(version_array);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_uversion_from_string(const char *version_string, i18n_uversion_info version_array)
+{
+ retv_if(version_string == NULL || version_array == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ u_versionFromString(version_array, version_string);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_uversion_from_ustring(const i18n_uchar *version_string, i18n_uversion_info version_array)
+{
+ retv_if(version_string == NULL || version_array == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ u_versionFromUString(version_array, version_string);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_uversion_to_string(const i18n_uversion_info version_array, char *version_string)
+{
+ retv_if(version_string == NULL || version_array == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ u_versionToString(version_array, version_string);
+
+ return I18N_ERROR_NONE;
+}