• Home
  • Raw
  • Download

Lines Matching +full:path +full:- +full:key

2 // Use of this source code is governed by a BSD-style license that can be
37 // expects |node| to always be non-NULL.
57 copy->SetWithoutPathExpansion(it.key(), std::move(child_copy)); in CopyDictionaryWithoutEmptyChildren()
157 std::make_unique<Value>(it.second->Clone())); in Value()
243 Value* Value::FindKey(std::string_view key) { in FindKey() argument
244 return const_cast<Value*>(static_cast<const Value*>(this)->FindKey(key)); in FindKey()
247 const Value* Value::FindKey(std::string_view key) const { in FindKey()
249 auto found = dict_.find(key); in FindKey()
252 return found->second.get(); in FindKey()
255 Value* Value::FindKeyOfType(std::string_view key, Type type) { in FindKeyOfType() argument
257 static_cast<const Value*>(this)->FindKeyOfType(key, type)); in FindKeyOfType()
260 const Value* Value::FindKeyOfType(std::string_view key, Type type) const { in FindKeyOfType() argument
261 const Value* result = FindKey(key); in FindKeyOfType()
262 if (!result || result->type() != type) in FindKeyOfType()
267 bool Value::RemoveKey(std::string_view key) { in RemoveKey() argument
269 // NOTE: Can't directly return dict_->erase(key) due to MSVC warning C4800. in RemoveKey()
270 return dict_.erase(key) != 0; in RemoveKey()
273 Value* Value::SetKey(std::string_view key, Value value) { in SetKey() argument
278 auto result = dict_.try_emplace(key, std::move(val_ptr)); in SetKey()
281 result.first->second = std::move(val_ptr); in SetKey()
283 return result.first->second.get(); in SetKey()
286 Value* Value::SetKey(std::string&& key, Value value) { in SetKey() argument
289 .insert_or_assign(std::move(key), in SetKey()
291 .first->second.get(); in SetKey()
294 Value* Value::SetKey(const char* key, Value value) { in SetKey() argument
295 return SetKey(std::string_view(key), std::move(value)); in SetKey()
298 Value* Value::FindPath(std::initializer_list<std::string_view> path) { in FindPath() argument
299 return const_cast<Value*>(const_cast<const Value*>(this)->FindPath(path)); in FindPath()
302 Value* Value::FindPath(span<const std::string_view> path) { in FindPath() argument
303 return const_cast<Value*>(const_cast<const Value*>(this)->FindPath(path)); in FindPath()
307 std::initializer_list<std::string_view> path) const { in FindPath()
308 DCHECK_GE(path.size(), 2u) << "Use FindKey() for a path of length 1."; in FindPath()
309 return FindPath(make_span(path.begin(), path.size())); in FindPath()
312 const Value* Value::FindPath(span<const std::string_view> path) const { in FindPath()
314 for (const std::string_view& component : path) { in FindPath()
315 if (!cur->is_dict() || (cur = cur->FindKey(component)) == nullptr) in FindPath()
321 Value* Value::FindPathOfType(std::initializer_list<std::string_view> path, in FindPathOfType() argument
324 const_cast<const Value*>(this)->FindPathOfType(path, type)); in FindPathOfType()
327 Value* Value::FindPathOfType(span<const std::string_view> path, Type type) { in FindPathOfType() argument
329 const_cast<const Value*>(this)->FindPathOfType(path, type)); in FindPathOfType()
332 const Value* Value::FindPathOfType(std::initializer_list<std::string_view> path, in FindPathOfType() argument
334 DCHECK_GE(path.size(), 2u) << "Use FindKeyOfType() for a path of length 1."; in FindPathOfType()
335 return FindPathOfType(make_span(path.begin(), path.size()), type); in FindPathOfType()
338 const Value* Value::FindPathOfType(span<const std::string_view> path, in FindPathOfType() argument
340 const Value* result = FindPath(path); in FindPathOfType()
341 if (!result || result->type() != type) in FindPathOfType()
346 Value* Value::SetPath(std::initializer_list<std::string_view> path, in SetPath() argument
348 DCHECK_GE(path.size(), 2u) << "Use SetKey() for a path of length 1."; in SetPath()
349 return SetPath(make_span(path.begin(), path.size()), std::move(value)); in SetPath()
352 Value* Value::SetPath(span<const std::string_view> path, Value value) { in SetPath() argument
353 DCHECK_NE(path.begin(), path.end()); // Can't be empty path. in SetPath()
358 const std::string_view* cur_path = path.begin(); in SetPath()
359 for (; (cur_path + 1) < path.end(); ++cur_path) { in SetPath()
360 if (!cur->is_dict()) in SetPath()
365 auto found = cur->dict_.lower_bound(path_component); in SetPath()
366 if (found == cur->dict_.end() || found->first != path_component) { in SetPath()
367 // No key found, insert one. in SetPath()
368 auto inserted = cur->dict_.try_emplace( in SetPath()
370 cur = inserted->second.get(); in SetPath()
372 cur = found->second.get(); in SetPath()
377 if (!cur->is_dict()) in SetPath()
379 return cur->SetKey(*cur_path, std::move(value)); in SetPath()
382 bool Value::RemovePath(std::initializer_list<std::string_view> path) { in RemovePath() argument
383 DCHECK_GE(path.size(), 2u) << "Use RemoveKey() for a path of length 1."; in RemovePath()
384 return RemovePath(make_span(path.begin(), path.size())); in RemovePath()
387 bool Value::RemovePath(span<const std::string_view> path) { in RemovePath() argument
388 if (!is_dict() || path.empty()) in RemovePath()
391 if (path.size() == 1) in RemovePath()
392 return RemoveKey(path[0]); in RemovePath()
394 auto found = dict_.find(path[0]); in RemovePath()
395 if (found == dict_.end() || !found->second->is_dict()) in RemovePath()
398 bool removed = found->second->RemovePath(path.subspan(1)); in RemovePath()
399 if (removed && found->second->dict_.empty()) in RemovePath()
656 if (value && value->GetAsDictionary(&out)) { in From()
668 bool DictionaryValue::HasKey(std::string_view key) const { in HasKey()
669 DCHECK(IsStringUTF8(key)); in HasKey()
670 auto current_entry = dict_.find(key); in HasKey()
671 DCHECK((current_entry == dict_.end()) || current_entry->second); in HasKey()
679 Value* DictionaryValue::Set(std::string_view path, in Set() argument
681 DCHECK(IsStringUTF8(path)); in Set()
684 std::string_view current_path(path); in Set()
690 std::string_view key = current_path.substr(0, delimiter_position); in Set() local
692 current_dictionary->FindKeyOfType(key, Type::DICTIONARY); in Set()
695 current_dictionary->SetKey(key, Value(Type::DICTIONARY)); in Set()
703 ->SetWithoutPathExpansion(current_path, std::move(in_value)); in Set()
706 Value* DictionaryValue::SetBoolean(std::string_view path, bool in_value) { in SetBoolean() argument
707 return Set(path, std::make_unique<Value>(in_value)); in SetBoolean()
710 Value* DictionaryValue::SetInteger(std::string_view path, int in_value) { in SetInteger() argument
711 return Set(path, std::make_unique<Value>(in_value)); in SetInteger()
714 Value* DictionaryValue::SetString(std::string_view path, in SetString() argument
716 return Set(path, std::make_unique<Value>(in_value)); in SetString()
719 Value* DictionaryValue::SetString(std::string_view path, in SetString() argument
721 return Set(path, std::make_unique<Value>(in_value)); in SetString()
725 std::string_view path, in SetDictionary() argument
727 return static_cast<DictionaryValue*>(Set(path, std::move(in_value))); in SetDictionary()
730 ListValue* DictionaryValue::SetList(std::string_view path, in SetList() argument
732 return static_cast<ListValue*>(Set(path, std::move(in_value))); in SetList()
736 std::string_view key, in SetWithoutPathExpansion() argument
740 auto result = dict_.try_emplace(key, std::move(in_value)); in SetWithoutPathExpansion()
743 result.first->second = std::move(in_value); in SetWithoutPathExpansion()
745 return result.first->second.get(); in SetWithoutPathExpansion()
748 bool DictionaryValue::Get(std::string_view path, in Get() argument
750 DCHECK(IsStringUTF8(path)); in Get()
751 std::string_view current_path(path); in Get()
757 if (!current_dictionary->GetDictionaryWithoutPathExpansion( in Get()
766 return current_dictionary->GetWithoutPathExpansion(current_path, out_value); in Get()
769 bool DictionaryValue::Get(std::string_view path, Value** out_value) { in Get() argument
771 path, const_cast<const Value**>(out_value)); in Get()
774 bool DictionaryValue::GetBoolean(std::string_view path, in GetBoolean() argument
777 if (!Get(path, &value)) in GetBoolean()
780 return value->GetAsBoolean(bool_value); in GetBoolean()
783 bool DictionaryValue::GetInteger(std::string_view path, int* out_value) const { in GetInteger() argument
785 if (!Get(path, &value)) in GetInteger()
788 return value->GetAsInteger(out_value); in GetInteger()
791 bool DictionaryValue::GetString(std::string_view path, in GetString() argument
794 if (!Get(path, &value)) in GetString()
797 return value->GetAsString(out_value); in GetString()
800 bool DictionaryValue::GetString(std::string_view path, in GetString() argument
803 if (!Get(path, &value)) in GetString()
806 return value->GetAsString(out_value); in GetString()
809 bool DictionaryValue::GetStringASCII(std::string_view path, in GetStringASCII() argument
812 if (!GetString(path, &out)) in GetStringASCII()
820 out_value->assign(out); in GetStringASCII()
824 bool DictionaryValue::GetBinary(std::string_view path, in GetBinary() argument
827 bool result = Get(path, &value); in GetBinary()
828 if (!result || !value->is_blob()) in GetBinary()
837 bool DictionaryValue::GetBinary(std::string_view path, Value** out_value) { in GetBinary() argument
839 path, const_cast<const Value**>(out_value)); in GetBinary()
842 bool DictionaryValue::GetDictionary(std::string_view path, in GetDictionary() argument
845 bool result = Get(path, &value); in GetDictionary()
846 if (!result || !value->is_dict()) in GetDictionary()
855 bool DictionaryValue::GetDictionary(std::string_view path, in GetDictionary() argument
858 path, const_cast<const DictionaryValue**>(out_value)); in GetDictionary()
861 bool DictionaryValue::GetList(std::string_view path, in GetList() argument
864 bool result = Get(path, &value); in GetList()
865 if (!result || !value->is_list()) in GetList()
874 bool DictionaryValue::GetList(std::string_view path, ListValue** out_value) { in GetList() argument
876 path, const_cast<const ListValue**>(out_value)); in GetList()
879 bool DictionaryValue::GetWithoutPathExpansion(std::string_view key, in GetWithoutPathExpansion() argument
881 DCHECK(IsStringUTF8(key)); in GetWithoutPathExpansion()
882 auto entry_iterator = dict_.find(key); in GetWithoutPathExpansion()
887 *out_value = entry_iterator->second.get(); in GetWithoutPathExpansion()
891 bool DictionaryValue::GetWithoutPathExpansion(std::string_view key, in GetWithoutPathExpansion() argument
894 key, const_cast<const Value**>(out_value)); in GetWithoutPathExpansion()
897 bool DictionaryValue::GetBooleanWithoutPathExpansion(std::string_view key, in GetBooleanWithoutPathExpansion() argument
900 if (!GetWithoutPathExpansion(key, &value)) in GetBooleanWithoutPathExpansion()
903 return value->GetAsBoolean(out_value); in GetBooleanWithoutPathExpansion()
906 bool DictionaryValue::GetIntegerWithoutPathExpansion(std::string_view key, in GetIntegerWithoutPathExpansion() argument
909 if (!GetWithoutPathExpansion(key, &value)) in GetIntegerWithoutPathExpansion()
912 return value->GetAsInteger(out_value); in GetIntegerWithoutPathExpansion()
916 std::string_view key, in GetStringWithoutPathExpansion() argument
919 if (!GetWithoutPathExpansion(key, &value)) in GetStringWithoutPathExpansion()
922 return value->GetAsString(out_value); in GetStringWithoutPathExpansion()
926 std::string_view key, in GetStringWithoutPathExpansion() argument
929 if (!GetWithoutPathExpansion(key, &value)) in GetStringWithoutPathExpansion()
932 return value->GetAsString(out_value); in GetStringWithoutPathExpansion()
936 std::string_view key, in GetDictionaryWithoutPathExpansion() argument
939 bool result = GetWithoutPathExpansion(key, &value); in GetDictionaryWithoutPathExpansion()
940 if (!result || !value->is_dict()) in GetDictionaryWithoutPathExpansion()
950 std::string_view key, in GetDictionaryWithoutPathExpansion() argument
955 key, const_cast<const DictionaryValue**>(out_value)); in GetDictionaryWithoutPathExpansion()
959 std::string_view key, in GetListWithoutPathExpansion() argument
962 bool result = GetWithoutPathExpansion(key, &value); in GetListWithoutPathExpansion()
963 if (!result || !value->is_list()) in GetListWithoutPathExpansion()
972 bool DictionaryValue::GetListWithoutPathExpansion(std::string_view key, in GetListWithoutPathExpansion() argument
975 key, const_cast<const ListValue**>(out_value)); in GetListWithoutPathExpansion()
978 bool DictionaryValue::Remove(std::string_view path, in Remove() argument
980 DCHECK(IsStringUTF8(path)); in Remove()
981 std::string_view current_path(path); in Remove()
991 return current_dictionary->RemoveWithoutPathExpansion(current_path, in Remove()
996 std::string_view key, in RemoveWithoutPathExpansion() argument
998 DCHECK(IsStringUTF8(key)); in RemoveWithoutPathExpansion()
999 auto entry_iterator = dict_.find(key); in RemoveWithoutPathExpansion()
1004 *out_value = std::move(entry_iterator->second); in RemoveWithoutPathExpansion()
1009 bool DictionaryValue::RemovePath(std::string_view path, in RemovePath() argument
1012 size_t delimiter_position = path.find('.'); in RemovePath()
1015 return RemoveWithoutPathExpansion(path, out_value); in RemovePath()
1017 std::string_view subdict_path = path.substr(0, delimiter_position); in RemovePath()
1021 result = subdict->RemovePath(path.substr(delimiter_position + 1), out_value); in RemovePath()
1022 if (result && subdict->empty()) in RemovePath()
1038 CHECK(dictionary->is_dict()); in MergeDictionary()
1042 if (merge_value->is_dict()) { in MergeDictionary()
1044 if (GetDictionaryWithoutPathExpansion(it.key(), &sub_dict)) { in MergeDictionary()
1045 sub_dict->MergeDictionary( in MergeDictionary()
1051 SetKey(it.key(), merge_value->Clone()); in MergeDictionary()
1056 CHECK(other->is_dict()); in Swap()
1057 dict_.swap(other->dict_); in Swap()
1080 if (value && value->GetAsList(&out)) { in From()
1131 return value->GetAsBoolean(bool_value); in GetBoolean()
1139 return value->GetAsInteger(out_value); in GetInteger()
1147 return value->GetAsString(out_value); in GetString()
1155 return value->GetAsString(out_value); in GetString()
1162 if (!result || !value->is_dict()) in GetDictionary()
1179 if (!result || !value->is_list()) in GetList()
1280 CHECK(other->is_list()); in Swap()
1281 list_.swap(other->list_); in Swap()