OLD | NEW |
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_JSON_H_ | 5 #ifndef PLATFORM_JSON_H_ |
6 #define PLATFORM_JSON_H_ | 6 #define PLATFORM_JSON_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 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 }; | 109 }; |
110 | 110 |
111 | 111 |
112 // TextBuffer maintains a dynamic character buffer with a printf-style way to | 112 // TextBuffer maintains a dynamic character buffer with a printf-style way to |
113 // append text. | 113 // append text. |
114 class TextBuffer : ValueObject { | 114 class TextBuffer : ValueObject { |
115 public: | 115 public: |
116 explicit TextBuffer(intptr_t buf_size); | 116 explicit TextBuffer(intptr_t buf_size); |
117 ~TextBuffer(); | 117 ~TextBuffer(); |
118 | 118 |
119 intptr_t Printf(const char* format, ...); | 119 intptr_t Printf(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
120 void AddChar(char ch); | 120 void AddChar(char ch); |
121 void AddUTF8(uint32_t ch); | 121 void AddUTF8(uint32_t ch); |
122 void AddEscapedChar(uint32_t ch); | 122 void AddEscapedChar(uint32_t ch); |
123 | 123 |
124 void Clear(); | 124 void Clear(); |
125 | 125 |
126 char* buf() { return buf_; } | 126 char* buf() { return buf_; } |
127 intptr_t length() { return msg_len_; } | 127 intptr_t length() { return msg_len_; } |
128 | 128 |
129 private: | 129 private: |
130 void EnsureCapacity(intptr_t len); | 130 void EnsureCapacity(intptr_t len); |
131 char* buf_; | 131 char* buf_; |
132 intptr_t buf_size_; | 132 intptr_t buf_size_; |
133 intptr_t msg_len_; | 133 intptr_t msg_len_; |
134 }; | 134 }; |
135 | 135 |
136 } // namespace dart | 136 } // namespace dart |
137 | 137 |
138 #endif // PLATFORM_JSON_H_ | 138 #endif // PLATFORM_JSON_H_ |
OLD | NEW |