]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unumsys.cpp
ICU-57166.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / unumsys.cpp
1 /*
2 *****************************************************************************************
3 * Copyright (C) 2013, International Business Machines Corporation and others.
4 * All Rights Reserved.
5 *****************************************************************************************
6 */
7
8 #include "unicode/utypes.h"
9
10 #if !UCONFIG_NO_FORMATTING
11
12 #include "unicode/unumsys.h"
13 #include "unicode/numsys.h"
14 #include "unicode/uenum.h"
15
16 U_NAMESPACE_USE
17
18
19 U_CAPI UNumberingSystem* U_EXPORT2
20 unumsys_open(const char *locale, UErrorCode *status)
21 {
22 // createInstance returns immediately if status indicates error
23 return (UNumberingSystem*)NumberingSystem::createInstance(Locale(locale), *status);
24 }
25
26
27 U_CAPI UNumberingSystem* U_EXPORT2
28 unumsys_openByName(const char *name, UErrorCode *status)
29 {
30 // createInstanceByName does NOT return immediately if status indicates error
31 if (U_FAILURE(*status)) {
32 return NULL;
33 }
34 return (UNumberingSystem*)NumberingSystem::createInstanceByName(name, *status);
35 }
36
37
38 U_CAPI void U_EXPORT2
39 unumsys_close(UNumberingSystem *unumsys)
40 {
41 delete ((NumberingSystem*)unumsys);
42 }
43
44
45 U_CAPI UEnumeration* U_EXPORT2
46 unumsys_openAvailableNames(UErrorCode *status)
47 {
48 // getAvailableNames returns immediately if status indicates error
49 return uenum_openFromStringEnumeration(NumberingSystem::getAvailableNames(*status), status);
50 }
51
52
53 U_CAPI const char * U_EXPORT2
54 unumsys_getName(const UNumberingSystem *unumsys)
55 {
56 return ((NumberingSystem*)unumsys)->getName();
57 }
58
59
60 U_CAPI int32_t U_EXPORT2
61 unumsys_getRadix(const UNumberingSystem *unumsys)
62 {
63 return ((NumberingSystem*)unumsys)->getRadix();
64 }
65
66
67 U_CAPI UBool U_EXPORT2
68 unumsys_isAlgorithmic(const UNumberingSystem *unumsys)
69 {
70 return ((NumberingSystem*)unumsys)->isAlgorithmic();
71 }
72
73 U_CAPI int32_t U_EXPORT2
74 unumsys_getDescription(const UNumberingSystem *unumsys, UChar *result,
75 int32_t resultLength, UErrorCode *status)
76 {
77 if (U_FAILURE(*status)) {
78 return -1;
79 }
80 // implement
81 UnicodeString descrip = ((NumberingSystem*)unumsys)->getDescription();
82 return descrip.extract(result, resultLength, *status);
83 }
84
85
86 #endif /* #if !UCONFIG_NO_FORMATTING */