1 | // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | // BSD-style license that can be found in the LICENSE file. |
4 | |
5 | #ifndef RUNTIME_VM_ZONE_TEXT_BUFFER_H_ |
6 | #define RUNTIME_VM_ZONE_TEXT_BUFFER_H_ |
7 | |
8 | #include "platform/text_buffer.h" |
9 | #include "vm/allocation.h" |
10 | #include "vm/globals.h" |
11 | |
12 | namespace dart { |
13 | |
14 | class String; |
15 | class Zone; |
16 | |
17 | // ZoneTextBuffer allocates the character buffer in the given zone. Thus, |
18 | // pointers returned by buffer() have the same lifetime as the zone. |
19 | class ZoneTextBuffer : public BaseTextBuffer { |
20 | public: |
21 | explicit ZoneTextBuffer(Zone* zone, intptr_t initial_capacity = 64); |
22 | ~ZoneTextBuffer() {} |
23 | |
24 | // Allocates a new internal buffer. Thus, the contents of buffers returned by |
25 | // previous calls to buffer() are no longer affected by this object. |
26 | void Clear(); |
27 | |
28 | private: |
29 | bool EnsureCapacity(intptr_t len); |
30 | Zone* zone_; |
31 | |
32 | DISALLOW_COPY_AND_ASSIGN(ZoneTextBuffer); |
33 | }; |
34 | |
35 | } // namespace dart |
36 | |
37 | #endif // RUNTIME_VM_ZONE_TEXT_BUFFER_H_ |
38 | |