blob: cb22f51528beb0dd32d3004781596266051028f0 [file] [log] [blame]
QUICHE teamfd50a402018-12-07 22:54:05 -05001// 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#include "net/third_party/quiche/src/http2/hpack/hpack_string.h"
6
7#include <utility>
8
QUICHE team61940b42019-03-07 23:32:27 -05009#include "net/third_party/quiche/src/http2/platform/api/http2_logging.h"
bnc252403d2020-01-15 08:39:53 -080010#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h"
QUICHE teamfd50a402018-12-07 22:54:05 -050011
12namespace http2 {
13
14HpackString::HpackString(const char* data) : str_(data) {}
bnc74646d12019-12-13 09:21:19 -080015HpackString::HpackString(quiche::QuicheStringPiece str)
16 : str_(std::string(str)) {}
bnc47904002019-08-16 11:49:48 -070017HpackString::HpackString(std::string str) : str_(std::move(str)) {}
QUICHE teamfd50a402018-12-07 22:54:05 -050018HpackString::HpackString(const HpackString& other) = default;
19HpackString::~HpackString() = default;
20
bnc74646d12019-12-13 09:21:19 -080021quiche::QuicheStringPiece HpackString::ToStringPiece() const {
QUICHE teamfd50a402018-12-07 22:54:05 -050022 return str_;
23}
24
25bool HpackString::operator==(const HpackString& other) const {
26 return str_ == other.str_;
27}
bnc74646d12019-12-13 09:21:19 -080028bool HpackString::operator==(quiche::QuicheStringPiece str) const {
QUICHE teamfd50a402018-12-07 22:54:05 -050029 return str == str_;
30}
31
bnc74646d12019-12-13 09:21:19 -080032bool operator==(quiche::QuicheStringPiece a, const HpackString& b) {
QUICHE teamfd50a402018-12-07 22:54:05 -050033 return b == a;
34}
bnc74646d12019-12-13 09:21:19 -080035bool operator!=(quiche::QuicheStringPiece a, const HpackString& b) {
QUICHE teamfd50a402018-12-07 22:54:05 -050036 return !(b == a);
37}
38bool operator!=(const HpackString& a, const HpackString& b) {
39 return !(a == b);
40}
bnc74646d12019-12-13 09:21:19 -080041bool operator!=(const HpackString& a, quiche::QuicheStringPiece b) {
QUICHE teamfd50a402018-12-07 22:54:05 -050042 return !(a == b);
43}
44std::ostream& operator<<(std::ostream& out, const HpackString& v) {
45 return out << v.ToString();
46}
47
48HpackStringPair::HpackStringPair(const HpackString& name,
49 const HpackString& value)
50 : name(name), value(value) {
QUICHE team61940b42019-03-07 23:32:27 -050051 HTTP2_DVLOG(3) << DebugString() << " ctor";
QUICHE teamfd50a402018-12-07 22:54:05 -050052}
53
bnc74646d12019-12-13 09:21:19 -080054HpackStringPair::HpackStringPair(quiche::QuicheStringPiece name,
55 quiche::QuicheStringPiece value)
QUICHE teamfd50a402018-12-07 22:54:05 -050056 : name(name), value(value) {
QUICHE team61940b42019-03-07 23:32:27 -050057 HTTP2_DVLOG(3) << DebugString() << " ctor";
QUICHE teamfd50a402018-12-07 22:54:05 -050058}
59
60HpackStringPair::~HpackStringPair() {
QUICHE team61940b42019-03-07 23:32:27 -050061 HTTP2_DVLOG(3) << DebugString() << " dtor";
QUICHE teamfd50a402018-12-07 22:54:05 -050062}
63
bnc47904002019-08-16 11:49:48 -070064std::string HpackStringPair::DebugString() const {
bnc252403d2020-01-15 08:39:53 -080065 return quiche::QuicheStrCat("HpackStringPair(name=", name.ToString(),
66 ", value=", value.ToString(), ")");
QUICHE teamfd50a402018-12-07 22:54:05 -050067}
68
69std::ostream& operator<<(std::ostream& os, const HpackStringPair& p) {
70 os << p.DebugString();
71 return os;
72}
73
74} // namespace http2