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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 bool IsTrue() const { | 95 bool IsTrue() const { |
96 return scanner_.CurrentToken() == JSONScanner::TokenTrue; | 96 return scanner_.CurrentToken() == JSONScanner::TokenTrue; |
97 } | 97 } |
98 bool IsFalse() const { | 98 bool IsFalse() const { |
99 return scanner_.CurrentToken() == JSONScanner::TokenFalse; | 99 return scanner_.CurrentToken() == JSONScanner::TokenFalse; |
100 } | 100 } |
101 bool IsNull() const { | 101 bool IsNull() const { |
102 return scanner_.CurrentToken() == JSONScanner::TokenNull; | 102 return scanner_.CurrentToken() == JSONScanner::TokenNull; |
103 } | 103 } |
104 | 104 |
| 105 // Debugging method to check for validity of a JSON message. |
| 106 bool CheckMessage(); |
| 107 |
105 private: | 108 private: |
| 109 void CheckObject(); |
| 110 void CheckArray(); |
| 111 void CheckValue(); |
| 112 |
106 JSONScanner scanner_; | 113 JSONScanner scanner_; |
107 const char* json_object_; | 114 const char* json_object_; |
108 bool error_; | 115 bool error_; |
109 }; | 116 }; |
110 | 117 |
111 | 118 |
112 // TextBuffer maintains a dynamic character buffer with a printf-style way to | 119 // TextBuffer maintains a dynamic character buffer with a printf-style way to |
113 // append text. | 120 // append text. |
114 class TextBuffer : ValueObject { | 121 class TextBuffer : ValueObject { |
115 public: | 122 public: |
(...skipping 13 matching lines...) Expand all Loading... |
129 private: | 136 private: |
130 void EnsureCapacity(intptr_t len); | 137 void EnsureCapacity(intptr_t len); |
131 char* buf_; | 138 char* buf_; |
132 intptr_t buf_size_; | 139 intptr_t buf_size_; |
133 intptr_t msg_len_; | 140 intptr_t msg_len_; |
134 }; | 141 }; |
135 | 142 |
136 } // namespace dart | 143 } // namespace dart |
137 | 144 |
138 #endif // PLATFORM_JSON_H_ | 145 #endif // PLATFORM_JSON_H_ |
OLD | NEW |