aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/i18n/unumsys.cpp
blob: 4a0d0fa3b6f3473339926fe3790cdcc831da17b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
* Copyright (C) 2013, International Business Machines Corporation and others.
* All Rights Reserved.
*****************************************************************************************
*/

#include "unicode/utypes.h"

#if !UCONFIG_NO_FORMATTING

#include "unicode/unumsys.h"
#include "unicode/numsys.h"
#include "unicode/uenum.h"

U_NAMESPACE_USE


U_CAPI UNumberingSystem* U_EXPORT2
unumsys_open(const char *locale, UErrorCode *status)
{
    // createInstance returns immediately if status indicates error
    return (UNumberingSystem*)NumberingSystem::createInstance(Locale(locale), *status);
}


U_CAPI UNumberingSystem* U_EXPORT2
unumsys_openByName(const char *name, UErrorCode *status)
{
    // createInstanceByName does NOT return immediately if status indicates error
    if (U_FAILURE(*status)) {
        return NULL;
    }
    return (UNumberingSystem*)NumberingSystem::createInstanceByName(name, *status);
}


U_CAPI void U_EXPORT2
unumsys_close(UNumberingSystem *unumsys)
{
    delete ((NumberingSystem*)unumsys);
}


U_CAPI UEnumeration* U_EXPORT2
unumsys_openAvailableNames(UErrorCode *status)
{
    // getAvailableNames returns immediately if status indicates error
    return uenum_openFromStringEnumeration(NumberingSystem::getAvailableNames(*status), status);
}


U_CAPI const char * U_EXPORT2
unumsys_getName(const UNumberingSystem *unumsys)
{
    return ((NumberingSystem*)unumsys)->getName();
}


U_CAPI int32_t U_EXPORT2
unumsys_getRadix(const UNumberingSystem *unumsys)
{
    return ((NumberingSystem*)unumsys)->getRadix();
}


U_CAPI UBool U_EXPORT2
unumsys_isAlgorithmic(const UNumberingSystem *unumsys)
{
    return ((NumberingSystem*)unumsys)->isAlgorithmic();
}

U_CAPI int32_t U_EXPORT2
unumsys_getDescription(const UNumberingSystem *unumsys, UChar *result,
                       int32_t resultLength, UErrorCode *status)
{
    if (U_FAILURE(*status)) {
        return -1;
    }
    // implement
    UnicodeString descrip = ((NumberingSystem*)unumsys)->getDescription();
    return descrip.extract(result, resultLength, *status);
}


#endif /* #if !UCONFIG_NO_FORMATTING */