xref: /aosp_15_r20/external/icu/libicu/cts_headers/messageformat2_serializer.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
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_FORMATTING
14 
15 #if !UCONFIG_NO_MF2
16 
17 #include "unicode/messageformat2_data_model.h"
18 
19 U_NAMESPACE_BEGIN
20 
21 namespace message2 {
22 
23     using namespace data_model;
24 
25     // Serializer class (private)
26     // Converts a data model back to a string
27     // TODO: Should be private; made public so tests
28     // can use it
29     class U_I18N_API Serializer : public UMemory {
30     public:
Serializer(const MFDataModel & m,UnicodeString & s)31         Serializer(const MFDataModel& m, UnicodeString& s) : dataModel(m), result(s) {}
32         void serialize();
33 
34         const MFDataModel& dataModel;
35         UnicodeString& result;
36 
37     private:
38 
39         void whitespace();
40         void emit(UChar32);
41         template <int32_t N>
42         void emit(const UChar32 (&)[N]);
43         void emit(const UnicodeString&);
44         void emit(const Literal&);
45         void emit(const Key&);
46         void emit(const SelectorKeys&);
47         void emit(const Operand&);
48         void emit(const Reserved&);
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 serializeUnsupported();
56         void serializeDeclarations();
57         void serializeSelectors();
58         void serializeVariants();
59     }; // class Serializer
60 
61 } // namespace message2
62 
63 U_NAMESPACE_END
64 
65 #endif /* #if !UCONFIG_NO_MF2 */
66 
67 #endif /* #if !UCONFIG_NO_FORMATTING */
68 
69 #endif /* U_SHOW_CPLUSPLUS_API */
70 
71 #endif // MESSAGEFORMAT_SERIALIZER_H
72 
73 #endif // U_HIDE_DEPRECATED_API
74 // eof
75 
76