@@ -17,8 +17,6 @@
#include <libcamera/base/class.h>
-#include <libcamera/geometry.h>
-
namespace libcamera {
class File;
@@ -14,6 +14,8 @@
#include <libcamera/base/log.h>
#include <libcamera/base/span.h>
+#include <libcamera/geometry.h>
+
#include "libcamera/internal/yaml_parser.h"
namespace libcamera {
@@ -12,6 +12,8 @@
#include <libcamera/base/log.h>
+#include "libcamera/internal/yaml_parser.h"
+
/**
* \file geometry.h
* \brief Data structures related to geometric objects
@@ -924,4 +926,31 @@ std::ostream &operator<<(std::ostream &out, const Rectangle &r)
return out;
}
+#ifndef __DOXYGEN__
+/*
+ * The YAML data shall be a list of two numerical values containing the x and y
+ * coordinates, in that order.
+ */
+template<>
+std::optional<Size>
+YamlObject::Accessor<Size>::get(const YamlObject &obj) const
+{
+ if (obj.type_ != Type::List)
+ return std::nullopt;
+
+ if (obj.list_.size() != 2)
+ return std::nullopt;
+
+ auto width = obj.list_[0].value->get<uint32_t>();
+ if (!width)
+ return std::nullopt;
+
+ auto height = obj.list_[1].value->get<uint32_t>();
+ if (!height)
+ return std::nullopt;
+
+ return Size(*width, *height);
+}
+#endif /* __DOXYGEN__ */
+
} /* namespace libcamera */
@@ -284,27 +284,6 @@ void YamlObject::Accessor<std::string>::set(YamlObject &obj, std::string value)
obj.value_ = std::move(value);
}
-template<>
-std::optional<Size>
-YamlObject::Accessor<Size>::get(const YamlObject &obj) const
-{
- if (obj.type_ != Type::List)
- return std::nullopt;
-
- if (obj.list_.size() != 2)
- return std::nullopt;
-
- auto width = obj.list_[0].value->get<uint32_t>();
- if (!width)
- return std::nullopt;
-
- auto height = obj.list_[1].value->get<uint32_t>();
- if (!height)
- return std::nullopt;
-
- return Size(*width, *height);
-}
-
template<typename T>
struct YamlObject::Accessor<std::vector<T>, std::enable_if_t<
std::is_same_v<bool, T> ||
@@ -316,8 +295,7 @@ struct YamlObject::Accessor<std::vector<T>, std::enable_if_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>>>
+ std::is_same_v<std::string, T>>>
{
std::optional<std::vector<T>> get(const YamlObject &obj) const
{
@@ -348,7 +326,6 @@ template struct YamlObject::Accessor<std::vector<uint16_t>>;
template struct YamlObject::Accessor<std::vector<int32_t>>;
template struct YamlObject::Accessor<std::vector<uint32_t>>;
template struct YamlObject::Accessor<std::vector<std::string>>;
-template struct YamlObject::Accessor<std::vector<Size>>;
#endif /* __DOXYGEN__ */
/**
@@ -14,6 +14,8 @@
#include <libcamera/base/file.h>
#include <libcamera/base/utils.h>
+#include <libcamera/geometry.h>
+
#include "libcamera/internal/yaml_parser.h"
#include "test.h"
The YamlObject::Accessor structure is designed to extend the YamlObject class with new getter and setter types without modifying yaml_parser.cpp. This feature is used for various libcamera classes, while standard C++ types are handled in yaml_parser.cpp. The Size class is an outlier: it is a libcamera class, but is handled in yaml_parser.cpp. Move it to geometry.cpp. Drop the std::vector<Size> specialization as it is currently unused. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- include/libcamera/internal/yaml_parser.h | 2 -- src/ipa/libipa/lsc_polynomial.h | 2 ++ src/libcamera/geometry.cpp | 29 ++++++++++++++++++++++++ src/libcamera/yaml_parser.cpp | 25 +------------------- test/yaml-parser.cpp | 2 ++ 5 files changed, 34 insertions(+), 26 deletions(-)