OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 provides a builders for DictionaryValue and ListValue. These | 5 // This file provides a builders for DictionaryValue and ListValue. These |
6 // aren't specific to extensions and could move up to base/ if there's interest | 6 // aren't specific to extensions and could move up to base/ if there's interest |
7 // from other sub-projects. | 7 // from other sub-projects. |
8 // | 8 // |
9 // The general pattern is to write: | 9 // The general pattern is to write: |
10 // | 10 // |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 explicit DictionaryBuilder(const base::DictionaryValue& init); | 49 explicit DictionaryBuilder(const base::DictionaryValue& init); |
50 ~DictionaryBuilder(); | 50 ~DictionaryBuilder(); |
51 | 51 |
52 // Workaround to allow you to pass rvalue ExtensionBuilders by reference to | 52 // Workaround to allow you to pass rvalue ExtensionBuilders by reference to |
53 // other functions. | 53 // other functions. |
54 DictionaryBuilder& Pass() { return *this; } | 54 DictionaryBuilder& Pass() { return *this; } |
55 | 55 |
56 // Can only be called once, after which it's invalid to use the builder. | 56 // Can only be called once, after which it's invalid to use the builder. |
57 scoped_ptr<base::DictionaryValue> Build() { return dict_.Pass(); } | 57 scoped_ptr<base::DictionaryValue> Build() { return dict_.Pass(); } |
58 | 58 |
59 // Get the number of elements stored in the dictionary | |
60 long size() const { return dict_->size(); } | |
not at google - send to devlin
2015/03/16 18:11:56
size_t
but this change might not be necessary
| |
61 | |
59 // Immediately serializes the current state to JSON. Can be called as many | 62 // Immediately serializes the current state to JSON. Can be called as many |
60 // times as you like. | 63 // times as you like. |
61 std::string ToJSON() const; | 64 std::string ToJSON() const; |
62 | 65 |
63 DictionaryBuilder& Set(const std::string& path, int in_value); | 66 DictionaryBuilder& Set(const std::string& path, int in_value); |
64 DictionaryBuilder& Set(const std::string& path, double in_value); | 67 DictionaryBuilder& Set(const std::string& path, double in_value); |
65 DictionaryBuilder& Set(const std::string& path, const std::string& in_value); | 68 DictionaryBuilder& Set(const std::string& path, const std::string& in_value); |
66 DictionaryBuilder& Set(const std::string& path, | 69 DictionaryBuilder& Set(const std::string& path, |
67 const base::string16& in_value); | 70 const base::string16& in_value); |
68 DictionaryBuilder& Set(const std::string& path, DictionaryBuilder& in_value); | 71 DictionaryBuilder& Set(const std::string& path, DictionaryBuilder& in_value); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 // convert implicitly to bool. | 103 // convert implicitly to bool. |
101 ListBuilder& AppendBoolean(bool in_value); | 104 ListBuilder& AppendBoolean(bool in_value); |
102 | 105 |
103 private: | 106 private: |
104 scoped_ptr<base::ListValue> list_; | 107 scoped_ptr<base::ListValue> list_; |
105 }; | 108 }; |
106 | 109 |
107 } // namespace extensions | 110 } // namespace extensions |
108 | 111 |
109 #endif // EXTENSIONS_COMMON_VALUE_BUILDER_H_ | 112 #endif // EXTENSIONS_COMMON_VALUE_BUILDER_H_ |
OLD | NEW |