summaryrefslogtreecommitdiff
path: root/src/libcamera/yaml_parser.cpp
AgeCommit message (Collapse)Author
2022-06-20libcamera: yaml_parser: Add get() specializations for 16-bit integersLaurent Pinchart
Extend the YamlObject::get() function template to support 16-bit integers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-20libcamera: yaml_parser: Fix range checks for 32-bit integersLaurent Pinchart
The strtol() and strtoul() functions return long integers, which may be larger than 32-bit integers. Add manual range checks. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-20libcamera: yaml_parser: Remove memberNames() functionLaurent Pinchart
Now that YamlObject supports iteration, the memberNames() function isn't useful anymore as it can be implemented using utils::map_keys() if really needed. Drop it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-20libcamera: yaml_parser: Add iterator APILaurent Pinchart
Allow using range-based for loops over YamlObject instances by implementing iterators. New YamlObject::DictAdapter and YamlObject::ListAdapter adapter classes are introduced to provide different iterators depending on the object type. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-16libcamera: yaml_parser: Switch from FILE to FileLaurent Pinchart
THe FILE object isn't very user-friendly as it requires manual close. Replace it with File to provide RAII-style resource management in the YamlParser API. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16libcamera: yaml_parser: Extend YamlObject::size() to dictionariesLaurent Pinchart
Dictionaries have a size too, extend the size() function to support them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16libcamera: yaml_object: Turn Type into an enum classLaurent Pinchart
Turn the Type enum into an enum class to force qualifying 'List' and 'Dictionary' in the YamlObject namespace scope. This will help avoiding ambiguities when adding iterator support. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-05-10libcamera: Introduce YamlParser as a helper to parse yaml filesHan-Lin Chen
Introduce YamlParser as a helper to convert contents of a yaml file to a tree based structure for easier reading, and to avoid writing parser with raw yaml tokens. The class is based on libyaml, and only support reading but not writing a yaml file. The interface is inspired by Json::Value class from jsoncpp: http://jsoncpp.sourceforge.net/class_json_1_1_value.html Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>