messageformat2_macros.h (3407B)
1 // © 2024 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 4 #include "unicode/utypes.h" 5 6 #ifndef U_HIDE_DEPRECATED_API 7 8 #ifndef MESSAGEFORMAT2_MACROS_H 9 #define MESSAGEFORMAT2_MACROS_H 10 11 #if U_SHOW_CPLUSPLUS_API 12 13 #if !UCONFIG_NO_NORMALIZATION 14 15 #if !UCONFIG_NO_FORMATTING 16 17 #if !UCONFIG_NO_MF2 18 19 #include "unicode/format.h" 20 #include "unicode/unistr.h" 21 #include "plurrule_impl.h" 22 23 U_NAMESPACE_BEGIN 24 25 namespace message2 { 26 27 using namespace pluralimpl; 28 29 // Tokens for parser and serializer 30 31 // Syntactically significant characters 32 #define LEFT_CURLY_BRACE ((UChar32)0x007B) 33 #define RIGHT_CURLY_BRACE ((UChar32)0x007D) 34 #define HTAB ((UChar32)0x0009) 35 #define CR ((UChar32)0x000D) 36 #define LF ((UChar32)0x000A) 37 #define IDEOGRAPHIC_SPACE ((UChar32)0x3000) 38 39 #define PIPE ((UChar32)0x007C) 40 #define EQUALS ((UChar32)0x003D) 41 #define DOLLAR ((UChar32)0x0024) 42 #define COLON ((UChar32)0x003A) 43 #define PLUS ((UChar32)0x002B) 44 #define HYPHEN ((UChar32)0x002D) 45 #define PERIOD ((UChar32)0x002E) 46 #define UNDERSCORE ((UChar32)0x005F) 47 48 #define LOWERCASE_E ((UChar32)0x0065) 49 #define UPPERCASE_E ((UChar32)0x0045) 50 51 // Reserved sigils 52 #define BANG ((UChar32)0x0021) 53 #define AT ((UChar32)0x0040) 54 #define PERCENT ((UChar32)0x0025) 55 #define CARET ((UChar32)0x005E) 56 #define AMPERSAND ((UChar32)0x0026) 57 #define LESS_THAN ((UChar32)0x003C) 58 #define GREATER_THAN ((UChar32)0x003E) 59 #define QUESTION ((UChar32)0x003F) 60 #define TILDE ((UChar32)0x007E) 61 62 // Fallback 63 #define REPLACEMENT ((UChar32) 0xFFFD) 64 65 // MessageFormat2 uses three keywords: `.input`, `.local`, and `.match`. 66 67 static constexpr std::u16string_view ID_INPUT = u".input"; 68 static constexpr std::u16string_view ID_LOCAL = u".local"; 69 static constexpr std::u16string_view ID_MATCH = u".match"; 70 71 // Returns immediately if `errorCode` indicates failure 72 #define CHECK_ERROR(errorCode) \ 73 if (U_FAILURE(errorCode)) { \ 74 return; \ 75 } 76 77 // Returns immediately if `errorCode` indicates failure 78 #define NULL_ON_ERROR(errorCode) \ 79 if (U_FAILURE(errorCode)) { \ 80 return nullptr; \ 81 } 82 83 // Returns immediately if `errorCode` indicates failure 84 #define THIS_ON_ERROR(errorCode) \ 85 if (U_FAILURE(errorCode)) { \ 86 return *this; \ 87 } 88 89 // Returns immediately if `errorCode` indicates failure 90 #define EMPTY_ON_ERROR(errorCode) \ 91 if (U_FAILURE(errorCode)) { \ 92 return {}; \ 93 } 94 95 } // namespace message2 96 U_NAMESPACE_END 97 98 #endif /* #if !UCONFIG_NO_MF2 */ 99 100 #endif /* #if !UCONFIG_NO_FORMATTING */ 101 102 #endif /* #if !UCONFIG_NO_NORMALIZATION */ 103 104 #endif /* U_SHOW_CPLUSPLUS_API */ 105 106 #endif // MESSAGEFORMAT2_MACROS_H 107 108 #endif // U_HIDE_DEPRECATED_API 109 // eof