| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#ifndef __LSR_H__ |
| 8 |
#define __LSR_H__ |
| 9 |
|
| 10 |
#include "unicode/stringpiece.h" |
| 11 |
#include "unicode/utypes.h" |
| 12 |
#include "unicode/uobject.h" |
| 13 |
#include "cstring.h" |
| 14 |
|
| 15 |
U_NAMESPACE_BEGIN |
| 16 |
|
| 17 |
struct LSR final : public UMemory { |
| 18 |
static constexpr int32_t REGION_INDEX_LIMIT = 1001 + 26 * 26; |
| 19 |
|
| 20 |
static constexpr int32_t EXPLICIT_LSR = 7; |
| 21 |
static constexpr int32_t EXPLICIT_LANGUAGE = 4; |
| 22 |
static constexpr int32_t EXPLICIT_SCRIPT = 2; |
| 23 |
static constexpr int32_t EXPLICIT_REGION = 1; |
| 24 |
static constexpr int32_t IMPLICIT_LSR = 0; |
| 25 |
static constexpr int32_t DONT_CARE_FLAGS = 0; |
| 26 |
|
| 27 |
const char *language; |
| 28 |
const char *script; |
| 29 |
const char *region; |
| 30 |
char *owned = nullptr; |
| 31 |
|
| 32 |
int32_t regionIndex = 0; |
| 33 |
int32_t flags = 0; |
| 34 |
|
| 35 |
int32_t hashCode = 0; |
| 36 |
|
| 37 |
LSR() : language("und"), script(""), region("") {} |
| 38 |
|
| 39 |
|
| 40 |
LSR(const char *lang, const char *scr, const char *r, int32_t f) : |
| 41 |
language(lang), script(scr), region(r), |
| 42 |
regionIndex(indexForRegion(region)), flags(f) {} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
LSR(char prefix, const char *lang, const char *scr, const char *r, int32_t f, |
| 48 |
UErrorCode &errorCode); |
| 49 |
LSR(StringPiece lang, StringPiece scr, StringPiece r, int32_t f, |
| 50 |
UErrorCode &errorCode); |
| 51 |
LSR(LSR &&other) noexcept; |
| 52 |
LSR(const LSR &other) = delete; |
| 53 |
inline ~LSR() { |
| 54 |
|
| 55 |
if (owned != nullptr) { |
| 56 |
deleteOwned(); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
LSR &operator=(LSR &&other) noexcept; |
| 61 |
LSR &operator=(const LSR &other) = delete; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
static int32_t indexForRegion(const char *region); |
| 69 |
|
| 70 |
UBool isEquivalentTo(const LSR &other) const; |
| 71 |
bool operator==(const LSR &other) const; |
| 72 |
|
| 73 |
inline bool operator!=(const LSR &other) const { |
| 74 |
return !operator==(other); |
| 75 |
} |
| 76 |
|
| 77 |
LSR &setHashCode(); |
| 78 |
|
| 79 |
private: |
| 80 |
void deleteOwned(); |
| 81 |
}; |
| 82 |
|
| 83 |
U_NAMESPACE_END |
| 84 |
|
| 85 |
#endif |