ICU 62.1  62.1
unumberformatter.h
Go to the documentation of this file.
1 // © 2018 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 
4 #include "unicode/utypes.h"
5 
6 #if !UCONFIG_NO_FORMATTING
7 #ifndef __UNUMBERFORMATTER_H__
8 #define __UNUMBERFORMATTER_H__
9 
10 #include "unicode/ufieldpositer.h"
11 #include "unicode/umisc.h"
12 
13 
79 #ifndef U_HIDE_DRAFT_API
80 
98 typedef enum UNumberUnitWidth {
111 
127 
138 
149 
158 
166 #endif /* U_HIDE_DRAFT_API */
167 
168 #ifndef U_HIDE_DRAFT_API
169 
196 typedef enum UGroupingStrategy {
203 
219 
234 
250 
258 
265 
267 #endif /* U_HIDE_DRAFT_API */
268 
269 #ifndef U_HIDE_DRAFT_API
270 
289 typedef enum UNumberSignDisplay {
297 
305 
312 
328 
338 
346 
355 
363 #endif /* U_HIDE_DRAFT_API */
364 
365 #ifndef U_HIDE_DRAFT_API
366 
383 
390 
398 #endif /* U_HIDE_DRAFT_API */
399 
400 #ifndef U_HIDE_DRAFT_API
401 
408 struct UNumberFormatter;
409 typedef struct UNumberFormatter UNumberFormatter;
410 
411 
419 struct UFormattedNumber;
420 typedef struct UFormattedNumber UFormattedNumber;
421 
422 
440 U_DRAFT UNumberFormatter* U_EXPORT2
441 unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
442  UErrorCode* ec);
443 
444 
455 U_DRAFT UFormattedNumber* U_EXPORT2
457 
458 
474 U_DRAFT void U_EXPORT2
475 unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
476  UErrorCode* ec);
477 
478 
494 U_DRAFT void U_EXPORT2
495 unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
496  UErrorCode* ec);
497 
498 
518 U_DRAFT void U_EXPORT2
519 unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
520  UFormattedNumber* uresult, UErrorCode* ec);
521 
522 
537 U_DRAFT int32_t U_EXPORT2
538 unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
539  UErrorCode* ec);
540 
541 
572 U_DRAFT UBool U_EXPORT2
573 unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec);
574 
575 
594 U_DRAFT void U_EXPORT2
595 unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPositionIterator* ufpositer,
596  UErrorCode* ec);
597 
598 
607 U_DRAFT void U_EXPORT2
608 unumf_close(UNumberFormatter* uformatter);
609 
610 
619 U_DRAFT void U_EXPORT2
620 unumf_closeResult(UFormattedNumber* uresult);
621 
622 
623 #if U_SHOW_CPLUSPLUS_API
625 
642 
658 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberPointer, UFormattedNumber, unumf_closeResult);
659 
661 #endif // U_SHOW_CPLUSPLUS_API
662 
663 #endif /* U_HIDE_DRAFT_API */
664 
665 #endif //__UNUMBERFORMATTER_H__
666 #endif /* #if !UCONFIG_NO_FORMATTING */
667 
668 
669 
670 
671 
672 
673 
674 
675 
676 
677 
678 
679 
680 
681 
682 
683 
684 
685 
686 
687 
688 
689 
690 
691 
692 
693 
694 
695 
696 
697 
698 
699 
700 
701 
702 
703 
704 
705 
706 
707 
708 
709 
710 
711 
712 
713 
714 
715 
716 
717 
One more than the highest UNumberSignDisplay value.
UBool unumf_resultNextFieldPosition(const UFormattedNumber *uresult, UFieldPosition *ufpos, UErrorCode *ec)
Determines the start and end indices of the next occurrence of the given field in the output string...
Display grouping using the default strategy for all locales.
UGroupingStrategy
An enum declaring the strategy for when and how to display grouping separators (i.e., the separator, often a comma or period, after every 2-3 powers of ten).
UFormattedNumber * unumf_openResult(UErrorCode *ec)
Creates a new UFormattedNumber for holding the result of a number formatting operation.
Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive nu...
C API:misc definitions.
struct UFieldPositionIterator UFieldPositionIterator
C typedef for struct UFieldPositionIterator.
Definition: ufieldpositer.h:44
Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater.
Use the three-digit ISO XXX code in place of the symbol for displaying currencies.
Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive ...
UNumberDecimalSeparatorDisplay
An enum declaring how to render the decimal separator.
void unumf_close(UNumberFormatter *uformatter)
Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
void unumf_formatDouble(const UNumberFormatter *uformatter, double value, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format a double to a UFormattedNumber.
Do not show the sign on positive or negative numbers.
UNumberFormatter * unumf_openForSkeletonAndLocale(const UChar *skeleton, int32_t skeletonLen, const char *locale, UErrorCode *ec)
Creates a new UNumberFormatter for the given skeleton string and locale.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
Format the number according to the specified unit, but do not display the unit.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:487
A struct representing a range of text containing a specific field.
Definition: umisc.h:34
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
Do not display grouping separators in any locale.
void unumf_formatDecimal(const UNumberFormatter *uformatter, const char *value, int32_t valueLen, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format a decimal number to a UFormattedNumber.
Show the decimal separator when there are one or more digits to display after the separator...
Print the full name of the unit, without any abbreviations.
Print an abbreviated version of the unit name.
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:353
Print an abbreviated version of the unit name.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
"Smart pointer" class; closes a UNumberFormatter via unumf_close().
int32_t unumf_resultToString(const UFormattedNumber *uresult, UChar *buffer, int32_t bufferCapacity, UErrorCode *ec)
Extracts the result number string out of a UFormattedNumber to a UChar buffer if possible.
Show the minus sign on negative numbers, and do not show the sign on positive numbers.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive nu...
Show the minus sign on negative numbers and the plus sign on positive numbers, including zero...
C API: UFieldPositionIterator for use with format APIs.
UNumberUnitWidth
An enum declaring how to render units, including currencies.
Basic definitions for ICU, for both C and C++ APIs.
void unumf_formatInt(const UNumberFormatter *uformatter, int64_t value, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format an integer to a UFormattedNumber.
Always show the decimal separator, even if there are no digits to display after the separator...
Show the minus sign on negative numbers and the plus sign on positive numbers.
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition: umachine.h:113
Display grouping using locale defaults, except do not show grouping on values smaller than 10000 (suc...
Always display the grouping separator on values of at least 1000.
One more than the highest UNumberDecimalSeparatorDisplay value.
void unumf_closeResult(UFormattedNumber *uresult)
Releases the UFormattedNumber created by unumf_openResult().
One more than the highest UGroupingStrategy value.
One more than the highest UNumberUnitWidth value.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
void unumf_resultGetAllFieldPositions(const UFormattedNumber *uresult, UFieldPositionIterator *ufpositer, UErrorCode *ec)
Populates the given iterator with all fields in the formatted output string.