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

Side by Side Diff: extensions/common/value_builder.h

Issue 107803004: Add base:: to string16 in extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove a using Created 7 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 | Annotate | Revision Log
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 DictionaryBuilder& Set(const std::string& path, int in_value); 59 DictionaryBuilder& Set(const std::string& path, int in_value);
60 DictionaryBuilder& Set(const std::string& path, double in_value); 60 DictionaryBuilder& Set(const std::string& path, double in_value);
61 DictionaryBuilder& Set(const std::string& path, const std::string& in_value); 61 DictionaryBuilder& Set(const std::string& path, const std::string& in_value);
62 DictionaryBuilder& Set(const std::string& path, const string16& in_value); 62 DictionaryBuilder& Set(const std::string& path,
63 const base::string16& in_value);
63 DictionaryBuilder& Set(const std::string& path, DictionaryBuilder& in_value); 64 DictionaryBuilder& Set(const std::string& path, DictionaryBuilder& in_value);
64 DictionaryBuilder& Set(const std::string& path, ListBuilder& in_value); 65 DictionaryBuilder& Set(const std::string& path, ListBuilder& in_value);
65 66
66 // Named differently because overload resolution is too eager to 67 // Named differently because overload resolution is too eager to
67 // convert implicitly to bool. 68 // convert implicitly to bool.
68 DictionaryBuilder& SetBoolean(const std::string& path, bool in_value); 69 DictionaryBuilder& SetBoolean(const std::string& path, bool in_value);
69 70
70 private: 71 private:
71 scoped_ptr<base::DictionaryValue> dict_; 72 scoped_ptr<base::DictionaryValue> dict_;
72 }; 73 };
73 74
74 class ListBuilder { 75 class ListBuilder {
75 public: 76 public:
76 ListBuilder(); 77 ListBuilder();
77 explicit ListBuilder(const base::ListValue& init); 78 explicit ListBuilder(const base::ListValue& init);
78 ~ListBuilder(); 79 ~ListBuilder();
79 80
80 // Workaround to allow you to pass rvalue ExtensionBuilders by reference to 81 // Workaround to allow you to pass rvalue ExtensionBuilders by reference to
81 // other functions. 82 // other functions.
82 ListBuilder& Pass() { return *this; } 83 ListBuilder& Pass() { return *this; }
83 84
84 // Can only be called once, after which it's invalid to use the builder. 85 // Can only be called once, after which it's invalid to use the builder.
85 scoped_ptr<base::ListValue> Build() { return list_.Pass(); } 86 scoped_ptr<base::ListValue> Build() { return list_.Pass(); }
86 87
87 ListBuilder& Append(int in_value); 88 ListBuilder& Append(int in_value);
88 ListBuilder& Append(double in_value); 89 ListBuilder& Append(double in_value);
89 ListBuilder& Append(const std::string& in_value); 90 ListBuilder& Append(const std::string& in_value);
90 ListBuilder& Append(const string16& in_value); 91 ListBuilder& Append(const base::string16& in_value);
91 ListBuilder& Append(DictionaryBuilder& in_value); 92 ListBuilder& Append(DictionaryBuilder& in_value);
92 ListBuilder& Append(ListBuilder& in_value); 93 ListBuilder& Append(ListBuilder& in_value);
93 94
94 // Named differently because overload resolution is too eager to 95 // Named differently because overload resolution is too eager to
95 // convert implicitly to bool. 96 // convert implicitly to bool.
96 ListBuilder& AppendBoolean(bool in_value); 97 ListBuilder& AppendBoolean(bool in_value);
97 98
98 private: 99 private:
99 scoped_ptr<base::ListValue> list_; 100 scoped_ptr<base::ListValue> list_;
100 }; 101 };
101 102
102 } // namespace extensions 103 } // namespace extensions
103 104
104 #endif // EXTENSIONS_COMMON_VALUE_BUILDER_H_ 105 #endif // EXTENSIONS_COMMON_VALUE_BUILDER_H_
OLDNEW
« no previous file with comments | « extensions/common/permissions/permissions_data_unittest.cc ('k') | extensions/common/value_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698