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