OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 static std::unique_ptr<JSONObject> create() { | 170 static std::unique_ptr<JSONObject> create() { |
171 return WTF::wrapUnique(new JSONObject()); | 171 return WTF::wrapUnique(new JSONObject()); |
172 } | 172 } |
173 | 173 |
174 static JSONObject* cast(JSONValue* value) { | 174 static JSONObject* cast(JSONValue* value) { |
175 if (!value || value->getType() != TypeObject) | 175 if (!value || value->getType() != TypeObject) |
176 return nullptr; | 176 return nullptr; |
177 return static_cast<JSONObject*>(value); | 177 return static_cast<JSONObject*>(value); |
178 } | 178 } |
179 | 179 |
| 180 static const JSONObject* cast(const JSONValue* value) { |
| 181 if (!value || value->getType() != TypeObject) |
| 182 return nullptr; |
| 183 return static_cast<const JSONObject*>(value); |
| 184 } |
| 185 |
180 static std::unique_ptr<JSONObject> from(std::unique_ptr<JSONValue> value) { | 186 static std::unique_ptr<JSONObject> from(std::unique_ptr<JSONValue> value) { |
181 auto maybeObject = WTF::wrapUnique(JSONObject::cast(value.get())); | 187 auto maybeObject = WTF::wrapUnique(JSONObject::cast(value.get())); |
182 if (maybeObject) | 188 if (maybeObject) |
183 value.release(); | 189 value.release(); |
184 return maybeObject; | 190 return maybeObject; |
185 } | 191 } |
186 | 192 |
187 static void cast(JSONObject*) = delete; | 193 static void cast(JSONObject*) = delete; |
188 static void cast(std::unique_ptr<JSONObject>) = delete; | 194 static void cast(std::unique_ptr<JSONObject>) = delete; |
189 | 195 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 JSONArray(); | 285 JSONArray(); |
280 Vector<std::unique_ptr<JSONValue>> m_data; | 286 Vector<std::unique_ptr<JSONValue>> m_data; |
281 }; | 287 }; |
282 | 288 |
283 PLATFORM_EXPORT void escapeStringForJSON(const String&, StringBuilder*); | 289 PLATFORM_EXPORT void escapeStringForJSON(const String&, StringBuilder*); |
284 void doubleQuoteStringForJSON(const String&, StringBuilder*); | 290 void doubleQuoteStringForJSON(const String&, StringBuilder*); |
285 | 291 |
286 } // namespace blink | 292 } // namespace blink |
287 | 293 |
288 #endif // JSONValues_h | 294 #endif // JSONValues_h |
OLD | NEW |