Line data Source code
1 : #pragma once 2 : 3 : // This component provides an interface, `DictReader`, that represents a 4 : // read-only key/value mapping of strings. It's used when extracting trace 5 : // context from externalized formats: HTTP headers, gRPC metadata, etc. 6 : 7 : #include <functional> 8 : 9 : #include "optional.h" 10 : #include "string_view.h" 11 : 12 : namespace datadog { 13 : namespace tracing { 14 : 15 : class DictReader { 16 : public: 17 637 : virtual ~DictReader() {} 18 : 19 : // Return the value at the specified `key`, or return `nullopt` if there 20 : // is no value at `key`. 21 : virtual Optional<StringView> lookup(StringView key) const = 0; 22 : 23 : // Invoke the specified `visitor` once for each key/value pair in this object. 24 : virtual void visit( 25 : const std::function<void(StringView key, StringView value)>& visitor) 26 : const = 0; 27 : }; 28 : 29 : } // namespace tracing 30 : } // namespace datadog