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

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

Issue 6997006: iwyu: Include stringprintf.h where appropriate, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_writer.h" 5 #include "base/json/json_writer.h"
6 6
7 #include "base/json/string_escape.h" 7 #include "base/json/string_escape.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/stringprintf.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 #if defined(OS_WIN) 16 #if defined(OS_WIN)
17 static const char kPrettyPrintLineEnding[] = "\r\n"; 17 static const char kPrettyPrintLineEnding[] = "\r\n";
18 #else 18 #else
19 static const char kPrettyPrintLineEnding[] = "\n"; 19 static const char kPrettyPrintLineEnding[] = "\n";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 DCHECK(result); 64 DCHECK(result);
65 json_string_->append(value ? "true" : "false"); 65 json_string_->append(value ? "true" : "false");
66 break; 66 break;
67 } 67 }
68 68
69 case Value::TYPE_INTEGER: 69 case Value::TYPE_INTEGER:
70 { 70 {
71 int value; 71 int value;
72 bool result = node->GetAsInteger(&value); 72 bool result = node->GetAsInteger(&value);
73 DCHECK(result); 73 DCHECK(result);
74 StringAppendF(json_string_, "%d", value); 74 base::StringAppendF(json_string_, "%d", value);
75 break; 75 break;
76 } 76 }
77 77
78 case Value::TYPE_DOUBLE: 78 case Value::TYPE_DOUBLE:
79 { 79 {
80 double value; 80 double value;
81 bool result = node->GetAsDouble(&value); 81 bool result = node->GetAsDouble(&value);
82 DCHECK(result); 82 DCHECK(result);
83 std::string real = DoubleToString(value); 83 std::string real = DoubleToString(value);
84 // Ensure that the number has a .0 if there's no decimal or 'e'. This 84 // Ensure that the number has a .0 if there's no decimal or 'e'. This
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_); 194 JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_);
195 } 195 }
196 196
197 void JSONWriter::IndentLine(int depth) { 197 void JSONWriter::IndentLine(int depth) {
198 // It may be faster to keep an indent string so we don't have to keep 198 // It may be faster to keep an indent string so we don't have to keep
199 // reallocating. 199 // reallocating.
200 json_string_->append(std::string(depth * 3, ' ')); 200 json_string_->append(std::string(depth * 3, ' '));
201 } 201 }
202 202
203 } // namespace base 203 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_reader.cc ('k') | base/json/string_escape.cc » ('j') | base/json/string_escape.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698