| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_STRING_STREAM_H_ | 5 #ifndef V8_STRING_STREAM_H_ |
| 6 #define V8_STRING_STREAM_H_ | 6 #define V8_STRING_STREAM_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" |
| 9 #include "src/base/smart-pointers.h" |
| 8 #include "src/handles.h" | 10 #include "src/handles.h" |
| 11 #include "src/vector.h" |
| 9 | 12 |
| 10 namespace v8 { | 13 namespace v8 { |
| 11 namespace internal { | 14 namespace internal { |
| 12 | 15 |
| 16 // Forward declarations. |
| 17 class ByteArray; |
| 18 |
| 13 class StringAllocator { | 19 class StringAllocator { |
| 14 public: | 20 public: |
| 15 virtual ~StringAllocator() { } | 21 virtual ~StringAllocator() { } |
| 16 // Allocate a number of bytes. | 22 // Allocate a number of bytes. |
| 17 virtual char* allocate(unsigned bytes) = 0; | 23 virtual char* allocate(unsigned bytes) = 0; |
| 18 // Allocate a larger number of bytes and copy the old buffer to the new one. | 24 // Allocate a larger number of bytes and copy the old buffer to the new one. |
| 19 // bytes is an input and output parameter passing the old size of the buffer | 25 // bytes is an input and output parameter passing the old size of the buffer |
| 20 // and returning the new size. If allocation fails then we return the old | 26 // and returning the new size. If allocation fails then we return the old |
| 21 // buffer and do not increase the size. | 27 // buffer and do not increase the size. |
| 22 virtual char* grow(unsigned* bytes) = 0; | 28 virtual char* grow(unsigned* bytes) = 0; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 174 |
| 169 bool full() const { return (capacity_ - length_) == 1; } | 175 bool full() const { return (capacity_ - length_) == 1; } |
| 170 int space() const { return capacity_ - length_; } | 176 int space() const { return capacity_ - length_; } |
| 171 | 177 |
| 172 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); | 178 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); |
| 173 }; | 179 }; |
| 174 | 180 |
| 175 } } // namespace v8::internal | 181 } } // namespace v8::internal |
| 176 | 182 |
| 177 #endif // V8_STRING_STREAM_H_ | 183 #endif // V8_STRING_STREAM_H_ |
| OLD | NEW |