From d2fee067d4a9278b71f90d7d3ee4e126880c6269 Mon Sep 17 00:00:00 2001 From: Lukasz Pik Date: Mon, 16 Oct 2017 16:24:03 +0200 Subject: [PATCH] Added formattable guide PS2: Reviewed PS3: Rebase Change-Id: Ifc0d194bd4bbd6d2799010afd632904d790b835a Signed-off-by: Lukasz Pik --- .../html/native/internationalization/i18n_n.htm | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/org.tizen.guides/html/native/internationalization/i18n_n.htm b/org.tizen.guides/html/native/internationalization/i18n_n.htm index 8378052..ae02bac 100644 --- a/org.tizen.guides/html/native/internationalization/i18n_n.htm +++ b/org.tizen.guides/html/native/internationalization/i18n_n.htm @@ -590,6 +590,10 @@

The Format API specifies the protocol for classes which convert between objects or values, such as numeric values and dates, and their string representations. These representations can be localized or contain localized characters or strings.

There is no function for creating an i18n_format_h object, as this module uses a mechanism similar to inheritance in object-oriented languages. All functions with the i18n_format_h handle as a parameter can instead take the handle to a more specific format object from the derived classes.

+

The Formattable API (in mobile and wearable applications) allows you to interconvert between Udate, char string, and primitive numeric types, such as double and long.

+

Internally, an i18n_formattable_h handle holds an object that is a union of primitive types. As such, it can only store 1 flavor of data at a time. To determine what flavor of data it contains, use the i18n_formattable_get_type() function.

+

The Formattable API is a helping object for the Format API and its derived format objects. The formattable object holds the value to be formatted or the formatting result.

+

Measurement Values with Units

The Measure API (in mobile and wearable applications) allows you to create measure objects containing a numerical value and a measurement unit. You can, for example, store a length value in feet or meters.

@@ -2076,6 +2080,77 @@ i18n_format_destroy(format); +

Converting Between Types

+You can use the Formattable API (in mobile and wearable applications) to convert between data types. + +

To manage formattable objects:

+
    +
  1. To create a formattable handler: +
      +
    • Without a specified data type: +
      +i18n_formattable_h formattable;
      +i18n_formattable_create_default(&formattable);
      +
    • +
    • With a specified data type, for example, double: +
      +double value = 20;
      +i18n_formattable_create_double(value, &formattable);
      +
      +

      You can also create handles for udate, long, int64, char pointer, and formattable array.

    • +
  2. +
  3. To clone a formattable object: +
    +i18n_formattable_h clone;
    +i18n_formattable_clone(formattable, &clone);
    +
  4. +
  5. To retrieve formattable object information: +
      +
    • To check whether the value in the formattable object is numeric: +
      +bool is_numeric;
      +i18n_formattable_is_numeric(formattable, &is_numeric);
      +
    • +
    • To get the data type of the value in a formattable object: +
      +i18n_formattable_type_e type;
      +i18n_formattable_get_type(formattable, &type);
      +
    • +
    • To retrieve the value of the formattable object, use the i18n_formattable_get_xxx() function corresponding to the value's data type: +
      +double value;
      +i18n_formattable_get_double(formattable, &value);
      +
      +
    • +
    • To compare whether 2 formattable objects are equal: +
      +bool equal;
      +i18n_formattable_equal(formattable, clone, &equal);
      +
      +

      You can also compare whether 2 objects are not equal, using the i18n_formattable_not_equal() function.

    • +
  6. +
  7. To set a formattable object in a formattable array: +
    +i18n_formattable_h array[3] = {NULL};
    +i18n_formattable_h element;
    +
    +i18n_formattable_create_with_formattable_array(array, 3, &formattable);
    +i18n_formattable_create_double(30, &element);
    +
    +i18n_formattable_element_at(formattable, 0, &element);
    +
  8. +
  9. To set the type of a formattable object, for example, to int64_t: +
    +int64_t value = 15;
    +i18n_formattable_set_int64(formattable, value);
    +
    +

    You can also set the type to double, array, udate, long, or string, using the corresponding i18n_formattable_set_xxx() function.

  10. +
  11. When no longer needed, destroy the formattable object pointer: +
    +i18n_formattable_destroy(formattable);
    +
  12. +
+

Managing Measure Objects

Since Tizen 3.0, you can use the Measure API (in mobile and wearable applications) to create measure objects, containing a numerical value and a measurement unit.

-- 2.7.4