proxygen
Logging.cpp
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  */
11 
12 #include <sstream>
13 
14 using std::ostream;
15 using std::string;
16 using std::stringstream;
17 using std::vector;
18 
19 namespace proxygen {
20 
21 ostream& operator<<(ostream& os, const std::list<uint32_t>* refset) {
22  os << std::endl << '[';
23  for (auto& ref : *refset) {
24  os << ref << ' ';
25  }
26  os << ']' << std::endl;
27  return os;
28 }
29 
30 std::ostream& operator<<(std::ostream& os, const std::vector<HPACKHeader>& v) {
31  for (const auto &h : v) {
32  os << h.name << ": " << h.value << std::endl;
33  }
34  os << std::endl;
35  return os;
36 }
37 
38 string printDelta(const vector<HPACKHeader> &v1,
39  const vector<HPACKHeader> &v2) {
40  stringstream out;
41  // similar with merge operation
42  size_t i = 0;
43  size_t j = 0;
44  out << std::endl;
45  while (i < v1.size() && j < v2.size()) {
46  if (v1[i] < v2[j]) {
47  if (i > 0 && v1[i - 1] == v1[i]) {
48  out << " duplicate " << v1[i] << std::endl;
49  } else {
50  out << " + " << v1[i] << std::endl;
51  }
52  i++;
53  } else if (v1[i] > v2[j]) {
54  out << " - " << v2[j] << std::endl;
55  j++;
56  } else {
57  i++;
58  j++;
59  }
60  }
61  while (i < v1.size()) {
62  out << " + " << v1[i];
63  if (i > 0 && v1[i - 1] == v1[i]) {
64  out << " (duplicate)";
65  }
66  out << std::endl;
67  i++;
68  }
69  while (j < v2.size()) {
70  out << " - " << v2[j] << std::endl;
71  j++;
72  }
73  return out.str();
74 }
75 
76 }
*than *hazptr_holder h
Definition: Hazptr.h:116
auto v
string printDelta(const vector< HPACKHeader > &v1, const vector< HPACKHeader > &v2)
Definition: Logging.cpp:38
const char * string
Definition: Conv.cpp:212