| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 431 |
| 432 PassRefPtr<JSONArray> JSONArrayBase::asArray() | 432 PassRefPtr<JSONArray> JSONArrayBase::asArray() |
| 433 { | 433 { |
| 434 static_assert(sizeof(JSONArrayBase) == sizeof(JSONArray), "cannot cast"); | 434 static_assert(sizeof(JSONArrayBase) == sizeof(JSONArray), "cannot cast"); |
| 435 return static_cast<JSONArray*>(this); | 435 return static_cast<JSONArray*>(this); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void JSONArrayBase::writeJSON(StringBuilder* output) const | 438 void JSONArrayBase::writeJSON(StringBuilder* output) const |
| 439 { | 439 { |
| 440 output->append('['); | 440 output->append('['); |
| 441 for (Vector<RefPtr<JSONValue> >::const_iterator it = m_data.begin(); it != m
_data.end(); ++it) { | 441 for (Vector<RefPtr<JSONValue>>::const_iterator it = m_data.begin(); it != m_
data.end(); ++it) { |
| 442 if (it != m_data.begin()) | 442 if (it != m_data.begin()) |
| 443 output->append(','); | 443 output->append(','); |
| 444 (*it)->writeJSON(output); | 444 (*it)->writeJSON(output); |
| 445 } | 445 } |
| 446 output->append(']'); | 446 output->append(']'); |
| 447 } | 447 } |
| 448 | 448 |
| 449 void JSONArrayBase::prettyWriteJSONInternal(StringBuilder* output, int depth) co
nst | 449 void JSONArrayBase::prettyWriteJSONInternal(StringBuilder* output, int depth) co
nst |
| 450 { | 450 { |
| 451 output->append('['); | 451 output->append('['); |
| 452 bool lastIsArrayOrObject = false; | 452 bool lastIsArrayOrObject = false; |
| 453 for (Vector<RefPtr<JSONValue> >::const_iterator it = m_data.begin(); it != m
_data.end(); ++it) { | 453 for (Vector<RefPtr<JSONValue>>::const_iterator it = m_data.begin(); it != m_
data.end(); ++it) { |
| 454 bool isArrayOrObject = (*it)->type() == JSONValue::TypeObject || (*it)->
type() == JSONValue::TypeArray; | 454 bool isArrayOrObject = (*it)->type() == JSONValue::TypeObject || (*it)->
type() == JSONValue::TypeArray; |
| 455 if (it == m_data.begin()) { | 455 if (it == m_data.begin()) { |
| 456 if (isArrayOrObject) { | 456 if (isArrayOrObject) { |
| 457 output->append('\n'); | 457 output->append('\n'); |
| 458 writeIndent(depth + 1, output); | 458 writeIndent(depth + 1, output); |
| 459 } | 459 } |
| 460 } else { | 460 } else { |
| 461 output->append(','); | 461 output->append(','); |
| 462 if (lastIsArrayOrObject) { | 462 if (lastIsArrayOrObject) { |
| 463 output->append('\n'); | 463 output->append('\n'); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 m_data.append(value); | 520 m_data.append(value); |
| 521 } | 521 } |
| 522 | 522 |
| 523 PassRefPtr<JSONValue> JSONArrayBase::get(size_t index) | 523 PassRefPtr<JSONValue> JSONArrayBase::get(size_t index) |
| 524 { | 524 { |
| 525 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); | 525 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); |
| 526 return m_data[index]; | 526 return m_data[index]; |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace blink | 529 } // namespace blink |
| OLD | NEW |