| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return false; | 128 return false; |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool JSONValue::asArray(RefPtr<JSONArray>*) | 131 bool JSONValue::asArray(RefPtr<JSONArray>*) |
| 132 { | 132 { |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 | 135 |
| 136 PassRefPtr<JSONObject> JSONValue::asObject() | 136 PassRefPtr<JSONObject> JSONValue::asObject() |
| 137 { | 137 { |
| 138 return 0; | 138 return nullptr; |
| 139 } | 139 } |
| 140 | 140 |
| 141 PassRefPtr<JSONArray> JSONValue::asArray() | 141 PassRefPtr<JSONArray> JSONValue::asArray() |
| 142 { | 142 { |
| 143 return 0; | 143 return nullptr; |
| 144 } | 144 } |
| 145 | 145 |
| 146 String JSONValue::toJSONString() const | 146 String JSONValue::toJSONString() const |
| 147 { | 147 { |
| 148 StringBuilder result; | 148 StringBuilder result; |
| 149 result.reserveCapacity(512); | 149 result.reserveCapacity(512); |
| 150 writeJSON(&result); | 150 writeJSON(&result); |
| 151 return result.toString(); | 151 return result.toString(); |
| 152 } | 152 } |
| 153 | 153 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 RefPtr<JSONValue> value = get(name); | 283 RefPtr<JSONValue> value = get(name); |
| 284 if (!value) | 284 if (!value) |
| 285 return false; | 285 return false; |
| 286 return value->asString(output); | 286 return value->asString(output); |
| 287 } | 287 } |
| 288 | 288 |
| 289 PassRefPtr<JSONObject> JSONObjectBase::getObject(const String& name) const | 289 PassRefPtr<JSONObject> JSONObjectBase::getObject(const String& name) const |
| 290 { | 290 { |
| 291 RefPtr<JSONValue> value = get(name); | 291 RefPtr<JSONValue> value = get(name); |
| 292 if (!value) | 292 if (!value) |
| 293 return 0; | 293 return nullptr; |
| 294 return value->asObject(); | 294 return value->asObject(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 PassRefPtr<JSONArray> JSONObjectBase::getArray(const String& name) const | 297 PassRefPtr<JSONArray> JSONObjectBase::getArray(const String& name) const |
| 298 { | 298 { |
| 299 RefPtr<JSONValue> value = get(name); | 299 RefPtr<JSONValue> value = get(name); |
| 300 if (!value) | 300 if (!value) |
| 301 return 0; | 301 return nullptr; |
| 302 return value->asArray(); | 302 return value->asArray(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 PassRefPtr<JSONValue> JSONObjectBase::get(const String& name) const | 305 PassRefPtr<JSONValue> JSONObjectBase::get(const String& name) const |
| 306 { | 306 { |
| 307 Dictionary::const_iterator it = m_data.find(name); | 307 Dictionary::const_iterator it = m_data.find(name); |
| 308 if (it == m_data.end()) | 308 if (it == m_data.end()) |
| 309 return 0; | 309 return nullptr; |
| 310 return it->value; | 310 return it->value; |
| 311 } | 311 } |
| 312 | 312 |
| 313 void JSONObjectBase::remove(const String& name) | 313 void JSONObjectBase::remove(const String& name) |
| 314 { | 314 { |
| 315 m_data.remove(name); | 315 m_data.remove(name); |
| 316 for (size_t i = 0; i < m_order.size(); ++i) { | 316 for (size_t i = 0; i < m_order.size(); ++i) { |
| 317 if (m_order[i] == name) { | 317 if (m_order[i] == name) { |
| 318 m_order.remove(i); | 318 m_order.remove(i); |
| 319 break; | 319 break; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 { | 377 { |
| 378 } | 378 } |
| 379 | 379 |
| 380 PassRefPtr<JSONValue> JSONArrayBase::get(size_t index) | 380 PassRefPtr<JSONValue> JSONArrayBase::get(size_t index) |
| 381 { | 381 { |
| 382 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); | 382 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); |
| 383 return m_data[index]; | 383 return m_data[index]; |
| 384 } | 384 } |
| 385 | 385 |
| 386 } // namespace WebCore | 386 } // namespace WebCore |
| OLD | NEW |