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

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

Issue 18648003: Let JsonDoubleQuote accept StringPiece (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
« no previous file with comments | « base/json/string_escape.h ('k') | base/json/string_escape_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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/string_escape.h" 5 #include "base/json/string_escape.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 } 72 }
73 } 73 }
74 74
75 if (put_in_quotes) 75 if (put_in_quotes)
76 dst->push_back('"'); 76 dst->push_back('"');
77 } 77 }
78 78
79 } // namespace 79 } // namespace
80 80
81 void JsonDoubleQuote(const std::string& str, 81 void JsonDoubleQuote(const StringPiece& str,
82 bool put_in_quotes, 82 bool put_in_quotes,
83 std::string* dst) { 83 std::string* dst) {
84 JsonDoubleQuoteT(str, put_in_quotes, dst); 84 JsonDoubleQuoteT(str, put_in_quotes, dst);
85 } 85 }
86 86
87 std::string GetDoubleQuotedJson(const std::string& str) { 87 std::string GetDoubleQuotedJson(const StringPiece& str) {
88 std::string dst; 88 std::string dst;
89 JsonDoubleQuote(str, true, &dst); 89 JsonDoubleQuote(str, true, &dst);
90 return dst; 90 return dst;
91 } 91 }
92 92
93 void JsonDoubleQuote(const string16& str, 93 void JsonDoubleQuote(const StringPiece16& str,
94 bool put_in_quotes, 94 bool put_in_quotes,
95 std::string* dst) { 95 std::string* dst) {
96 JsonDoubleQuoteT(str, put_in_quotes, dst); 96 JsonDoubleQuoteT(str, put_in_quotes, dst);
97 } 97 }
98 98
99 std::string GetDoubleQuotedJson(const string16& str) { 99 std::string GetDoubleQuotedJson(const StringPiece16& str) {
100 std::string dst; 100 std::string dst;
101 JsonDoubleQuote(str, true, &dst); 101 JsonDoubleQuote(str, true, &dst);
102 return dst; 102 return dst;
103 } 103 }
104 104
105 } // namespace base 105 } // namespace base
OLDNEW
« no previous file with comments | « base/json/string_escape.h ('k') | base/json/string_escape_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698