Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: runtime/platform/text_buffer.h

Issue 2081433002: Use official JSON encoding for stream (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixed & Added UTF-32 characters tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/platform/text_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef PLATFORM_TEXT_BUFFER_H_ 5 #ifndef PLATFORM_TEXT_BUFFER_H_
6 #define PLATFORM_TEXT_BUFFER_H_ 6 #define PLATFORM_TEXT_BUFFER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 13
14 // TextBuffer maintains a dynamic character buffer with a printf-style way to 14 // TextBuffer maintains a dynamic character buffer with a printf-style way to
15 // append text. 15 // append text.
16 class TextBuffer : ValueObject { 16 class TextBuffer : ValueObject {
17 public: 17 public:
18 explicit TextBuffer(intptr_t buf_size); 18 explicit TextBuffer(intptr_t buf_size);
19 ~TextBuffer(); 19 ~TextBuffer();
20 20
21 intptr_t Printf(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); 21 intptr_t Printf(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
22 void AddChar(char ch); 22 void AddChar(char ch);
23 void EscapeAndAddUTF16CodeUnit(uint16_t cu);
23 void EscapeAndAddCodeUnit(uint32_t cu); 24 void EscapeAndAddCodeUnit(uint32_t cu);
24 void AddString(const char* s); 25 void AddString(const char* s);
25 void AddEscapedString(const char* s); 26 void AddEscapedString(const char* s);
26 void AddRaw(const uint8_t* buffer, 27 void AddRaw(const uint8_t* buffer,
27 intptr_t buffer_length); 28 intptr_t buffer_length);
28 29
29 void Clear(); 30 void Clear();
30 31
31 char* buf() { return buf_; } 32 char* buf() { return buf_; }
32 intptr_t length() { return msg_len_; } 33 intptr_t length() { return msg_len_; }
33 34
34 // Steal ownership of the buffer pointer. 35 // Steal ownership of the buffer pointer.
35 // NOTE: TextBuffer is empty afterwards. 36 // NOTE: TextBuffer is empty afterwards.
36 const char* Steal(); 37 const char* Steal();
37 38
38 private: 39 private:
39 void EnsureCapacity(intptr_t len); 40 void EnsureCapacity(intptr_t len);
40 char* buf_; 41 char* buf_;
41 intptr_t buf_size_; 42 intptr_t buf_size_;
42 intptr_t msg_len_; 43 intptr_t msg_len_;
43 }; 44 };
44 45
45 } // namespace dart 46 } // namespace dart
46 47
47 #endif // PLATFORM_TEXT_BUFFER_H_ 48 #endif // PLATFORM_TEXT_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/platform/text_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698