OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 VM_JSON_STREAM_H_ | 5 #ifndef VM_JSON_STREAM_H_ |
6 #define VM_JSON_STREAM_H_ | 6 #define VM_JSON_STREAM_H_ |
7 | 7 |
8 #include "platform/json.h" | 8 #include "platform/json.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
| 12 class Object; |
12 | 13 |
13 class JSONStream : ValueObject { | 14 class JSONStream : ValueObject { |
14 public: | 15 public: |
15 explicit JSONStream(TextBuffer* buffer); | 16 explicit JSONStream(TextBuffer* buffer); |
16 ~JSONStream(); | 17 ~JSONStream(); |
17 | 18 |
18 void Clear(); | 19 void Clear(); |
19 | 20 |
20 void OpenObject(const char* property_name = NULL); | 21 void OpenObject(const char* property_name = NULL); |
21 void CloseObject(); | 22 void CloseObject(); |
22 | 23 |
23 void OpenArray(const char* property_name = NULL); | 24 void OpenArray(const char* property_name = NULL); |
24 void CloseArray(); | 25 void CloseArray(); |
25 | 26 |
26 void PrintValueBool(bool b); | 27 void PrintValueBool(bool b); |
27 void PrintValue(intptr_t i); | 28 void PrintValue(intptr_t i); |
28 void PrintValue(double d); | 29 void PrintValue(double d); |
29 void PrintValue(const char* s); | 30 void PrintValue(const char* s); |
| 31 void PrintValue(const Object& o, bool ref = true); |
30 | 32 |
31 void PrintPropertyBool(const char* name, bool b); | 33 void PrintPropertyBool(const char* name, bool b); |
32 void PrintProperty(const char* name, intptr_t i); | 34 void PrintProperty(const char* name, intptr_t i); |
33 void PrintProperty(const char* name, double d); | 35 void PrintProperty(const char* name, double d); |
34 void PrintProperty(const char* name, const char* s); | 36 void PrintProperty(const char* name, const char* s); |
| 37 void PrintProperty(const char* name, const Object& o, bool ref = true); |
35 | 38 |
36 private: | 39 private: |
37 void PrintPropertyName(const char* name); | 40 void PrintPropertyName(const char* name); |
38 void PrintCommaIfNeeded(); | 41 void PrintCommaIfNeeded(); |
39 bool NeedComma(); | 42 bool NeedComma(); |
40 intptr_t open_objects_; | 43 intptr_t open_objects_; |
41 TextBuffer* buffer_; | 44 TextBuffer* buffer_; |
42 }; | 45 }; |
43 | 46 |
44 } // namespace dart | 47 } // namespace dart |
45 | 48 |
46 #endif // VM_JSON_STREAM_H_ | 49 #endif // VM_JSON_STREAM_H_ |
OLD | NEW |