25class YamlParserContext;
31 Value(std::string &&
k, std::unique_ptr<YamlObject> &&
v)
32 : key(std::move(
k)), value(std::move(
v))
36 std::unique_ptr<YamlObject> value;
39 using Container = std::vector<Value>;
40 using ListContainer = std::vector<std::unique_ptr<YamlObject>>;
44 template<
typename Derived>
48 using difference_type = std::ptrdiff_t;
49 using iterator_category = std::forward_iterator_tag;
51 Iterator(
typename Container::const_iterator
it)
59 return *
static_cast<Derived *
>(
this);
71 return a.it_ == b.it_;
76 return a.it_ != b.it_;
80 Container::const_iterator
it_;
83 template<
typename Iterator>
111 using reference = value_type;
118 pointer operator->()
const
120 return it_->value.get();
127 using value_type = std::pair<const std::string &, const YamlObject &>;
128 using pointer = value_type *;
129 using reference = value_type &;
133 return {
it_->key, *
it_->value.get() };
153 return type_ == Type::Value;
157 return type_ == Type::List;
161 return type_ == Type::Dictionary;
165 return type_ == Type::Empty;
169 return type_ != Type::Empty;
172 std::size_t
size()
const;
175 std::optional<T>
get()
const
180 template<
typename T,
typename U>
189 std::is_same_v<bool, T> ||
190 std::is_same_v<float, T> ||
191 std::is_same_v<double, T> ||
192 std::is_same_v<int8_t, T> ||
193 std::is_same_v<uint8_t, T> ||
194 std::is_same_v<int16_t, T> ||
195 std::is_same_v<uint16_t, T> ||
196 std::is_same_v<int32_t, T> ||
197 std::is_same_v<uint32_t, T> ||
198 std::is_same_v<std::string, T> ||
199 std::is_same_v<Size, T>> * =
nullptr>
203 std::optional<std::vector<T>>
getList()
const;
210 bool contains(std::string_view key)
const;
217 friend struct Getter;
218 friend class YamlParserContext;
227 template<
typename T,
typename Enable =
void>
229 std::optional<T>
get(
const YamlObject &
obj)
const;
236 std::map<std::string, YamlObject *, std::less<>> dictionary_;
242 static std::unique_ptr<YamlObject>
parse(
File &file);
Utilities to help constructing class interfaces.
#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
Disable copy and move construction and assignment of the klass.
Definition class.h:29
Interface for I/O operations on files.
Definition file.h:25
A class representing the tree structure of the YAML content.
Definition yaml_parser.h:28
std::size_t size() const
Retrieve the number of elements in a dictionary or list YamlObject.
Definition yaml_parser.cpp:99
bool isEmpty() const
Return whether the YamlObject is an empty.
Definition yaml_parser.h:163
bool isList() const
Return whether the YamlObject is a list.
Definition yaml_parser.h:155
T get(U &&defaultValue) const
Parse the YamlObject as a T value.
Definition yaml_parser.h:181
bool contains(std::string_view key) const
Check if an element of a dictionary exists.
Definition yaml_parser.cpp:372
std::optional< std::vector< T > > getList() const
Parse the YamlObject as a list of T.
std::optional< T > get() const
Parse the YamlObject as a T value.
Definition yaml_parser.h:175
const YamlObject & operator[](std::size_t index) const
Retrieve the element from list YamlObject by index.
Definition yaml_parser.cpp:353
DictAdapter asDict() const
Wrap a dictionary YamlObject in an adapter that exposes iterators.
Definition yaml_parser.h:205
bool isValue() const
Return whether the YamlObject is a value.
Definition yaml_parser.h:151
bool isDictionary() const
Return whether the YamlObject is a dictionary.
Definition yaml_parser.h:159
ListAdapter asList() const
Wrap a list YamlObject in an adapter that exposes iterators.
Definition yaml_parser.h:206
A helper class for parsing a YAML file.
Definition yaml_parser.h:240
static std::unique_ptr< YamlObject > parse(File &file)
Parse a YAML file as a YamlObject.
Definition yaml_parser.cpp:765
Data structures related to geometric objects.
Top-level libcamera namespace.
Definition backtrace.h:17
bool operator==(const ColorSpace &lhs, const ColorSpace &rhs)
Compare color spaces for equality.
Definition color_space.cpp:506
bool operator!=(const Vector< T, Rows > &lhs, const Vector< T, Rows > &rhs)
Compare vectors for inequality.
Definition vector.h:326
Matrix< U, Rows, Cols > operator*(T d, const Matrix< U, Rows, Cols > &m)
Multiply the matrix by a scalar.
Definition matrix.h:133