Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: base/json/json_reader.cc

Issue 8962042: Add TYPE_INTEGER64 type to base::Value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/json/json_reader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 6
7 #include "base/basictypes.h"
7 #include "base/float_util.h" 8 #include "base/float_util.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
11 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
12 #include "base/string_util.h" 13 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 16
16 namespace { 17 namespace {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 c = token.NextChar(); 384 c = token.NextChar();
384 } 385 }
385 if (!ReadInt(token, true)) 386 if (!ReadInt(token, true))
386 return Token::CreateInvalidToken(); 387 return Token::CreateInvalidToken();
387 } 388 }
388 389
389 return token; 390 return token;
390 } 391 }
391 392
392 Value* JSONReader::DecodeNumber(const Token& token) { 393 Value* JSONReader::DecodeNumber(const Token& token) {
393 const std::wstring num_string(token.begin, token.length); 394 const std::wstring num_wstring(token.begin, token.length);
395 const std::string& num_string(WideToUTF8(num_wstring));
394 396
395 int num_int; 397 int num_int;
396 if (StringToInt(WideToUTF8(num_string), &num_int)) 398 if (StringToInt(num_string, &num_int))
397 return Value::CreateIntegerValue(num_int); 399 return Value::CreateIntegerValue(num_int);
398 400
401 int64 num_int64;
402 if (StringToInt64(num_string, &num_int64))
403 return Value::CreateInteger64Value(num_int64);
404
399 double num_double; 405 double num_double;
400 if (StringToDouble(WideToUTF8(num_string), &num_double) && 406 if (StringToDouble(num_string, &num_double) &&
401 base::IsFinite(num_double)) 407 base::IsFinite(num_double))
402 return Value::CreateDoubleValue(num_double); 408 return Value::CreateDoubleValue(num_double);
403 409
404 return NULL; 410 return NULL;
405 } 411 }
406 412
407 JSONReader::Token JSONReader::ParseStringToken() { 413 JSONReader::Token JSONReader::ParseStringToken() {
408 Token token(Token::STRING, json_pos_, 1); 414 Token token(Token::STRING, json_pos_, 1);
409 wchar_t c = token.NextChar(); 415 wchar_t c = token.NextChar();
410 while ('\0' != c) { 416 while ('\0' != c) {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 ++column_number; 663 ++column_number;
658 } 664 }
659 } 665 }
660 666
661 error_line_ = line_number; 667 error_line_ = line_number;
662 error_col_ = column_number; 668 error_col_ = column_number;
663 error_code_ = error; 669 error_code_ = error;
664 } 670 }
665 671
666 } // namespace base 672 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/json/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698