diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-09-18 14:34:04 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-10-04 11:15:27 +0000 |
commit | e6430e577f105ad8813c92e75c54660c4985026e (patch) | |
tree | 88115e5d1fb471fea807111924dcccbeadbf9e4f /chromium/base/values.cc | |
parent | 53d399fe6415a96ea6986ec0d402a9c07da72453 (diff) |
BASELINE: Update Chromium to 61.0.3163.99
Change-Id: I8452f34574d88ca2b27af9bd56fc9ff3f16b1367
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/base/values.cc')
-rw-r--r-- | chromium/base/values.cc | 97 |
1 files changed, 93 insertions, 4 deletions
diff --git a/chromium/base/values.cc b/chromium/base/values.cc index 2f293c9e817..37a4e944363 100644 --- a/chromium/base/values.cc +++ b/chromium/base/values.cc @@ -244,6 +244,99 @@ const Value::ListStorage& Value::GetList() const { return *list_; } +Value::dict_iterator Value::FindKey(const char* key) { + return FindKey(std::string(key)); +} + +Value::dict_iterator Value::FindKey(const std::string& key) { + CHECK(is_dict()); + return dict_iterator(dict_->find(key)); +} + +Value::const_dict_iterator Value::FindKey(const char* key) const { + return FindKey(std::string(key)); +} + +Value::const_dict_iterator Value::FindKey(const std::string& key) const { + CHECK(is_dict()); + return const_dict_iterator(dict_->find(key)); +} + +Value::dict_iterator Value::FindKeyOfType(const char* key, Type type) { + return FindKeyOfType(std::string(key), type); +} + +Value::dict_iterator Value::FindKeyOfType(const std::string& key, Type type) { + CHECK(is_dict()); + auto iter = dict_->find(key); + return dict_iterator((iter != dict_->end() && iter->second->IsType(type)) + ? iter + : dict_->end()); +} + +Value::const_dict_iterator Value::FindKeyOfType(const char* key, + Type type) const { + return FindKeyOfType(std::string(key), type); +} + +Value::const_dict_iterator Value::FindKeyOfType(const std::string& key, + Type type) const { + CHECK(is_dict()); + auto iter = dict_->find(key); + return const_dict_iterator( + (iter != dict_->end() && iter->second->IsType(type)) ? iter + : dict_->end()); +} + +Value::dict_iterator Value::SetKey(const char* key, Value value) { + return SetKey(std::string(key), std::move(value)); +} + +Value::dict_iterator Value::SetKey(const std::string& key, Value value) { + CHECK(is_dict()); + auto iter = dict_->find(key); + if (iter != dict_->end()) { + *iter->second = std::move(value); + return dict_iterator(iter); + } + + return dict_iterator( + dict_->emplace(key, MakeUnique<Value>(std::move(value))).first); +} + +Value::dict_iterator Value::SetKey(std::string&& key, Value value) { + CHECK(is_dict()); + auto iter = dict_->find(key); + if (iter != dict_->end()) { + *iter->second = std::move(value); + return dict_iterator(iter); + } + + return dict_iterator( + dict_->emplace(std::move(key), MakeUnique<Value>(std::move(value))) + .first); +} + +Value::dict_iterator Value::DictEnd() { + CHECK(is_dict()); + return dict_iterator(dict_->end()); +} + +Value::const_dict_iterator Value::DictEnd() const { + CHECK(is_dict()); + return const_dict_iterator(dict_->end()); +} + +Value::dict_iterator_proxy Value::DictItems() { + CHECK(is_dict()); + return dict_iterator_proxy(&*dict_); +} + +Value::const_dict_iterator_proxy Value::DictItems() const { + CHECK(is_dict()); + return const_dict_iterator_proxy(&*dict_); +} + bool Value::GetAsBoolean(bool* out_value) const { if (out_value && is_bool()) { *out_value = bool_value_; @@ -636,10 +729,6 @@ Value* DictionaryValue::Set(StringPiece path, std::unique_ptr<Value> in_value) { std::move(in_value)); } -Value* DictionaryValue::Set(StringPiece path, Value* in_value) { - return Set(path, WrapUnique(in_value)); -} - Value* DictionaryValue::SetBoolean(StringPiece path, bool in_value) { return Set(path, MakeUnique<Value>(in_value)); } |