/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2022, Google Inc. * * yaml_parser.h - libcamera YAML parsing helper */ #pragma once #include #include #include #include #include #include namespace libcamera { class YamlParserContext; class YamlObject { public: YamlObject(); ~YamlObject(); bool isValue() const { return type_ == Type::Value; } bool isList() const { return type_ == Type::List; } bool isDictionary() const { return type_ == Type::Dictionary; } #ifndef __DOXYGEN__ template::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value> * = nullptr> #else template #endif T get(const T &defaultValue, bool *ok = nullptr) const; std::size_t size() const; const YamlObject &operator[](std::size_t index) const; bool contains(const std::string &key) const; const YamlObject &operator[](const std::string &key) const; std::vector memberNames() const; private: LIBCAMERA_DISABLE_COPY_AND_MOVE(YamlObject) friend class YamlParserContext; enum class Type { Dictionary, List, Value, }; Type type_; std::string value_; std::vector> list_; std::map> dictionary_; }; class YamlParser final { public: static std::unique_ptr parse(std::FILE *fh); }; } /* namespace libcamera */