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