Lines Matching refs:Value

30                   static_cast<size_t>(Value::Type::LIST) + 1,
33 std::unique_ptr<Value> CopyWithoutEmptyChildren(const Value& node);
38 std::unique_ptr<Value> CopyListWithoutEmptyChildren(const Value& list) {
39 Value copy(Value::Type::LIST);
41 std::unique_ptr<Value> child_copy = CopyWithoutEmptyChildren(entry);
46 : std::make_unique<Value>(std::move(copy));
53 std::unique_ptr<Value> child_copy = CopyWithoutEmptyChildren(it.value());
63 std::unique_ptr<Value> CopyWithoutEmptyChildren(const Value& node) {
65 case Value::Type::LIST:
68 case Value::Type::DICTIONARY:
73 return std::make_unique<Value>(node.Clone());
80 std::unique_ptr<Value> Value::CreateWithCopiedBuffer(const char* buffer,
82 return std::make_unique<Value>(BlobStorage(buffer, buffer + size));
86 Value Value::FromUniquePtrValue(std::unique_ptr<Value> val) {
91 std::unique_ptr<Value> Value::ToUniquePtrValue(Value val) {
92 return std::make_unique<Value>(std::move(val));
95 Value::Value(Value&& that) noexcept {
99 Value::Value() noexcept : type_(Type::NONE) {}
101 Value::Value(Type type) : type_(type) {
128 Value::Value(bool in_bool) : type_(Type::BOOLEAN), bool_value_(in_bool) {}
130 Value::Value(int in_int) : type_(Type::INTEGER), int_value_(in_int) {}
132 Value::Value(const char* in_string) : Value(std::string(in_string)) {}
134 Value::Value(std::string_view in_string) : Value(std::string(in_string)) {}
136 Value::Value(std::string&& in_string) noexcept
141 Value::Value(const char16_t* in_string16)
142 : Value(std::u16string_view(in_string16)) {}
144 Value::Value(std::u16string_view in_string16)
145 : Value(UTF16ToUTF8(in_string16)) {}
147 Value::Value(const BlobStorage& in_blob)
150 Value::Value(BlobStorage&& in_blob) noexcept
153 Value::Value(const DictStorage& in_dict) : type_(Type::DICTIONARY), dict_() {
157 std::make_unique<Value>(it.second->Clone()));
161 Value::Value(DictStorage&& in_dict) noexcept
164 Value::Value(const ListStorage& in_list) : type_(Type::LIST), list_() {
170 Value::Value(ListStorage&& in_list) noexcept
173 Value& Value::operator=(Value&& that) noexcept {
180 Value Value::Clone() const {
183 return Value();
185 return Value(bool_value_);
187 return Value(int_value_);
189 return Value(string_value_);
191 return Value(binary_value_);
193 return Value(dict_);
195 return Value(list_);
199 return Value();
202 Value::~Value() {
207 const char* Value::GetTypeName(Value::Type type) {
213 bool Value::GetBool() const {
218 int Value::GetInt() const {
223 const std::string& Value::GetString() const {
228 const Value::BlobStorage& Value::GetBlob() const {
233 Value::ListStorage& Value::GetList() {
238 const Value::ListStorage& Value::GetList() const {
243 Value* Value::FindKey(std::string_view key) {
244 return const_cast<Value*>(static_cast<const Value*>(this)->FindKey(key));
247 const Value* Value::FindKey(std::string_view key) const {
255 Value* Value::FindKeyOfType(std::string_view key, Type type) {
256 return const_cast<Value*>(
257 static_cast<const Value*>(this)->FindKeyOfType(key, type));
260 const Value* Value::FindKeyOfType(std::string_view key, Type type) const {
261 const Value* result = FindKey(key);
267 bool Value::RemoveKey(std::string_view key) {
273 Value* Value::SetKey(std::string_view key, Value value) {
277 auto val_ptr = std::make_unique<Value>(std::move(value));
286 Value* Value::SetKey(std::string&& key, Value value) {
290 std::make_unique<Value>(std::move(value)))
294 Value* Value::SetKey(const char* key, Value value) {
298 Value* Value::FindPath(std::initializer_list<std::string_view> path) {
299 return const_cast<Value*>(const_cast<const Value*>(this)->FindPath(path));
302 Value* Value::FindPath(span<const std::string_view> path) {
303 return const_cast<Value*>(const_cast<const Value*>(this)->FindPath(path));
306 const Value* Value::FindPath(
312 const Value* Value::FindPath(span<const std::string_view> path) const {
313 const Value* cur = this;
321 Value* Value::FindPathOfType(std::initializer_list<std::string_view> path,
323 return const_cast<Value*>(
324 const_cast<const Value*>(this)->FindPathOfType(path, type));
327 Value* Value::FindPathOfType(span<const std::string_view> path, Type type) {
328 return const_cast<Value*>(
329 const_cast<const Value*>(this)->FindPathOfType(path, type));
332 const Value* Value::FindPathOfType(std::initializer_list<std::string_view> path,
338 const Value* Value::FindPathOfType(span<const std::string_view> path,
340 const Value* result = FindPath(path);
346 Value* Value::SetPath(std::initializer_list<std::string_view> path,
347 Value value) {
352 Value* Value::SetPath(span<const std::string_view> path, Value value) {
357 Value* cur = this;
369 found, path_component, std::make_unique<Value>(Type::DICTIONARY));
382 bool Value::RemovePath(std::initializer_list<std::string_view> path) {
387 bool Value::RemovePath(span<const std::string_view> path) {
405 Value::dict_iterator_proxy Value::DictItems() {
410 Value::const_dict_iterator_proxy Value::DictItems() const {
415 size_t Value::DictSize() const {
420 bool Value::DictEmpty() const {
425 bool Value::GetAsBoolean(bool* out_value) const {
433 bool Value::GetAsInteger(int* out_value) const {
441 bool Value::GetAsString(std::string* out_value) const {
449 bool Value::GetAsString(std::u16string* out_value) const {
457 bool Value::GetAsString(const Value** out_value) const {
459 *out_value = static_cast<const Value*>(this);
465 bool Value::GetAsString(std::string_view* out_value) const {
473 bool Value::GetAsList(ListValue** out_value) {
481 bool Value::GetAsList(const ListValue** out_value) const {
489 bool Value::GetAsDictionary(DictionaryValue** out_value) {
497 bool Value::GetAsDictionary(const DictionaryValue** out_value) const {
505 Value* Value::DeepCopy() const {
506 return new Value(Clone());
509 std::unique_ptr<Value> Value::CreateDeepCopy() const {
510 return std::make_unique<Value>(Clone());
513 bool operator==(const Value& lhs, const Value& rhs) {
518 case Value::Type::NONE:
520 case Value::Type::BOOLEAN:
522 case Value::Type::INTEGER:
524 case Value::Type::STRING:
526 case Value::Type::BINARY:
530 case Value::Type::DICTIONARY:
538 case Value::Type::LIST:
546 bool operator!=(const Value& lhs, const Value& rhs) {
550 bool operator<(const Value& lhs, const Value& rhs) {
555 case Value::Type::NONE:
557 case Value::Type::BOOLEAN:
559 case Value::Type::INTEGER:
561 case Value::Type::STRING:
563 case Value::Type::BINARY:
567 case Value::Type::DICTIONARY:
571 [](const Value::DictStorage::value_type& u,
572 const Value::DictStorage::value_type& v) {
575 case Value::Type::LIST:
583 bool operator>(const Value& lhs, const Value& rhs) {
587 bool operator<=(const Value& lhs, const Value& rhs) {
591 bool operator>=(const Value& lhs, const Value& rhs) {
595 bool Value::Equals(const Value* other) const {
600 void Value::InternalMoveConstructFrom(Value&& that) {
627 void Value::InternalCleanup() {
654 std::unique_ptr<Value> value) {
663 DictionaryValue::DictionaryValue() : Value(Type::DICTIONARY) {}
664 DictionaryValue::DictionaryValue(const DictStorage& in_dict) : Value(in_dict) {}
666 : Value(std::move(in_dict)) {}
679 Value* DictionaryValue::Set(std::string_view path,
680 std::unique_ptr<Value> in_value) {
685 Value* current_dictionary = this;
691 Value* child_dictionary =
695 current_dictionary->SetKey(key, Value(Type::DICTIONARY));
706 Value* DictionaryValue::SetBoolean(std::string_view path, bool in_value) {
707 return Set(path, std::make_unique<Value>(in_value));
710 Value* DictionaryValue::SetInteger(std::string_view path, int in_value) {
711 return Set(path, std::make_unique<Value>(in_value));
714 Value* DictionaryValue::SetString(std::string_view path,
716 return Set(path, std::make_unique<Value>(in_value));
719 Value* DictionaryValue::SetString(std::string_view path,
721 return Set(path, std::make_unique<Value>(in_value));
735 Value* DictionaryValue::SetWithoutPathExpansion(
737 std::unique_ptr<Value> in_value) {
749 const Value** out_value) const {
769 bool DictionaryValue::Get(std::string_view path, Value** out_value) {
771 path, const_cast<const Value**>(out_value));
776 const Value* value;
784 const Value* value;
793 const Value* value;
802 const Value* value;
825 const Value** out_value) const {
826 const Value* value;
837 bool DictionaryValue::GetBinary(std::string_view path, Value** out_value) {
839 path, const_cast<const Value**>(out_value));
844 const Value* value;
863 const Value* value;
880 const Value** out_value) const {
892 Value** out_value) {
894 key, const_cast<const Value**>(out_value));
899 const Value* value;
908 const Value* value;
918 const Value* value;
928 const Value* value;
938 const Value* value;
961 const Value* value;
979 std::unique_ptr<Value>* out_value) {
997 std::unique_ptr<Value>* out_value) {
1010 std::unique_ptr<Value>* out_value) {
1040 const Value* merge_value = &it.value();
1078 std::unique_ptr<ListValue> ListValue::From(std::unique_ptr<Value> value) {
1087 ListValue::ListValue() : Value(Type::LIST) {}
1088 ListValue::ListValue(const ListStorage& in_list) : Value(in_list) {}
1090 : Value(std::move(in_list)) {}
1100 bool ListValue::Set(size_t index, std::unique_ptr<Value> in_value) {
1111 bool ListValue::Get(size_t index, const Value** out_value) const {
1121 bool ListValue::Get(size_t index, Value** out_value) {
1123 index, const_cast<const Value**>(out_value));
1127 const Value* value;
1135 const Value* value;
1143 const Value* value;
1151 const Value* value;
1160 const Value* value;
1177 const Value* value;
1193 bool ListValue::Remove(size_t index, std::unique_ptr<Value>* out_value) {
1198 *out_value = std::make_unique<Value>(std::move(list_[index]));
1204 bool ListValue::Remove(const Value& value, size_t* index) {
1218 std::unique_ptr<Value>* out_value) {
1220 *out_value = std::make_unique<Value>(std::move(*iter));
1225 void ListValue::Append(std::unique_ptr<Value> in_value) {
1257 bool ListValue::AppendIfNotPresent(std::unique_ptr<Value> in_value) {
1266 bool ListValue::Insert(size_t index, std::unique_ptr<Value> in_value) {
1275 ListValue::const_iterator ListValue::Find(const Value& value) const {
1296 std::ostream& operator<<(std::ostream& out, const Value& value) {
1302 std::ostream& operator<<(std::ostream& out, const Value::Type& type) {
1306 return out << Value::GetTypeName(type);