Lines Matching +full:non +full:- +full:empty
4 * Copyright (c) 2013-2018 Red Hat, Inc.
7 * See the COPYING.LIB file in the top-level directory.
16 #include "qapi/qobject-input-visitor.h"
79 * Flatten non-empty QDict and QList recursively into @target, in qdict_flatten_qlist()
111 key = new_key = g_strdup_printf("%s.%s", prefix, entry->key); in qdict_flatten_qdict()
113 key = entry->key; in qdict_flatten_qdict()
118 * Flatten non-empty QDict and QList recursively into @target, in qdict_flatten_qdict()
132 qdict_del(qdict, entry->key); in qdict_flatten_qdict()
137 qdict_del(qdict, entry->key); in qdict_flatten_qdict()
149 * qdict_flatten(): For each nested non-empty QDict with key x, all
151 * to "x.y". For each nested non-empty QList with key x, the field at
176 if (strstart(entry->key, start, &p)) { in qdict_extract_subqdict()
178 qdict_put_obj(*dst, p, qobject_ref(entry->value)); in qdict_extract_subqdict()
180 qdict_del(src, entry->key); in qdict_extract_subqdict()
192 if (strstart(entry->key, start, NULL)) { in qdict_count_prefixed_entries()
194 return -ERANGE; in qdict_count_prefixed_entries()
204 * qdict_array_split(): This function moves array-like elements of a QDict into
239 /* Overflow is the same as positive non-zero results */ in qdict_array_split()
266 * @prefix: non-NULL pointer to hold extracted prefix
267 * @suffix: non-NULL pointer to remaining suffix
274 * 'foo.0.bar' -> prefix='foo' and suffix='0.bar'
275 * 'foo..0.bar' -> prefix='foo.0' and suffix='bar'
304 *prefix = g_strndup(key, separator - key); in qdict_split_flat_key()
327 * If @maybe_list is non-zero in length and all the keys look like
329 * length or all keys are non-numeric then it will return 0 to indicate
330 * it is a normal qdict. If there is a mix of numeric and non-numeric
331 * keys, or the list indexes are non-contiguous, an error is reported.
333 * Returns: 1 if a valid list, 0 if a dict, -1 on error
339 ssize_t max = -1; in qdict_is_list()
340 int is_list = -1; in qdict_is_list()
345 int is_index = !qemu_strtoi64(ent->key, NULL, 10, &val); in qdict_is_list()
347 if (is_list == -1) { in qdict_is_list()
352 error_setg(errp, "Cannot mix list and non-list keys"); in qdict_is_list()
353 return -1; in qdict_is_list()
364 if (is_list == -1) { in qdict_is_list()
369 /* NB this isn't a perfect check - e.g. it won't catch in qdict_is_list()
371 * does not matter - we've still proved that the in qdict_is_list()
378 return -1; in qdict_is_list()
389 * nesting, and values are scalars, empty dictionaries or empty lists,
411 * - Any values in @src are non-scalar types
412 * - If keys in @src imply that a particular level is both a
414 * - If keys in @src imply that a particular level is a list,
415 * but the indices are non-contiguous. e.g. "foo.0.bar" and
417 * - If keys in @src represent list indexes, but are not in
439 dict_val = qobject_to(QDict, ent->value); in qdict_crumple()
440 list_val = qobject_to(QList, ent->value); in qdict_crumple()
443 error_setg(errp, "Value %s is not flat", ent->key); in qdict_crumple()
447 qdict_split_flat_key(ent->key, &prefix, &suffix); in qdict_crumple()
458 error_setg(errp, "Cannot mix scalar and non-scalar keys"); in qdict_crumple()
468 qdict_put_obj(child_dict, suffix, qobject_ref(ent->value)); in qdict_crumple()
470 qdict_put_obj(two_level, prefix, qobject_ref(ent->value)); in qdict_crumple()
478 * into a multi-level dict */ in qdict_crumple()
482 dict_val = qobject_to(QDict, ent->value); in qdict_crumple()
489 qdict_put_obj(multi_level, ent->key, child); in qdict_crumple()
491 qdict_put_obj(multi_level, ent->key, qobject_ref(ent->value)); in qdict_crumple()
558 switch (qobject_type(ent->value)) { in qdict_crumple_for_keyval_qiv()
563 s = buf = qnum_to_string(qobject_to(QNum, ent->value)); in qdict_crumple_for_keyval_qiv()
570 s = qbool_get_bool(qobject_to(QBool, ent->value)) in qdict_crumple_for_keyval_qiv()
580 qdict_put_str(tmp, ent->key, s); in qdict_crumple_for_keyval_qiv()
591 * sub-QDict of src specified by the prefix in subqdict (or src itself for
593 * the sub-QDict would become empty after calling qdict_array_split() on it. If
594 * the array is not valid, -EINVAL is returned.
603 assert(!subqdict_len || subqdict[subqdict_len - 1] == '.'); in qdict_array_entries()
607 * entries will lead to -EINVAL. */ in qdict_array_entries()
616 prefix[strlen(prefix) - 1] = 0; in qdict_array_entries()
628 return -EINVAL; in qdict_array_entries()
636 /* Consider everything handled that isn't part of the given sub-QDict */ in qdict_array_entries()
643 /* Anything left in the sub-QDict that wasn't handled? */ in qdict_array_entries()
645 return -EINVAL; in qdict_array_entries()
661 * Therefore, with overwrite being true, the src QDict will always be empty when
662 * this function returns. If overwrite is false, the src QDict will be empty
673 if (overwrite || !qdict_haskey(dest, entry->key)) { in qdict_join()
674 qdict_put_obj(dest, entry->key, qobject_ref(entry->value)); in qdict_join()
675 qdict_del(src, entry->key); in qdict_join()
697 while (renames->from) { in qdict_rename_keys()
698 if (qdict_haskey(qdict, renames->from)) { in qdict_rename_keys()
699 if (qdict_haskey(qdict, renames->to)) { in qdict_rename_keys()
701 "same time", renames->to, renames->from); in qdict_rename_keys()
705 qobj = qdict_get(qdict, renames->from); in qdict_rename_keys()
706 qdict_put_obj(qdict, renames->to, qobject_ref(qobj)); in qdict_rename_keys()
707 qdict_del(qdict, renames->from); in qdict_rename_keys()