• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         void emit(const std::u16string_view&);
42         void emit(const UnicodeString&);
43         void emit(const Literal&);
44         void emit(const Key&);
45         void emit(const SelectorKeys&);
46         void emit(const Operand&);
47         void emit(const Expression&);
48         void emit(const PatternPart&);
49         void emit(const Pattern&);
50         void emit(const Variant*);
51         void emitAttributes(const OptionMap&);
52         void emit(const OptionMap&);
53         void serializeDeclarations();
54         void serializeSelectors();
55         void serializeVariants();
56     }; // class Serializer
57 
58 } // namespace message2
59 
60 U_NAMESPACE_END
61 
62 #endif /* #if !UCONFIG_NO_MF2 */
63 
64 #endif /* #if !UCONFIG_NO_FORMATTING */
65 
66 #endif /* U_SHOW_CPLUSPLUS_API */
67 
68 #endif // MESSAGEFORMAT_SERIALIZER_H
69 
70 #endif // U_HIDE_DEPRECATED_API
71 // eof
72 
73