OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 // Renders a StringPiece value. This is for rendering strings. | 95 // Renders a StringPiece value. This is for rendering strings. |
96 virtual ObjectWriter* RenderString(StringPiece name, StringPiece value) = 0; | 96 virtual ObjectWriter* RenderString(StringPiece name, StringPiece value) = 0; |
97 | 97 |
98 // Renders a bytes value. | 98 // Renders a bytes value. |
99 virtual ObjectWriter* RenderBytes(StringPiece name, StringPiece value) = 0; | 99 virtual ObjectWriter* RenderBytes(StringPiece name, StringPiece value) = 0; |
100 | 100 |
101 // Renders a Null value. | 101 // Renders a Null value. |
102 virtual ObjectWriter* RenderNull(StringPiece name) = 0; | 102 virtual ObjectWriter* RenderNull(StringPiece name) = 0; |
103 | 103 |
| 104 |
104 // Renders a DataPiece object to a ObjectWriter. | 105 // Renders a DataPiece object to a ObjectWriter. |
105 static void RenderDataPieceTo(const DataPiece& data, StringPiece name, | 106 static void RenderDataPieceTo(const DataPiece& data, StringPiece name, |
106 ObjectWriter* ow); | 107 ObjectWriter* ow); |
107 | 108 |
108 // Indicates whether this ObjectWriter has completed writing the root message, | 109 // Indicates whether this ObjectWriter has completed writing the root message, |
109 // usually this means writing of one complete object. Subclasses must override | 110 // usually this means writing of one complete object. Subclasses must override |
110 // this behavior appropriately. | 111 // this behavior appropriately. |
111 virtual bool done() { return false; } | 112 virtual bool done() { return false; } |
112 | 113 |
113 void set_use_strict_base64_decoding(bool value) { | 114 void set_use_strict_base64_decoding(bool value) { |
114 use_strict_base64_decoding_ = value; | 115 use_strict_base64_decoding_ = value; |
115 } | 116 } |
116 | 117 |
117 bool use_strict_base64_decoding() const { | 118 bool use_strict_base64_decoding() const { |
118 return use_strict_base64_decoding_; | 119 return use_strict_base64_decoding_; |
119 } | 120 } |
120 | 121 |
| 122 // Whether empty strings should be rendered for the next name for Start/Render |
| 123 // calls. This setting is only valid until the next key is rendered, after |
| 124 // which it gets reset. |
| 125 // It is up to the derived classes to interpret this and render accordingly. |
| 126 // Default implementation ignores this setting. |
| 127 virtual void empty_name_ok_for_next_key() {} |
| 128 |
121 protected: | 129 protected: |
122 ObjectWriter() : use_strict_base64_decoding_(true) {} | 130 ObjectWriter() : use_strict_base64_decoding_(true) {} |
123 | 131 |
124 private: | 132 private: |
125 // If set to true, we use the stricter version of base64 decoding for byte | 133 // If set to true, we use the stricter version of base64 decoding for byte |
126 // fields by making sure decoded version encodes back to the original string. | 134 // fields by making sure decoded version encodes back to the original string. |
127 bool use_strict_base64_decoding_; | 135 bool use_strict_base64_decoding_; |
128 | 136 |
129 // Do not add any data members to this class. | 137 // Do not add any data members to this class. |
130 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectWriter); | 138 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectWriter); |
131 }; | 139 }; |
132 | 140 |
133 } // namespace converter | 141 } // namespace converter |
134 } // namespace util | 142 } // namespace util |
135 } // namespace protobuf | 143 } // namespace protobuf |
136 | 144 |
137 } // namespace google | 145 } // namespace google |
138 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ | 146 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ |
OLD | NEW |