OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/der/input.h" | 10 #include "net/der/input.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 namespace der { | 14 namespace der { |
15 | 15 |
16 Input::Input() : data_(nullptr), len_(0) { | 16 Input::Input() : data_(nullptr), len_(0) { |
17 } | 17 } |
18 | 18 |
19 Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) { | 19 Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) { |
20 } | 20 } |
21 | 21 |
22 Input::Input(const base::StringPiece& in) | 22 Input::Input(const base::StringPiece& in) |
23 : data_(reinterpret_cast<const uint8_t*>(in.data())), len_(in.length()) {} | 23 : data_(reinterpret_cast<const uint8_t*>(in.data())), len_(in.length()) {} |
24 | 24 |
25 Input::Input(const std::string* s) : Input(base::StringPiece(*s)) {} | 25 Input::Input(const std::string* s) : Input(base::StringPiece(*s)) {} |
26 | 26 |
27 bool Input::Equals(const Input& other) const { | 27 bool Input::operator==(const Input& other) const { |
28 if (len_ != other.len_) | 28 if (len_ != other.len_) |
29 return false; | 29 return false; |
30 return memcmp(data_, other.data_, len_) == 0; | 30 return memcmp(data_, other.data_, len_) == 0; |
31 } | 31 } |
32 | 32 |
| 33 bool Input::operator!=(const Input& other) const { |
| 34 return !(*this == other); |
| 35 } |
| 36 |
33 std::string Input::AsString() const { | 37 std::string Input::AsString() const { |
34 return std::string(reinterpret_cast<const char*>(data_), len_); | 38 return std::string(reinterpret_cast<const char*>(data_), len_); |
35 } | 39 } |
36 | 40 |
37 base::StringPiece Input::AsStringPiece() const { | 41 base::StringPiece Input::AsStringPiece() const { |
38 return base::StringPiece(reinterpret_cast<const char*>(data_), len_); | 42 return base::StringPiece(reinterpret_cast<const char*>(data_), len_); |
39 } | 43 } |
40 | 44 |
41 bool operator<(const Input& lhs, const Input& rhs) { | 45 bool operator<(const Input& lhs, const Input& rhs) { |
42 return std::lexicographical_compare( | 46 return std::lexicographical_compare( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 112 |
109 Mark::Mark(const uint8_t* ptr) : ptr_(ptr) { | 113 Mark::Mark(const uint8_t* ptr) : ptr_(ptr) { |
110 } | 114 } |
111 | 115 |
112 Mark::Mark() : ptr_(nullptr) { | 116 Mark::Mark() : ptr_(nullptr) { |
113 } | 117 } |
114 | 118 |
115 } // namespace der | 119 } // namespace der |
116 | 120 |
117 } // namespace net | 121 } // namespace net |
OLD | NEW |