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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 std::unique_ptr<JSONValue> JSONArray::clone() const { | 446 std::unique_ptr<JSONValue> JSONArray::clone() const { |
447 std::unique_ptr<JSONArray> result = JSONArray::create(); | 447 std::unique_ptr<JSONArray> result = JSONArray::create(); |
448 for (const std::unique_ptr<JSONValue>& value : m_data) | 448 for (const std::unique_ptr<JSONValue>& value : m_data) |
449 result->pushValue(value->clone()); | 449 result->pushValue(value->clone()); |
450 return std::move(result); | 450 return std::move(result); |
451 } | 451 } |
452 | 452 |
453 JSONArray::JSONArray() : JSONValue(TypeArray) {} | 453 JSONArray::JSONArray() : JSONValue(TypeArray) {} |
454 | 454 |
455 void JSONArray::pushBoolean(bool value) { | 455 void JSONArray::pushBoolean(bool value) { |
456 m_data.append(JSONBasicValue::create(value)); | 456 m_data.push_back(JSONBasicValue::create(value)); |
457 } | 457 } |
458 | 458 |
459 void JSONArray::pushInteger(int value) { | 459 void JSONArray::pushInteger(int value) { |
460 m_data.append(JSONBasicValue::create(value)); | 460 m_data.push_back(JSONBasicValue::create(value)); |
461 } | 461 } |
462 | 462 |
463 void JSONArray::pushDouble(double value) { | 463 void JSONArray::pushDouble(double value) { |
464 m_data.append(JSONBasicValue::create(value)); | 464 m_data.push_back(JSONBasicValue::create(value)); |
465 } | 465 } |
466 | 466 |
467 void JSONArray::pushString(const String& value) { | 467 void JSONArray::pushString(const String& value) { |
468 m_data.append(JSONString::create(value)); | 468 m_data.push_back(JSONString::create(value)); |
469 } | 469 } |
470 | 470 |
471 void JSONArray::pushValue(std::unique_ptr<JSONValue> value) { | 471 void JSONArray::pushValue(std::unique_ptr<JSONValue> value) { |
472 DCHECK(value); | 472 DCHECK(value); |
473 m_data.append(std::move(value)); | 473 m_data.push_back(std::move(value)); |
474 } | 474 } |
475 | 475 |
476 void JSONArray::pushObject(std::unique_ptr<JSONObject> value) { | 476 void JSONArray::pushObject(std::unique_ptr<JSONObject> value) { |
477 DCHECK(value); | 477 DCHECK(value); |
478 m_data.append(std::move(value)); | 478 m_data.push_back(std::move(value)); |
479 } | 479 } |
480 | 480 |
481 void JSONArray::pushArray(std::unique_ptr<JSONArray> value) { | 481 void JSONArray::pushArray(std::unique_ptr<JSONArray> value) { |
482 DCHECK(value); | 482 DCHECK(value); |
483 m_data.append(std::move(value)); | 483 m_data.push_back(std::move(value)); |
484 } | 484 } |
485 | 485 |
486 JSONValue* JSONArray::at(size_t index) { | 486 JSONValue* JSONArray::at(size_t index) { |
487 DCHECK_LT(index, m_data.size()); | 487 DCHECK_LT(index, m_data.size()); |
488 return m_data[index].get(); | 488 return m_data[index].get(); |
489 } | 489 } |
490 | 490 |
491 } // namespace blink | 491 } // namespace blink |
OLD | NEW |