/src/icu/icu4c/source/common/locbased.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // © 2016 and later: Unicode, Inc. and others. |
2 | | // License & terms of use: http://www.unicode.org/copyright.html |
3 | | /* |
4 | | ********************************************************************** |
5 | | * Copyright (c) 2004-2014, International Business Machines |
6 | | * Corporation and others. All Rights Reserved. |
7 | | ********************************************************************** |
8 | | * Author: Alan Liu |
9 | | * Created: January 16 2004 |
10 | | * Since: ICU 2.8 |
11 | | ********************************************************************** |
12 | | */ |
13 | | #include "locbased.h" |
14 | | #include "uresimp.h" |
15 | | |
16 | | U_NAMESPACE_BEGIN |
17 | | |
18 | | const Locale& LocaleBased::getLocale(const Locale& valid, const Locale& actual, |
19 | 10.6k | ULocDataLocaleType type, UErrorCode& status) { |
20 | 10.6k | if (U_FAILURE(status)) { |
21 | 0 | return Locale::getRoot(); |
22 | 0 | } |
23 | | |
24 | 10.6k | switch(type) { |
25 | 10.5k | case ULOC_VALID_LOCALE: |
26 | 10.5k | return valid; |
27 | 153 | case ULOC_ACTUAL_LOCALE: |
28 | 153 | return actual; |
29 | 0 | default: |
30 | 0 | status = U_ILLEGAL_ARGUMENT_ERROR; |
31 | 0 | return Locale::getRoot(); |
32 | 10.6k | } |
33 | 10.6k | } |
34 | | |
35 | | const char* LocaleBased::getLocaleID(const Locale& valid, const Locale& actual, |
36 | 0 | ULocDataLocaleType type, UErrorCode& status) { |
37 | 0 | const Locale& locale = getLocale(valid, actual, type, status); |
38 | |
|
39 | 0 | if (U_FAILURE(status)) { |
40 | 0 | return nullptr; |
41 | 0 | } |
42 | | |
43 | 0 | return locale == Locale::getRoot() ? kRootLocaleName : locale.getName(); |
44 | 0 | } |
45 | | |
46 | | U_NAMESPACE_END |