| 1 | // Licensed to the .NET Foundation under one or more agreements. |
|---|---|
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | #pragma once |
| 6 | |
| 7 | /* |
| 8 | * These values should be kept in sync with |
| 9 | * Interop.GlobalizationInterop.ResultCode |
| 10 | */ |
| 11 | enum ResultCode : int32_t |
| 12 | { |
| 13 | Success = 0, |
| 14 | UnknownError = 1, |
| 15 | InsufficentBuffer = 2, |
| 16 | OutOfMemory = 3 |
| 17 | }; |
| 18 | |
| 19 | /* |
| 20 | Converts a UErrorCode to a ResultCode. |
| 21 | */ |
| 22 | static ResultCode GetResultCode(UErrorCode err) |
| 23 | { |
| 24 | if (err == U_BUFFER_OVERFLOW_ERROR || err == U_STRING_NOT_TERMINATED_WARNING) |
| 25 | { |
| 26 | return InsufficentBuffer; |
| 27 | } |
| 28 | |
| 29 | if (err == U_MEMORY_ALLOCATION_ERROR) |
| 30 | { |
| 31 | return OutOfMemory; |
| 32 | } |
| 33 | |
| 34 | if (U_SUCCESS(err)) |
| 35 | { |
| 36 | return Success; |
| 37 | } |
| 38 | |
| 39 | return UnknownError; |
| 40 | } |
| 41 |