Line data Source code
1 : // Copyright 2024 Accenture.
2 :
3 : #include "transport/LogicalAddress.h"
4 :
5 : #include <etl/algorithm.h>
6 :
7 : namespace transport
8 : {
9 : namespace addressfinder
10 : {
11 : ::etl::optional<LogicalAddress>
12 9 : findDoipAddressInSlice(uint16_t const address, ::etl::span<LogicalAddress const> const& list)
13 : {
14 9 : auto const iter = etl::find_if(
15 : list.begin(),
16 : list.end(),
17 22 : [address](LogicalAddress const addr) -> bool { return addr.addressDoip == address; });
18 9 : if (iter != list.end())
19 : {
20 4 : return *iter;
21 : }
22 5 : return {};
23 : }
24 :
25 : ::etl::optional<LogicalAddress>
26 9 : find8BitAddressInSlice(uint16_t const address, ::etl::span<LogicalAddress const> const& list)
27 : {
28 9 : auto const iter = etl::find_if(
29 : list.begin(),
30 : list.end(),
31 22 : [address](LogicalAddress const addr) -> bool { return addr.address8Bit == address; });
32 9 : if (iter != list.end())
33 : {
34 4 : return *iter;
35 : }
36 5 : return {};
37 : }
38 : } // namespace addressfinder
39 : } // namespace transport
|