| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 private: | 202 private: |
| 203 char* outbuf_; | 203 char* outbuf_; |
| 204 const size_t capacity_; | 204 const size_t capacity_; |
| 205 size_t size_; | 205 size_t size_; |
| 206 bool overflowed_; | 206 bool overflowed_; |
| 207 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CheckedArrayByteSink); | 207 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CheckedArrayByteSink); |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // Implementation of ByteSink that allocates an internal buffer (a char array) | 210 // Implementation of ByteSink that allocates an internal buffer (a char array) |
| 211 // and expands it as needed to accomodate appended data (similar to a string), | 211 // and expands it as needed to accommodate appended data (similar to a string), |
| 212 // and allows the caller to take ownership of the internal buffer via the | 212 // and allows the caller to take ownership of the internal buffer via the |
| 213 // GetBuffer() method. The buffer returned from GetBuffer() must be deleted by | 213 // GetBuffer() method. The buffer returned from GetBuffer() must be deleted by |
| 214 // the caller with delete[]. GetBuffer() also sets the internal buffer to be | 214 // the caller with delete[]. GetBuffer() also sets the internal buffer to be |
| 215 // empty, and subsequent appends to the sink will create a new buffer. The | 215 // empty, and subsequent appends to the sink will create a new buffer. The |
| 216 // destructor will free the internal buffer if GetBuffer() was not called. | 216 // destructor will free the internal buffer if GetBuffer() was not called. |
| 217 // | 217 // |
| 218 // Example: | 218 // Example: |
| 219 // | 219 // |
| 220 // GrowingArrayByteSink sink(10); | 220 // GrowingArrayByteSink sink(10); |
| 221 // sink.Append("hi", 2); | 221 // sink.Append("hi", 2); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 private: | 339 private: |
| 340 ByteSource* source_; | 340 ByteSource* source_; |
| 341 size_t limit_; | 341 size_t limit_; |
| 342 }; | 342 }; |
| 343 | 343 |
| 344 } // namespace strings | 344 } // namespace strings |
| 345 } // namespace protobuf | 345 } // namespace protobuf |
| 346 } // namespace google | 346 } // namespace google |
| 347 | 347 |
| 348 #endif // GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_ | 348 #endif // GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_ |
| OLD | NEW |