diff options
author | Willy Tu <wltu@google.com> | 2022-02-01 02:38:48 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-03-01 03:00:11 +0300 |
commit | ea2e6eeca15f4019923466f7c8ccc52c53a5ea94 (patch) | |
tree | de20cf21801883ace3ef3b887253c7dd407411e5 /include/dbus_utility.hpp | |
parent | ad5d7e7130db7c99d6d4d3c3a465b28c33f9be21 (diff) | |
download | bmcweb-ea2e6eeca15f4019923466f7c8ccc52c53a5ea94.tar.xz |
json_utils: Add support for multiple level json read
Added support for multiple level direct read. For example, we can now
access `abc/xyz` directly instead of getting `abc` and then abc[`xyz`].
For extra element error, it will only be triggered if the element at the
root level is not a parent of any of the requested elements.
For example,
{
"abc": {
"xyz": 12
}
}
Getting "abc/xyz" will satisfy the condition so it does not throw an
error.
This is accomplished in a reasonable way by moving the previously
variadic templated code to a std::span<variant> that contains all
possible types. This is a trick learned from the fmt library to reduce
compile sizes, as the majority of the code doesn't get duplicated at
template level, and is instead operating on the fixed variant type.
This commit drops 7316 bytes (about half a percent of total) from the
bmcweb binary size from the reduction in template usage. Later patches
build on this patchset to simplify call sites even more and reduce the
binary size further, but as is, this is still a win.
Note: now that the UnpackVariant lists all possible unpack types, it was
found that readJson would fail to compile for vector<bool>. This is a
well known C++ deficiency in the std::vector<bool> type when compared to
all other types, and will need special handling in the future. The two
types for vector<bool> are left commented out in the typelist.
Tested: Unit tests passing with reasonable coverage. Functional use in
next commit in this series.
Change-Id: Ifb247c9121c41ad8f1de26eb4bfc3d71484e6bd6
Signed-off-by: Willy Tu <wltu@google.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'include/dbus_utility.hpp')
0 files changed, 0 insertions, 0 deletions