Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/stream_info/uint32_accessor.h" 4 : 5 : namespace Envoy { 6 : namespace StreamInfo { 7 : 8 : /* 9 : * A FilterState object that tracks a single uint32_t value. 10 : */ 11 : class UInt32AccessorImpl : public UInt32Accessor { 12 : public: 13 0 : UInt32AccessorImpl(uint32_t value) : value_(value) {} 14 : 15 : // From FilterState::Object 16 0 : ProtobufTypes::MessagePtr serializeAsProto() const override { 17 0 : auto message = std::make_unique<ProtobufWkt::UInt32Value>(); 18 0 : message->set_value(value_); 19 0 : return message; 20 0 : } 21 0 : absl::optional<std::string> serializeAsString() const override { return absl::StrCat(value_); } 22 : 23 : // From UInt32Accessor. 24 0 : void increment() override { value_++; } 25 0 : uint32_t value() const override { return value_; } 26 : 27 : private: 28 : uint32_t value_; 29 : }; 30 : 31 : } // namespace StreamInfo 32 : } // namespace Envoy