Discussion:
[chromium-discuss] Neat way to use FindPathOfType() ?
'Linkun Chen' via Chromium-discuss
2018-09-25 21:47:03 UTC
Permalink
2 facts:
* DictionaryValue::Get##Type() is deprecated
(https://cs.chromium.org/chromium/src/base/values.h?q=dictionaryvalue&sq=package:chromium&g=0&l=478),
and Value::FindPath() is encouraged.
* FindPathOfType doesn't allow initializer_list with 1 element
(https://cs.chromium.org/chromium/src/base/values.cc?sq=package:chromium&g=0&l=359)

What is the neatest way to find value by key? I want to use something like:

#define GET_FIELD_BY_VALUE(dict_value, key_path, value_type, type, value)
\
do {
\
const base::Value* tmp_value =
\
dict_value.FindPathOfType(key_path, base::Value::Type::value_type);
\
if (tmp_value) {
\
value = tmp_value->Get##type();
\
}
\
} while (false)

But initializer_list doesn't work with macro, and it doesn't support single
key.
--
--
Chromium Discussion mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+***@chromium.org.
Loading...