#pragma once #include #include #include #include #include namespace KAFKA_API { /** * Message Header (with a key value pair) */ struct Header { using Key = std::string; using Value = ConstBuffer; Header() = default; Header(Key k, Value v): key(std::move(k)), value(v) {} /** * Obtains explanatory string. */ std::string toString() const { return key + ":" + value.toString(); } Key key; Value value; }; /** * Message Headers. */ using Headers = std::vector
; /** * Null Headers. */ #if COMPILER_SUPPORTS_CPP_17 const inline Headers NullHeaders = Headers{}; #else const static Headers NullHeaders = Headers{}; #endif /** * Obtains explanatory string for Headers. */ inline std::string toString(const Headers& headers) { std::string ret; std::for_each(headers.cbegin(), headers.cend(), [&ret](const auto& header) { ret.append(ret.empty() ? "" : ",").append(header.toString()); }); return ret; } } // end of KAFKA_API