| 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 | |
| 105 // Renders a DataPiece object to a ObjectWriter. | 104 // Renders a DataPiece object to a ObjectWriter. |
| 106 static void RenderDataPieceTo(const DataPiece& data, StringPiece name, | 105 static void RenderDataPieceTo(const DataPiece& data, StringPiece name, |
| 107 ObjectWriter* ow); | 106 ObjectWriter* ow); |
| 108 | 107 |
| 109 // Indicates whether this ObjectWriter has completed writing the root message, | 108 // Indicates whether this ObjectWriter has completed writing the root message, |
| 110 // usually this means writing of one complete object. Subclasses must override | 109 // usually this means writing of one complete object. Subclasses must override |
| 111 // this behavior appropriately. | 110 // this behavior appropriately. |
| 112 virtual bool done() { return false; } | 111 virtual bool done() { return false; } |
| 113 | 112 |
| 114 void set_use_strict_base64_decoding(bool value) { | 113 void set_use_strict_base64_decoding(bool value) { |
| 115 use_strict_base64_decoding_ = value; | 114 use_strict_base64_decoding_ = value; |
| 116 } | 115 } |
| 117 | 116 |
| 118 bool use_strict_base64_decoding() const { | 117 bool use_strict_base64_decoding() const { |
| 119 return use_strict_base64_decoding_; | 118 return use_strict_base64_decoding_; |
| 120 } | 119 } |
| 121 | 120 |
| 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 | |
| 129 protected: | 121 protected: |
| 130 ObjectWriter() : use_strict_base64_decoding_(true) {} | 122 ObjectWriter() : use_strict_base64_decoding_(true) {} |
| 131 | 123 |
| 132 private: | 124 private: |
| 133 // If set to true, we use the stricter version of base64 decoding for byte | 125 // If set to true, we use the stricter version of base64 decoding for byte |
| 134 // fields by making sure decoded version encodes back to the original string. | 126 // fields by making sure decoded version encodes back to the original string. |
| 135 bool use_strict_base64_decoding_; | 127 bool use_strict_base64_decoding_; |
| 136 | 128 |
| 137 // Do not add any data members to this class. | 129 // Do not add any data members to this class. |
| 138 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectWriter); | 130 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectWriter); |
| 139 }; | 131 }; |
| 140 | 132 |
| 141 } // namespace converter | 133 } // namespace converter |
| 142 } // namespace util | 134 } // namespace util |
| 143 } // namespace protobuf | 135 } // namespace protobuf |
| 144 | 136 |
| 145 } // namespace google | 137 } // namespace google |
| 146 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ | 138 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ |
| OLD | NEW |