usimplenumberformatter.h
Go to the documentation of this file.
// © 2022 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#ifndef __USIMPLENUMBERFORMATTER_H__
#define __USIMPLENUMBERFORMATTER_H__
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/uformattednumber.h"
#include "unicode/unumberoptions.h"
typedef enum USimpleNumberSign {
UNUM_SIMPLE_NUMBER_PLUS_SIGN,
UNUM_SIMPLE_NUMBER_NO_SIGN,
UNUM_SIMPLE_NUMBER_MINUS_SIGN,
} USimpleNumberSign;
struct USimpleNumber;
typedef struct USimpleNumber USimpleNumber;
struct USimpleNumberFormatter;
typedef struct USimpleNumberFormatter USimpleNumberFormatter;
U_CAPI USimpleNumber* U_EXPORT2
usnum_openForInt64(int64_t value, UErrorCode* ec);
U_CAPI void U_EXPORT2
usnum_setToInt64(USimpleNumber* unumber, int64_t value, UErrorCode* ec);
U_CAPI void U_EXPORT2
usnum_multiplyByPowerOfTen(USimpleNumber* unumber, int32_t power, UErrorCode* ec);
U_CAPI void U_EXPORT2
usnum_roundTo(USimpleNumber* unumber, int32_t power, UNumberFormatRoundingMode roundingMode, UErrorCode* ec);
U_CAPI void U_EXPORT2
usnum_setMinimumIntegerDigits(USimpleNumber* unumber, int32_t minimumIntegerDigits, UErrorCode* ec);
U_CAPI void U_EXPORT2
usnum_setMinimumFractionDigits(USimpleNumber* unumber, int32_t minimumFractionDigits, UErrorCode* ec);
#ifndef U_HIDE_DRAFT_API
U_CAPI void U_EXPORT2
usnum_setMaximumIntegerDigits(USimpleNumber* unumber, int32_t maximumIntegerDigits, UErrorCode* ec);
#endif // U_HIDE_DRAFT_API
U_CAPI void U_EXPORT2
usnum_setSign(USimpleNumber* unumber, USimpleNumberSign sign, UErrorCode* ec);
U_CAPI USimpleNumberFormatter* U_EXPORT2
usnumf_openForLocale(const char* locale, UErrorCode* ec);
U_CAPI USimpleNumberFormatter* U_EXPORT2
usnumf_openForLocaleAndGroupingStrategy(
const char* locale, UNumberGroupingStrategy groupingStrategy, UErrorCode* ec);
U_CAPI void U_EXPORT2
usnumf_format(
const USimpleNumberFormatter* uformatter,
USimpleNumber* unumber,
UFormattedNumber* uresult,
UErrorCode* ec);
U_CAPI void U_EXPORT2
usnumf_formatInt64(
const USimpleNumberFormatter* uformatter,
int64_t value,
UFormattedNumber* uresult,
UErrorCode* ec);
U_CAPI void U_EXPORT2
usnum_close(USimpleNumber* unumber);
U_CAPI void U_EXPORT2
usnumf_close(USimpleNumberFormatter* uformatter);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUSimpleNumberPointer, USimpleNumber, usnum_close);
U_DEFINE_LOCAL_OPEN_POINTER(LocalUSimpleNumberFormatterPointer, USimpleNumberFormatter, usnumf_close);
U_NAMESPACE_END
#endif // U_SHOW_CPLUSPLUS_API
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif //__USIMPLENUMBERFORMATTER_H__
LocalUSimpleNumberFormatterPointer
"Smart pointer" class; closes a USimpleNumberFormatter via usnumf_close().
LocalUSimpleNumberPointer
"Smart pointer" class; closes a USimpleNumber via usnum_close().
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition localpointer.h:550
uformattednumber.h
C API: Formatted number result from various number formatting functions.
UFormattedNumber
struct UFormattedNumber UFormattedNumber
C-compatible version of icu::number::FormattedNumber.
Definition uformattednumber.h:43
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
unumberoptions.h
C API: Header-only input options for various number formatting APIs.
UNumberFormatRoundingMode
UNumberFormatRoundingMode
The possible number format rounding modes.
Definition unumberoptions.h:28
UNumberGroupingStrategy
UNumberGroupingStrategy
An enum declaring the strategy for when and how to display grouping separators (i....
Definition unumberoptions.h:96
USimpleNumberSign
USimpleNumberSign
An explicit sign option for a SimpleNumber.
Definition usimplenumberformatter.h:58
UNUM_SIMPLE_NUMBER_MINUS_SIGN
@ UNUM_SIMPLE_NUMBER_MINUS_SIGN
Render a minus sign.
Definition usimplenumberformatter.h:76
UNUM_SIMPLE_NUMBER_NO_SIGN
@ UNUM_SIMPLE_NUMBER_NO_SIGN
Render no sign.
Definition usimplenumberformatter.h:70
UNUM_SIMPLE_NUMBER_PLUS_SIGN
@ UNUM_SIMPLE_NUMBER_PLUS_SIGN
Render a plus sign.
Definition usimplenumberformatter.h:64
usnumf_openForLocale
U_CAPI USimpleNumberFormatter * usnumf_openForLocale(const char *locale, UErrorCode *ec)
Creates a new USimpleNumberFormatter with all locale defaults.
usnum_setSign
U_CAPI void usnum_setSign(USimpleNumber *unumber, USimpleNumberSign sign, UErrorCode *ec)
Sets the sign of the number: an explicit plus sign, explicit minus sign, or no sign.
usnumf_openForLocaleAndGroupingStrategy
U_CAPI USimpleNumberFormatter * usnumf_openForLocaleAndGroupingStrategy(const char *locale, UNumberGroupingStrategy groupingStrategy, UErrorCode *ec)
Creates a new USimpleNumberFormatter, overriding the grouping strategy.
usnum_roundTo
U_CAPI void usnum_roundTo(USimpleNumber *unumber, int32_t power, UNumberFormatRoundingMode roundingMode, UErrorCode *ec)
Rounds the value currently stored in the USimpleNumber to the given power of 10, which can be before ...
usnum_close
U_CAPI void usnum_close(USimpleNumber *unumber)
Frees the memory held by a USimpleNumber.
usnum_setToInt64
U_CAPI void usnum_setToInt64(USimpleNumber *unumber, int64_t value, UErrorCode *ec)
Overwrites the value in a USimpleNumber to an int64_t.
usnumf_formatInt64
U_CAPI void usnumf_formatInt64(const USimpleNumberFormatter *uformatter, int64_t value, UFormattedNumber *uresult, UErrorCode *ec)
Formats an integer using this SimpleNumberFormatter.
usnum_setMaximumIntegerDigits
U_CAPI void usnum_setMaximumIntegerDigits(USimpleNumber *unumber, int32_t maximumIntegerDigits, UErrorCode *ec)
Sets the number of integer digits to the given amount, truncating if necessary.
usnum_setMinimumIntegerDigits
U_CAPI void usnum_setMinimumIntegerDigits(USimpleNumber *unumber, int32_t minimumIntegerDigits, UErrorCode *ec)
Pads the beginning of the number with zeros up to the given minimum number of integer digits.
USimpleNumberFormatter
struct USimpleNumberFormatter USimpleNumberFormatter
C-compatible version of icu::number::SimpleNumberFormatter.
Definition usimplenumberformatter.h:95
usnum_openForInt64
U_CAPI USimpleNumber * usnum_openForInt64(int64_t value, UErrorCode *ec)
Creates a new USimpleNumber to be formatted with a USimpleNumberFormatter.
usnumf_close
U_CAPI void usnumf_close(USimpleNumberFormatter *uformatter)
Frees the memory held by a USimpleNumberFormatter.
usnumf_format
U_CAPI void usnumf_format(const USimpleNumberFormatter *uformatter, USimpleNumber *unumber, UFormattedNumber *uresult, UErrorCode *ec)
Formats a number using this SimpleNumberFormatter.
USimpleNumber
struct USimpleNumber USimpleNumber
C-compatible version of icu::number::SimpleNumber.
Definition usimplenumberformatter.h:86
usnum_setMinimumFractionDigits
U_CAPI void usnum_setMinimumFractionDigits(USimpleNumber *unumber, int32_t minimumFractionDigits, UErrorCode *ec)
Pads the end of the number with zeros up to the given minimum number of fraction digits.
usnum_multiplyByPowerOfTen
U_CAPI void usnum_multiplyByPowerOfTen(USimpleNumber *unumber, int32_t power, UErrorCode *ec)
Changes the value of the USimpleNumber by a power of 10.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430