24class YamlParserContext;
30 Value(std::string &&
k, std::unique_ptr<YamlObject> &&
v)
31 : key(std::move(
k)), value(std::move(
v))
35 std::unique_ptr<YamlObject> value;
38 using Container = std::vector<Value>;
39 using ListContainer = std::vector<std::unique_ptr<YamlObject>>;
43 template<
typename Derived>
47 using difference_type = std::ptrdiff_t;
48 using iterator_category = std::forward_iterator_tag;
50 Iterator(
typename Container::const_iterator
it)
58 return *
static_cast<Derived *
>(
this);
70 return a.it_ ==
b.it_;
75 return a.it_ !=
b.it_;
79 Container::const_iterator
it_;
82 template<
typename Iterator>
110 using reference = value_type;
117 pointer operator->()
const
119 return it_->value.get();
126 using value_type = std::pair<const std::string &, const YamlObject &>;
127 using pointer = value_type *;
128 using reference = value_type &;
132 return {
it_->key, *
it_->value.get() };
152 return type_ == Type::Value;
156 return type_ == Type::List;
160 return type_ == Type::Dictionary;
164 return type_ == Type::Empty;
168 return type_ != Type::Empty;
171 std::size_t
size()
const;
174 std::optional<T>
get()
const
176 return Getter<T>{}.get(*
this);
179 template<
typename T,
typename U>
188 std::is_same_v<bool, T> ||
189 std::is_same_v<float, T> ||
190 std::is_same_v<double, T> ||
191 std::is_same_v<int8_t, T> ||
192 std::is_same_v<uint8_t, T> ||
193 std::is_same_v<int16_t, T> ||
194 std::is_same_v<uint16_t, T> ||
195 std::is_same_v<int32_t, T> ||
196 std::is_same_v<uint32_t, T> ||
197 std::is_same_v<std::string, T> ||
198 std::is_same_v<Size, T>> * =
nullptr>
202 std::optional<std::vector<T>>
getList()
const;
209 bool contains(
const std::string &key)
const;
216 friend struct Getter;
217 friend class YamlParserContext;
228 std::optional<T>
get(
const YamlObject &
obj)
const;
235 std::map<std::string, YamlObject *> dictionary_;
241 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:27
std::size_t size() const
Retrieve the number of elements in a dictionary or list YamlObject.
Definition yaml_parser.cpp:98
bool contains(const std::string &key) const
Check if an element of a dictionary exists.
Definition yaml_parser.cpp:484
bool isEmpty() const
Return whether the YamlObject is an empty.
Definition yaml_parser.h:162
bool isList() const
Return whether the YamlObject is a list.
Definition yaml_parser.h:154
T get(U &&defaultValue) const
Parse the YamlObject as a T value.
Definition yaml_parser.h:180
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:174
const YamlObject & operator[](std::size_t index) const
Retrieve the element from list YamlObject by index.
Definition yaml_parser.cpp:465
DictAdapter asDict() const
Wrap a dictionary YamlObject in an adapter that exposes iterators.
Definition yaml_parser.h:204
bool isValue() const
Return whether the YamlObject is a value.
Definition yaml_parser.h:150
bool isDictionary() const
Return whether the YamlObject is a dictionary.
Definition yaml_parser.h:158
ListAdapter asList() const
Wrap a list YamlObject in an adapter that exposes iterators.
Definition yaml_parser.h:205
A helper class for parsing a YAML file.
Definition yaml_parser.h:239
static std::unique_ptr< YamlObject > parse(File &file)
Parse a YAML file as a YamlObject.
Definition yaml_parser.cpp:871
Data structures related to geometric objects.
Top-level libcamera namespace.
Definition backtrace.h:17
Transform operator*(Transform t0, Transform t1)
Compose two transforms by applying t0 first then t1.
Definition transform.cpp:209
bool operator==(const ColorSpace &lhs, const ColorSpace &rhs)
Compare color spaces for equality.
Definition color_space.cpp:506