libcamera: yaml_parser: Add getList() function

Allow to retrieve a YAML list of any already supported types in a
std::vector.

Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Florian Sylvestre 2022-07-22 17:16:31 +02:00 committed by Laurent Pinchart
parent b4cbb5c388
commit 02e387e7b6
3 changed files with 75 additions and 0 deletions

View file

@ -183,6 +183,22 @@ public:
return get<T>().value_or(defaultValue);
}
#ifndef __DOXYGEN__
template<typename T,
typename std::enable_if_t<
std::is_same_v<bool, T> ||
std::is_same_v<double, T> ||
std::is_same_v<int16_t, T> ||
std::is_same_v<uint16_t, T> ||
std::is_same_v<int32_t, T> ||
std::is_same_v<uint32_t, T> ||
std::is_same_v<std::string, T> ||
std::is_same_v<Size, T>> * = nullptr>
#else
template<typename T>
#endif
std::optional<std::vector<T>> getList() const;
DictAdapter asDict() const { return DictAdapter{ list_ }; }
ListAdapter asList() const { return ListAdapter{ list_ }; }