OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // A JSON parser. Converts strings of JSON into a Value object (see | 5 // A JSON parser. Converts strings of JSON into a Value object (see |
6 // base/values.h). | 6 // base/values.h). |
7 // http://www.ietf.org/rfc/rfc4627.txt?number=4627 | 7 // http://www.ietf.org/rfc/rfc4627.txt?number=4627 |
8 // | 8 // |
9 // Known limitations/deviations from the RFC: | 9 // Known limitations/deviations from the RFC: |
10 // - Only knows how to parse ints within the range of a signed 32 bit int and | 10 // - Only knows how to parse ints within the range of a signed 32 bit int and |
(...skipping 16 matching lines...) Expand all Loading... |
27 // TODO(aa): Consider making the constructor public and the static Read() method | 27 // TODO(aa): Consider making the constructor public and the static Read() method |
28 // only a convenience for the common uses with more complex configuration going | 28 // only a convenience for the common uses with more complex configuration going |
29 // on the instance. | 29 // on the instance. |
30 | 30 |
31 #ifndef BASE_JSON_JSON_READER_H_ | 31 #ifndef BASE_JSON_JSON_READER_H_ |
32 #define BASE_JSON_JSON_READER_H_ | 32 #define BASE_JSON_JSON_READER_H_ |
33 #pragma once | 33 #pragma once |
34 | 34 |
35 #include <string> | 35 #include <string> |
36 | 36 |
| 37 #include "base/base_api.h" |
37 #include "base/basictypes.h" | 38 #include "base/basictypes.h" |
38 | 39 |
39 // Chromium and Chromium OS check out gtest to different places, so we're | 40 // Chromium and Chromium OS check out gtest to different places, so we're |
40 // unable to compile on both if we include gtest_prod.h here. Instead, include | 41 // unable to compile on both if we include gtest_prod.h here. Instead, include |
41 // its only contents -- this will need to be updated if the macro ever changes. | 42 // its only contents -- this will need to be updated if the macro ever changes. |
42 #define FRIEND_TEST(test_case_name, test_name)\ | 43 #define FRIEND_TEST(test_case_name, test_name)\ |
43 friend class test_case_name##_##test_name##_Test | 44 friend class test_case_name##_##test_name##_Test |
44 | 45 |
45 class Value; | 46 class Value; |
46 | 47 |
47 namespace base { | 48 namespace base { |
48 | 49 |
49 class JSONReader { | 50 class BASE_API JSONReader { |
50 public: | 51 public: |
51 // A struct to hold a JS token. | 52 // A struct to hold a JS token. |
52 class Token { | 53 class Token { |
53 public: | 54 public: |
54 enum Type { | 55 enum Type { |
55 OBJECT_BEGIN, // { | 56 OBJECT_BEGIN, // { |
56 OBJECT_END, // } | 57 OBJECT_END, // } |
57 ARRAY_BEGIN, // [ | 58 ARRAY_BEGIN, // [ |
58 ARRAY_END, // ] | 59 ARRAY_END, // ] |
59 STRING, | 60 STRING, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 JsonParseError error_code_; | 212 JsonParseError error_code_; |
212 int error_line_; | 213 int error_line_; |
213 int error_col_; | 214 int error_col_; |
214 | 215 |
215 DISALLOW_COPY_AND_ASSIGN(JSONReader); | 216 DISALLOW_COPY_AND_ASSIGN(JSONReader); |
216 }; | 217 }; |
217 | 218 |
218 } // namespace base | 219 } // namespace base |
219 | 220 |
220 #endif // BASE_JSON_JSON_READER_H_ | 221 #endif // BASE_JSON_JSON_READER_H_ |
OLD | NEW |