diff options
author | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2024-10-03 10:45:56 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2024-10-04 11:17:20 +0200 |
commit | 5a6eb4855506086caf73c2e8673a1aa27c400669 (patch) | |
tree | c115ebb3e2ce1d67fd743f4118fa1012c0c0297e /include | |
parent | 1accca05b5027ec30c5d6dbfea89a51fdcd1b969 (diff) |
WIP: YamlEmitter
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/internal/meson.build | 1 | ||||
-rw-r--r-- | include/libcamera/internal/yaml_emitter.h | 61 |
2 files changed, 62 insertions, 0 deletions
diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index 1c5eef9c..7533b075 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -41,6 +41,7 @@ libcamera_internal_headers = files([ 'v4l2_pixelformat.h', 'v4l2_subdevice.h', 'v4l2_videodevice.h', + 'yaml_emitter.h', 'yaml_parser.h', ]) diff --git a/include/libcamera/internal/yaml_emitter.h b/include/libcamera/internal/yaml_emitter.h new file mode 100644 index 00000000..f8df5265 --- /dev/null +++ b/include/libcamera/internal/yaml_emitter.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Ideas On Board Oy + * + * libcamera YAML emitter helper + */ + +#pragma once + +#include <map> +#include <memory> +#include <string> + +#include <libcamera/base/class.h> +#include <libcamera/base/file.h> + +#include <yaml.h> + +namespace libcamera { + +class File; +class YamlEvent; + +class YamlEmitter final +{ +public: + ~YamlEmitter(); + + static std::unique_ptr<YamlEmitter> create(std::string &path); + + int emit(std::map<std::string, std::string>); + int emit(const std::string &scalar); + +private: + LIBCAMERA_DISABLE_COPY(YamlEmitter); + + class Emitter + { + public: + Emitter() = default; + ~Emitter(); + + void init(File *file); + + int emit(YamlEvent *event); + + private: + void logError(); + + yaml_emitter_t emitter_; + }; + + YamlEmitter() = default; + + void init(); + + std::unique_ptr<File> file_; + Emitter emitter_; +}; + +} /* namespace libcamera */ |