Chromium Code Reviews| 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 // This file specifies a recursive data storage class called Value intended for | 5 // This file specifies a recursive data storage class called Value intended for |
| 6 // storing setting and other persistable data. It includes the ability to | 6 // storing setting and other persistable data. It includes the ability to |
| 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. | 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. |
| 8 // However, the API is optimized for the common case, namely storing a | 8 // However, the API is optimized for the common case, namely storing a |
| 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can | 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can |
| 10 // easily do things like: | 10 // easily do things like: |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 #include <iterator> | 24 #include <iterator> |
| 25 #include <map> | 25 #include <map> |
| 26 #include <string> | 26 #include <string> |
| 27 #include <vector> | 27 #include <vector> |
| 28 | 28 |
| 29 #include "base/base_export.h" | 29 #include "base/base_export.h" |
| 30 #include "base/basictypes.h" | 30 #include "base/basictypes.h" |
| 31 #include "base/compiler_specific.h" | 31 #include "base/compiler_specific.h" |
| 32 #include "base/string16.h" | 32 #include "base/string16.h" |
| 33 #include "base/string_piece.h" | |
|
brettw
2012/07/13 16:46:46
I don't actually know the answer but I wonder if w
Jeffrey Yasskin
2012/07/15 04:07:24
I tend to think that StringPiece should be used ev
| |
| 33 | 34 |
| 34 // This file declares "using base::Value", etc. at the bottom, so that | 35 // This file declares "using base::Value", etc. at the bottom, so that |
| 35 // current code can use these classes without the base namespace. In | 36 // current code can use these classes without the base namespace. In |
| 36 // new code, please always use base::Value, etc. or add your own | 37 // new code, please always use base::Value, etc. or add your own |
| 37 // "using" declaration. | 38 // "using" declaration. |
| 38 // http://crbug.com/88666 | 39 // http://crbug.com/88666 |
| 39 namespace base { | 40 namespace base { |
| 40 | 41 |
| 41 class BinaryValue; | 42 class BinaryValue; |
| 42 class DictionaryValue; | 43 class DictionaryValue; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 // Creates a Value to represent a binary buffer. The new object takes | 182 // Creates a Value to represent a binary buffer. The new object takes |
| 182 // ownership of the pointer passed in, if successful. | 183 // ownership of the pointer passed in, if successful. |
| 183 // Returns NULL if buffer is NULL. | 184 // Returns NULL if buffer is NULL. |
| 184 static BinaryValue* Create(char* buffer, size_t size); | 185 static BinaryValue* Create(char* buffer, size_t size); |
| 185 | 186 |
| 186 // For situations where you want to keep ownership of your buffer, this | 187 // For situations where you want to keep ownership of your buffer, this |
| 187 // factory method creates a new BinaryValue by copying the contents of the | 188 // factory method creates a new BinaryValue by copying the contents of the |
| 188 // buffer that's passed in. | 189 // buffer that's passed in. |
| 189 // Returns NULL if buffer is NULL. | 190 // Returns NULL if buffer is NULL. |
| 190 static BinaryValue* CreateWithCopiedBuffer(const char* buffer, size_t size); | 191 static BinaryValue* CreateWithCopiedBuffer(const char* buffer, size_t size); |
| 192 static BinaryValue* CreateWithCopiedBuffer(StringPiece buffer) { | |
| 193 return CreateWithCopiedBuffer(buffer.data(), buffer.size()); | |
| 194 } | |
| 191 | 195 |
| 192 size_t GetSize() const { return size_; } | 196 size_t GetSize() const { return size_; } |
| 193 char* GetBuffer() { return buffer_; } | 197 char* GetBuffer() { return buffer_; } |
| 194 const char* GetBuffer() const { return buffer_; } | 198 const char* GetBuffer() const { return buffer_; } |
| 195 | 199 |
| 196 // Overridden from Value: | 200 // Overridden from Value: |
| 197 virtual BinaryValue* DeepCopy() const OVERRIDE; | 201 virtual BinaryValue* DeepCopy() const OVERRIDE; |
| 198 virtual bool Equals(const Value* other) const OVERRIDE; | 202 virtual bool Equals(const Value* other) const OVERRIDE; |
| 199 | 203 |
| 200 private: | 204 private: |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 | 496 |
| 493 } // namespace base | 497 } // namespace base |
| 494 | 498 |
| 495 // http://crbug.com/88666 | 499 // http://crbug.com/88666 |
| 496 using base::DictionaryValue; | 500 using base::DictionaryValue; |
| 497 using base::ListValue; | 501 using base::ListValue; |
| 498 using base::StringValue; | 502 using base::StringValue; |
| 499 using base::Value; | 503 using base::Value; |
| 500 | 504 |
| 501 #endif // BASE_VALUES_H_ | 505 #endif // BASE_VALUES_H_ |
| OLD | NEW |