xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/http2/hpack/varint/hpack_varint_encoder.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef QUICHE_HTTP2_HPACK_VARINT_HPACK_VARINT_ENCODER_H_
6 #define QUICHE_HTTP2_HPACK_VARINT_HPACK_VARINT_ENCODER_H_
7 
8 #include <cstddef>
9 #include <cstdint>
10 #include <string>
11 
12 #include "quiche/common/platform/api/quiche_export.h"
13 
14 namespace http2 {
15 
16 // HPACK integer encoder class with single static method implementing variable
17 // length integer representation defined in RFC7541, Section 5.1:
18 // https://httpwg.org/specs/rfc7541.html#integer.representation
19 class QUICHE_EXPORT HpackVarintEncoder {
20  public:
21   // Encode |varint|, appending encoded data to |*output|.
22   // Appends between 1 and 11 bytes in total.
23   static void Encode(uint8_t high_bits, uint8_t prefix_length, uint64_t varint,
24                      std::string* output);
25 };
26 
27 }  // namespace http2
28 
29 #endif  // QUICHE_HTTP2_HPACK_VARINT_HPACK_VARINT_ENCODER_H_
30