1
#pragma once
2

            
3
#include "envoy/stream_info/uint64_accessor.h"
4

            
5
namespace Envoy {
6
namespace StreamInfo {
7

            
8
/*
9
 * A FilterState object that tracks a single uint64_t value.
10
 */
11
class UInt64AccessorImpl : public UInt64Accessor {
12
public:
13
9
  UInt64AccessorImpl(uint64_t value) : value_(value) {}
14

            
15
  // From FilterState::Object
16
1
  ProtobufTypes::MessagePtr serializeAsProto() const override {
17
1
    auto message = std::make_unique<Protobuf::UInt64Value>();
18
1
    message->set_value(value_);
19
1
    return message;
20
1
  }
21

            
22
4
  absl::optional<std::string> serializeAsString() const override { return std::to_string(value_); }
23

            
24
  // From UInt64Accessor.
25
1
  void increment() override { value_++; }
26
4
  uint64_t value() const override { return value_; }
27

            
28
private:
29
  uint64_t value_;
30
};
31

            
32
} // namespace StreamInfo
33
} // namespace Envoy