utils_i18n_alpha_idx.cpp
utils_i18n_formattable.cpp
utils_i18n_measure_unit.cpp
+ utils_i18n_measure.cpp
)
ADD_LIBRARY(${target_name} SHARED ${BASEUTILS_SRCS}
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_formattable.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_measure_unit.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_measure.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n.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_alpha_idx.h>
#include <utils_i18n_formattable.h>
#include <utils_i18n_measure_unit.h>
+#include <utils_i18n_measure.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 and measure unit.
+ * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber, alpha_idx, formattable, measure unit and measure.
* 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_MEASURE_UNIT_MODULE</td>
* <td>The MeasureUnit module contains units such as length, mass, volume, currency, etc...</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>The Measure module represents an amount of a specified unit, consisting of a number and a unit.</td>
+ * </tr>
* </table>
*
* @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
* <td>#i18n_measure_unit_create_teaspoon</td>
* <td>createTeaspoon</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_create</td>
+ * <td>Measure</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_clone</td>
+ * <td>clone</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_destroy</td>
+ * <td>~Measure</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_get_number</td>
+ * <td>getNumber</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_get_unit</td>
+ * <td>getUnit</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_MEASURE_H__
+#define __UTILS_I18N_MEASURE_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_measure.h
+ * @version 0.1
+ * @brief utils_i18n_measure
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_MEASURE_MODULE MeasureUnit
+ * @brief Measure object contains an amount of a specified unit, consisting of a number and an unit.
+ * @section CAPI_BASE_UTILS_I18N_MEASURE_MODULE_HEADER Required Header
+ *» \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_MEASURE_MODULE_OVERVIEW Overview
+ * @details
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_MEASURE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates an object with the given numeric amount and the given unit.
+ * @details After this call, the caller must not delete the given measure unit object.
+ * @remarks The created object should be released by the caller with the
+ * #i18n_measure_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] formattable A numeric object; The #i18n_formattable_is_numeric()
+ * function must return @c true for this object.
+ * @param[in] measure_unit The unit object, which must not be @c NULL
+ * @param[out] measure The created measure 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_measure_create(const i18n_formattable_h formattable, i18n_measure_unit_h measure_unit, i18n_measure_h *measure);
+
+/**
+ * @brief Creates a polymorphic clone of the given @a clone object.
+ * @remarks The @c clone object should be released by the caller with the
+ * #i18n_measure_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] measure The measure object to be cloned
+ * @param[out] clone The created measure 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_measure_clone(i18n_measure_h measure, i18n_measure_h *clone);
+
+/**
+ * @brief Destroys the measure object
+ * @since_tizen 3.0
+ *
+ * @param[in] measure The measure 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_measure_destroy(i18n_measure_h measure);
+
+/**
+ * @brief Gets a reference to the numeric value of the measure object.
+ * @remarks The obtained formattable object should be released by the caller
+ * with the #i18n_formattable_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] measure The measure object
+ * @param[out] formattable The numeric value of the measure 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_measure_get_number(i18n_measure_h measure, i18n_formattable_h *formattable);
+
+/**
+ * @brief Gets a reference to the unit of the measure object.
+ * @remarks The obtained measure unit object should be released by the caller
+ * with the #i18n_measure_unit_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] measure The measure object
+ * @param[out] measure_unit The unit of the measure 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_measure_get_unit(i18n_measure_h measure, i18n_measure_unit_h *measure_unit);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_MEASURE_H__*/
#include <utils_i18n_alpha_idx.h>
#include <utils_i18n_formattable.h>
#include <utils_i18n_measure_unit.h>
+#include <utils_i18n_measure.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 and formattable.
+ * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale, unumber, alpha_idx, formattable and measure.
* 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>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_UNIT_MODULE</td>
- * <td>The MeasureUnit module contains unit such as length, mass, volume, currency, etc..</td>
+ * <td>The MeasureUnit module contains units such as length, mass, volume, currency, etc...</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>The Measure module represents an amount of a specified unit, consisting of a number and a unit.</td>
* </tr>
* </table>
*
* <td>#i18n_measure_unit_create_teaspoon</td>
* <td>createTeaspoon</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_create</td>
+ * <td>Measure</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_clone</td>
+ * <td>clone</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_destroy</td>
+ * <td>~Measure</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_get_number</td>
+ * <td>getNumber</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_MODULE</td>
+ * <td>#i18n_measure_get_unit</td>
+ * <td>getUnit</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_MEASURE_H__
+#define __UTILS_I18N_MEASURE_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_measure.h
+ * @version 0.1
+ * @brief utils_i18n_measure
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_MEASURE_MODULE MeasureUnit
+ * @brief Measure object contains an amount of a specified unit, consisting of a number and an unit.
+ * @section CAPI_BASE_UTILS_I18N_MEASURE_MODULE_HEADER Required Header
+ *» \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_MEASURE_MODULE_OVERVIEW Overview
+ * @details
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_MEASURE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates an object with the given numeric amount and the given unit.
+ * @details After this call, the caller must not delete the given measure unit object.
+ * @remarks The created object should be released by the caller with the
+ * #i18n_measure_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] formattable A numeric object; The #i18n_formattable_is_numeric()
+ * function must return @c true for this object.
+ * @param[in] measure_unit The unit object, which must not be @c NULL
+ * @param[out] measure The created measure 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_measure_create(const i18n_formattable_h formattable, i18n_measure_unit_h measure_unit, i18n_measure_h *measure);
+
+/**
+ * @brief Creates a polymorphic clone of the given @a clone object.
+ * @remarks The @c clone object should be released by the caller with the
+ * #i18n_measure_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] measure The measure object to be cloned
+ * @param[out] clone The created measure 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_measure_clone(i18n_measure_h measure, i18n_measure_h *clone);
+
+/**
+ * @brief Destroys the measure object
+ * @since_tizen 3.0
+ *
+ * @param[in] measure The measure 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_measure_destroy(i18n_measure_h measure);
+
+/**
+ * @brief Gets a reference to the numeric value of the measure object.
+ * @remarks The obtained formattable object should be released by the caller
+ * with the #i18n_formattable_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] measure The measure object
+ * @param[out] formattable The numeric value of the measure 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_measure_get_number(i18n_measure_h measure, i18n_formattable_h *formattable);
+
+/**
+ * @brief Gets a reference to the unit of the measure object.
+ * @remarks The obtained measure unit object should be released by the caller
+ * with the #i18n_measure_unit_destroy() function.
+ * @since_tizen 3.0
+ *
+ * @param[in] measure The measure object
+ * @param[out] measure_unit The unit of the measure 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_measure_get_unit(i18n_measure_h measure, i18n_measure_unit_h *measure_unit);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_MEASURE_H__*/
--- /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_measure.h>
+#include <utils_i18n_private.h>
+
+#include <unicode/measure.h>
+#include <unicode/measunit.h>
+
+int i18n_measure_create(const i18n_formattable_h formattable, i18n_measure_unit_h measure_unit, i18n_measure_h *measure)
+{
+ retv_if(measure == NULL || formattable == NULL || measure_unit == NULL, I18N_ERROR_INVALID_PARAMETER);
+ UErrorCode status = U_ZERO_ERROR;
+
+ *measure = new Measure(*((Formattable *) formattable), (MeasureUnit *) measure_unit, status);
+ retv_if(*measure == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_measure_clone(i18n_measure_h measure, i18n_measure_h *clone)
+{
+ retv_if(measure == NULL || clone == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *clone = ((Measure *) measure)->clone();
+ retv_if(*clone == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_measure_destroy(i18n_measure_h measure)
+{
+ retv_if(measure == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ delete((Measure *) measure);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_measure_get_number(i18n_measure_h measure, i18n_formattable_h *formattable)
+{
+ retv_if(measure == NULL || formattable == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ Formattable frmttbl = ((Measure *) measure)->getNumber();
+ *formattable = frmttbl.clone();
+ retv_if(*formattable == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_measure_get_unit(i18n_measure_h measure, i18n_measure_unit_h *measure_unit)
+{
+ retv_if(measure == NULL || measure_unit == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ MeasureUnit mu = ((Measure *) measure)->getUnit();
+ *measure_unit = mu.clone();
+ retv_if(*measure_unit == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return I18N_ERROR_NONE;
+}