Namespaces

Enumerations

enum ScanState
Name Value
kDone 0
kDoneWithSubtree 1
kActive 2
kNeedsPathResolution 3

Forward-declaration.

Defined at line 34 of file ../../zircon/kernel/lib/devicetree/include/lib/devicetree/matcher.h

Records

Functions

  • template <Matcher... Matchers>
    bool Match (const devicetree::Devicetree & devicetreeMatchers &&... matchers)

    Returns true if all `matchers` completed successfully.

    Usage example:

    ```

    // Assume |dt| is a |devicetree::Devicetree| object.

    struct FooMatcher {

    constexpr size_t kMaxScans = 1;

    ScanState OnNode(const NodePath

    &

    path, const PropertyDecoder

    &

    decoder) {

    if (path.back() == "foo") {

    foo_count++;

    subtree_start_ =

    &path

    .back();

    return ScanState::kActive;

    }

    }

    ScanState OnSubtree(const NodePath

    &

    path) {

    if (

    &path

    .back() == subtree_start_) {

    // All childs of |subtree_start_| have been visited.

    }

    }

    ScanState OnScan() {

    return ScanState::kDone;

    }

    void OnDone() {}

    void OnError(std::string_view err) {

    std::cout

    <

    <

    " Foo Matcher had an error: "

    <

    <

    err

    <

    <

    std::endl;

    }

    int foo_count = 0;

    }

    ...

    FooMatcher foo_matcher;

    if (!devicetree::Match(dt, foo_matcher)) {

    return;

    }

    std::cout

    <

    <

    " Nodes names foo: "

    <

    <

    foo_matcher.foo_count

    <

    <

    std::endl;

    ```

    Defined at line 147 of file ../../zircon/kernel/lib/devicetree/include/lib/devicetree/matcher.h

Concepts

template <typename T> UnsignedIntegralConstant std::unsigned_integral<std::remove_reference_t<T> > && std::is_const_v<std::remove_reference_t<T> >

Helper concept.

Defined at line 49 of file ../../zircon/kernel/lib/devicetree/include/lib/devicetree/matcher.h

template <typename MatcherType> MatcherImpl requires (MatcherType matcher, const NodePath &path, const PropertyDecoder &decoder, std::string_view error_message) { { MatcherType::kMaxScans } -> UnsignedIntegralConstant; { std::integral_constant<size_t, MatcherType::kMaxScans>{} }; { matcher.OnNode(path, decoder) } -> std::same_as<ScanState>; { matcher.OnSubtree(path) } -> std::convertible_to<ScanState>; { matcher.OnScan() } -> std::convertible_to<ScanState>; { matcher.OnDone() }; { matcher.OnError(error_message) } -> std::same_as<void>; } && MatcherType::kMaxScans > 0

A `Matcher` type object must follow the following compile time contract and is meant

to be used in conjunction with `Devicetree::Match`.

Defined at line 55 of file ../../zircon/kernel/lib/devicetree/include/lib/devicetree/matcher.h

template <typename T> Matcher MatcherImpl<std::decay_t<T> >

Defined at line 90 of file ../../zircon/kernel/lib/devicetree/include/lib/devicetree/matcher.h

template <typename T> OkNodeMatcher Matcher<T> && requires { { std::bool_constant<std::decay_t<T>::kMatchOkNodesOnly>{} }; } && T::kMatchOkNodesOnly

`OkNodeMatcher` fulfills the `Matcher` concept, but declares that is only interested

in visiting nodes whose status is `okay` or equivalent.

To achieve this a `OkNodeMatcher` implementation must define a constexpr bool member

`kMatchOkNodesOnly` as true.

Defined at line 98 of file ../../zircon/kernel/lib/devicetree/include/lib/devicetree/matcher.h