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

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

Issue 2577563002: Add struct traits for base::Value. (Closed)
Patch Set: rebase Created 4 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
« no previous file with comments | « no previous file | base/values.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_parser.h" 5 #include "base/json/json_parser.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 // Overridden from Value: 145 // Overridden from Value:
146 bool GetAsString(std::string* out_value) const override { 146 bool GetAsString(std::string* out_value) const override {
147 string_piece_.CopyToString(out_value); 147 string_piece_.CopyToString(out_value);
148 return true; 148 return true;
149 } 149 }
150 bool GetAsString(string16* out_value) const override { 150 bool GetAsString(string16* out_value) const override {
151 *out_value = UTF8ToUTF16(string_piece_); 151 *out_value = UTF8ToUTF16(string_piece_);
152 return true; 152 return true;
153 } 153 }
154 bool GetAsString(StringPiece* out_value) const override {
155 *out_value = string_piece_;
156 return true;
157 }
154 Value* DeepCopy() const override { return new StringValue(string_piece_); } 158 Value* DeepCopy() const override { return new StringValue(string_piece_); }
155 bool Equals(const Value* other) const override { 159 bool Equals(const Value* other) const override {
156 std::string other_string; 160 std::string other_string;
157 return other->IsType(Type::STRING) && other->GetAsString(&other_string) && 161 return other->IsType(Type::STRING) && other->GetAsString(&other_string) &&
158 StringPiece(other_string) == string_piece_; 162 StringPiece(other_string) == string_piece_;
159 } 163 }
160 164
161 private: 165 private:
162 // The location in the original input stream. 166 // The location in the original input stream.
163 StringPiece string_piece_; 167 StringPiece string_piece_;
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 const std::string& description) { 993 const std::string& description) {
990 if (line || column) { 994 if (line || column) {
991 return StringPrintf("Line: %i, column: %i, %s", 995 return StringPrintf("Line: %i, column: %i, %s",
992 line, column, description.c_str()); 996 line, column, description.c_str());
993 } 997 }
994 return description; 998 return description;
995 } 999 }
996 1000
997 } // namespace internal 1001 } // namespace internal
998 } // namespace base 1002 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/values.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698