Program Listing for File key_value_iterable.h
↰ Return to documentation for file (/tmp/B.puc0r6hi/BUILD/opentelemetry-cpp-1.27.0-build/opentelemetry-cpp-1.27.0/api/include/opentelemetry/common/key_value_iterable.h)
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
{
class KeyValueIterable
{
public:
KeyValueIterable() = default;
KeyValueIterable(const KeyValueIterable &) = default;
KeyValueIterable &operator=(const KeyValueIterable &) = default;
KeyValueIterable(KeyValueIterable &&) noexcept = default;
KeyValueIterable &operator=(KeyValueIterable &&) noexcept = default;
virtual ~KeyValueIterable() = default;
virtual bool ForEachKeyValue(nostd::function_ref<bool(nostd::string_view, common::AttributeValue)>
callback) const noexcept = 0;
virtual size_t size() const noexcept = 0;
};
class NoopKeyValueIterable : public KeyValueIterable
{
public:
bool ForEachKeyValue(
nostd::function_ref<bool(nostd::string_view, common::AttributeValue)> /*callback*/)
const noexcept override
{
return true;
}
size_t size() const noexcept override { return 0; }
};
} // namespace common
OPENTELEMETRY_END_NAMESPACE