Class DisplayConfiguration::Node

Nested Relationships

This class is a nested type of Class DisplayConfiguration.

Class Documentation

class Node

A class providing access to an arbitrary piece of data from the miral::DisplayConfiguration.

This is specifically useful when a user wants to extend the basic display configuration with some sort of custom payload (e.g. a user may want to extend the layout configuration with information describing the position and size of specific applications).

Remark

Since MirAL 5.3

Public Types

enum class Type

Values:

enumerator integer
enumerator string
enumerator sequence
enumerator map
enumerator unknown

Public Functions

Type type() const

The type of the node.

Once resolved, the user can call the appropriate methods on the object. For example, if the type is #Type::string, users can safely call as_string.

Returns:

the node type

std::string as_string() const

Returns the content of the node as a std::string.

If the node does not have a type of #Type::string, this will cause a fatal error.

Returns:

the node as a string

int as_int() const

If the node does not have a type of #Type::integer, this will cause a fatal error.

Returns:

the node as an integer

void for_each(std::function<void(Node const&)> const &f) const

Iterate over the children of this node.

If the node does not have a type of #Type::sequence, this will cause a fatal error.

Parameters:

f – function to all on each child node

bool has(std::string const &key) const

Check if the node has a value at the given key.

If the node does not have a type of #Type::map, this will cause a fatal error.

Parameters:

key – the key to check for existence

Returns:

true if the key exists, otherwise false

std::optional<Node> at(std::string const &key) const

Get the node at the given key.

If the node does not have a type of #Type::map, this will cause a fatal error.

Parameters:

key – the key to get

Returns:

the node at the key, or std::nullopt if none exists

Node(Node&&) noexcept
Node &operator=(Node&&) noexcept
Node(Node const&) = delete
Node &operator=(Node const&) = delete
~Node()