Struct Struct#
Defined in File slint-interpreter.h
Nested Relationships#
Nested Types#
Struct Documentation#
-
struct Struct#
This type represents a runtime instance of structure in
.slint
.This can either be an instance of a name structure introduced with the
struct
keyword in the .slint file, or an anonymous struct written with the{ key: value, }
notation.It can be constructed with the range constructor or initializer lst, and converted into or from a Value with the Value constructor and Value::to_struct().
Public Functions
-
inline Struct()#
Constructs a new empty struct. You can add fields with set_field() and read them with get_field().
-
inline Struct(const Struct &other)#
Creates a new Struct as a copy from other. All fields are copied as well.
-
inline Struct(Struct &&other)#
Creates a new Struct by moving all fields from other into this struct.
-
inline ~Struct()#
Destroys this struct.
-
inline Struct(std::initializer_list<std::pair<std::string_view, Value>> args)#
Creates a new struct with the fields of the std::initializer_list given by args.
-
template<typename InputIterator>
inline Struct(InputIterator it, InputIterator end)# Creates a new struct with the fields produced by the iterator it. it is advanced until it equals end.
-
inline iterator end() const#
Returns an iterator that when compared with an iterator returned by begin() can be used to detect when all fields have been visited.
-
struct iterator#
The Struct::iterator class implements the typical C++ iterator protocol and conveniently provides access to the field names and values of a Struct. It is created by calling either Struct::begin() or Struct::end().
Make sure to compare the iterator to the iterator returned by Struct::end() before de-referencing it. The value returned when de-referencing is a std::pair that holds a std::string_view of the field name as well as a const reference of the value. Both references become invalid when the iterator or the Struct is changed, so make sure to make copies if you want to retain the name or value.
Note that the order in which the iterator exposes the fields is not defined.
If you’re using C++ 17, you can use the convenience destructuring syntax to extract the name and value in one go:
Struct stru = ...; auto it = stru.begin(); ... ++it; // advance iterator to the next field ... // Check iterator before dereferencing it if (it != stru.end()) { // Extract a view of the name and a const reference to the value in one go. auto [field_name, field_value] = *it; }
Public Types
Public Functions
-
inline ~iterator()#
Destroys this field iterator.
-
iterator &operator=(iterator &&other) = default#
Move-assigns the iterator other to this and returns a reference to this.
-
inline iterator &operator++()#
The prefix ++ operator advances the iterator to the next entry and returns a reference to this.
-
inline value_type operator*() const#
Dereferences the iterator to return a pair of the key and value.
-
inline ~iterator()#
-
inline Struct()#