messageformat2_serializer.h (1810B)
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 MESSAGEFORMAT_SERIALIZER_H 9 #define MESSAGEFORMAT_SERIALIZER_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/messageformat2_data_model.h" 20 21 U_NAMESPACE_BEGIN 22 23 namespace message2 { 24 25 using namespace data_model; 26 27 // Serializer class (private) 28 // Converts a data model back to a string 29 // TODO: Should be private; made public so tests 30 // can use it 31 class U_I18N_API Serializer : public UMemory { 32 public: 33 Serializer(const MFDataModel& m, UnicodeString& s) : dataModel(m), result(s) {} 34 void serialize(); 35 36 const MFDataModel& dataModel; 37 UnicodeString& result; 38 39 private: 40 41 void whitespace(); 42 void emit(UChar32); 43 void emit(const std::u16string_view&); 44 void emit(const UnicodeString&); 45 void emit(const Literal&); 46 void emit(const Key&); 47 void emit(const SelectorKeys&); 48 void emit(const Operand&); 49 void emit(const Expression&); 50 void emit(const PatternPart&); 51 void emit(const Pattern&); 52 void emit(const Variant*); 53 void emitAttributes(const OptionMap&); 54 void emit(const OptionMap&); 55 void serializeDeclarations(); 56 void serializeSelectors(); 57 void serializeVariants(); 58 }; // class Serializer 59 60 } // namespace message2 61 62 U_NAMESPACE_END 63 64 #endif /* #if !UCONFIG_NO_MF2 */ 65 66 #endif /* #if !UCONFIG_NO_FORMATTING */ 67 68 #endif /* #if !UCONFIG_NO_NORMALIZATION */ 69 70 #endif /* U_SHOW_CPLUSPLUS_API */ 71 72 #endif // MESSAGEFORMAT_SERIALIZER_H 73 74 #endif // U_HIDE_DEPRECATED_API 75 // eof