]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/unumsys.cpp
ICU-531.48.tar.gz
[apple/icu.git] / icuSources / i18n / unumsys.cpp
CommitLineData
57a6839d
A
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
16U_NAMESPACE_USE
17
18
19U_CAPI UNumberingSystem* U_EXPORT2
20unumsys_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
27U_CAPI UNumberingSystem* U_EXPORT2
28unumsys_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
38U_CAPI void U_EXPORT2
39unumsys_close(UNumberingSystem *unumsys)
40{
41 delete ((NumberingSystem*)unumsys);
42}
43
44
45U_CAPI UEnumeration* U_EXPORT2
46unumsys_openAvailableNames(UErrorCode *status)
47{
48 // getAvailableNames returns immediately if status indicates error
49 return uenum_openFromStringEnumeration(NumberingSystem::getAvailableNames(*status), status);
50}
51
52
53U_CAPI const char * U_EXPORT2
54unumsys_getName(const UNumberingSystem *unumsys)
55{
56 return ((NumberingSystem*)unumsys)->getName();
57}
58
59
60U_CAPI int32_t U_EXPORT2
61unumsys_getRadix(const UNumberingSystem *unumsys)
62{
63 return ((NumberingSystem*)unumsys)->getRadix();
64}
65
66
67U_CAPI UBool U_EXPORT2
68unumsys_isAlgorithmic(const UNumberingSystem *unumsys)
69{
70 return ((NumberingSystem*)unumsys)->isAlgorithmic();
71}
72
73U_CAPI int32_t U_EXPORT2
74unumsys_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 */