proxygen
HPACKHeader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <folly/Conv.h>
13 #include <ostream>
14 #include <string>
16 #include <folly/FBString.h>
17 
18 namespace proxygen {
19 
20 class HPACKHeader {
21  public:
22  static const uint32_t kMinLength = 32;
23 
25 
27  const folly::fbstring& value_):
28  name(name_), value(value_) {}
29 
31  folly::StringPiece value_):
32  name(name_), value(value_.data(), value_.size()) {}
33 
35  : name(std::move(goner.name)),
36  value(std::move(goner.value)) {}
37 
39  std::swap(name, goner.name);
40  std::swap(value, goner.value);
41  return *this;
42  }
43 
45 
49  uint32_t bytes() const {
50  return folly::to<uint32_t>(kMinLength + name.size() + value.size());
51  }
52 
53  bool operator==(const HPACKHeader& other) const {
54  return name == other.name && value == other.value;
55  }
56  bool operator<(const HPACKHeader& other) const {
57  bool eqname = (name == other.name);
58  if (!eqname) {
59  return name < other.name;
60  }
61  return value < other.value;
62  }
63  bool operator>(const HPACKHeader& other) const {
64  bool eqname = (name == other.name);
65  if (!eqname) {
66  return name > other.name;
67  }
68  return value > other.value;
69  }
70 
71  HPACKHeader copy() const {
72  return HPACKHeader(name, value);
73  }
74 
78  bool hasValue() const {
79  return !value.empty();
80  }
81 
84 };
85 
86 std::ostream& operator<<(std::ostream& os, const HPACKHeader& h);
87 
88 }
size_type size() const
Definition: FBString.h:1337
HPACKHeader(const HPACKHeaderName &name_, const folly::fbstring &value_)
Definition: HPACKHeader.h:26
*than *hazptr_holder h
Definition: Hazptr.h:116
bool empty() const
Definition: FBString.h:1372
bool operator<(const HPACKHeader &other) const
Definition: HPACKHeader.h:56
std::ostream & operator<<(std::ostream &os, const HeaderTable &table)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
HPACKHeader(HPACKHeader &&goner) noexcept
Definition: HPACKHeader.h:34
HPACKHeader & operator=(HPACKHeader &&goner) noexcept
Definition: HPACKHeader.h:38
requires E e noexcept(noexcept(s.error(std::move(e))))
static const uint32_t kMinLength
Definition: HPACKHeader.h:22
uint32_t bytes() const
Definition: HPACKHeader.h:49
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
HPACKHeaderName name
Definition: HPACKHeader.h:82
bool operator==(const HPACKHeader &other) const
Definition: HPACKHeader.h:53
folly::fbstring value
Definition: HPACKHeader.h:83
HPACKHeader(folly::StringPiece name_, folly::StringPiece value_)
Definition: HPACKHeader.h:30
bool hasValue() const
Definition: HPACKHeader.h:78
HPACKHeader copy() const
Definition: HPACKHeader.h:71
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414
bool operator>(const HPACKHeader &other) const
Definition: HPACKHeader.h:63
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
std::string name_
Definition: gtest.cc:2607