]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | // Copyright The OpenTelemetry Authors |
2 | // SPDX-License-Identifier: Apache-2.0 | |
3 | ||
4 | #pragma once | |
5 | ||
6 | #include "opentelemetry/common/attribute_value.h" | |
7 | #include "opentelemetry/nostd/function_ref.h" | |
8 | #include "opentelemetry/version.h" | |
9 | ||
10 | OPENTELEMETRY_BEGIN_NAMESPACE | |
11 | namespace common | |
12 | { | |
13 | /** | |
14 | * Supports internal iteration over a collection of key-value pairs. | |
15 | */ | |
16 | class KeyValueIterable | |
17 | { | |
18 | public: | |
19 | virtual ~KeyValueIterable() = default; | |
20 | ||
21 | /** | |
22 | * Iterate over key-value pairs | |
23 | * @param callback a callback to invoke for each key-value. If the callback returns false, | |
24 | * the iteration is aborted. | |
25 | * @return true if every key-value pair was iterated over | |
26 | */ | |
27 | virtual bool ForEachKeyValue(nostd::function_ref<bool(nostd::string_view, common::AttributeValue)> | |
28 | callback) const noexcept = 0; | |
29 | ||
30 | /** | |
31 | * @return the number of key-value pairs | |
32 | */ | |
33 | virtual size_t size() const noexcept = 0; | |
34 | }; | |
35 | } // namespace common | |
36 | OPENTELEMETRY_END_NAMESPACE |