OLD | NEW |
---|---|
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/values.h" | 5 #include "base/values.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 private: | 78 private: |
79 const Value* first_; | 79 const Value* first_; |
80 }; | 80 }; |
81 | 81 |
82 } // namespace | 82 } // namespace |
83 | 83 |
84 Value::~Value() { | 84 Value::~Value() { |
85 } | 85 } |
86 | 86 |
87 // static | 87 // static |
88 Value* Value::CreateNullValue() { | 88 scoped_ptr<Value> Value::CreateNullValue() { |
89 return new Value(TYPE_NULL); | 89 return make_scoped_ptr(new Value(TYPE_NULL)); |
90 } | 90 } |
91 | 91 |
92 bool Value::GetAsBinary(const BinaryValue** out_value) const { | 92 bool Value::GetAsBinary(const BinaryValue** out_value) const { |
93 return false; | 93 return false; |
94 } | 94 } |
95 | 95 |
96 bool Value::GetAsBoolean(bool* out_value) const { | 96 bool Value::GetAsBoolean(bool* out_value) const { |
97 return false; | 97 return false; |
98 } | 98 } |
99 | 99 |
(...skipping 26 matching lines...) Expand all Loading... | |
126 } | 126 } |
127 | 127 |
128 bool Value::GetAsDictionary(DictionaryValue** out_value) { | 128 bool Value::GetAsDictionary(DictionaryValue** out_value) { |
129 return false; | 129 return false; |
130 } | 130 } |
131 | 131 |
132 bool Value::GetAsDictionary(const DictionaryValue** out_value) const { | 132 bool Value::GetAsDictionary(const DictionaryValue** out_value) const { |
133 return false; | 133 return false; |
134 } | 134 } |
135 | 135 |
136 Value* Value::DeepCopy() const { | 136 Value* Value::DeepCopy() const { |
danakj
2015/05/08 18:07:26
TODO to return scoped_ptr?
Evan Stade
2015/05/08 18:32:09
See CreateDeepCopy below. There's a TODO in the he
| |
137 // This method should only be getting called for null Values--all subclasses | 137 // This method should only be getting called for null Values--all subclasses |
138 // need to provide their own implementation;. | 138 // need to provide their own implementation;. |
139 DCHECK(IsType(TYPE_NULL)); | 139 DCHECK(IsType(TYPE_NULL)); |
140 return CreateNullValue(); | 140 return CreateNullValue().release(); |
141 } | 141 } |
142 | 142 |
143 scoped_ptr<Value> Value::CreateDeepCopy() const { | 143 scoped_ptr<Value> Value::CreateDeepCopy() const { |
144 return make_scoped_ptr(DeepCopy()); | 144 return make_scoped_ptr(DeepCopy()); |
145 } | 145 } |
146 | 146 |
147 bool Value::Equals(const Value* other) const { | 147 bool Value::Equals(const Value* other) const { |
148 // This method should only be getting called for null Values--all subclasses | 148 // This method should only be getting called for null Values--all subclasses |
149 // need to provide their own implementation;. | 149 // need to provide their own implementation;. |
150 DCHECK(IsType(TYPE_NULL)); | 150 DCHECK(IsType(TYPE_NULL)); |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1164 | 1164 |
1165 std::ostream& operator<<(std::ostream& out, const Value& value) { | 1165 std::ostream& operator<<(std::ostream& out, const Value& value) { |
1166 std::string json; | 1166 std::string json; |
1167 JSONWriter::WriteWithOptions(&value, | 1167 JSONWriter::WriteWithOptions(&value, |
1168 JSONWriter::OPTIONS_PRETTY_PRINT, | 1168 JSONWriter::OPTIONS_PRETTY_PRINT, |
1169 &json); | 1169 &json); |
1170 return out << json; | 1170 return out << json; |
1171 } | 1171 } |
1172 | 1172 |
1173 } // namespace base | 1173 } // namespace base |
OLD | NEW |