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 Input& other, const Input& old_base, const Input& new_base) |
| 20 : data_(other.data_ ? new_base.data_ + (other.data_ - old_base.data_) |
| 21 : nullptr), |
| 22 len_(other.len_) { |
| 23 if (other.data_) { |
| 24 DCHECK_EQ(new_base.len_, old_base.len_); |
| 25 DCHECK_GE(data_, new_base.data_); |
| 26 DCHECK_LE(data_ + len_, new_base.data_ + new_base.len_); |
| 27 } |
| 28 DCHECK(*this == other); |
| 29 } |
| 30 |
19 Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) { | 31 Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) { |
20 } | 32 } |
21 | 33 |
22 Input::Input(const base::StringPiece& in) | 34 Input::Input(const base::StringPiece& in) |
23 : data_(reinterpret_cast<const uint8_t*>(in.data())), len_(in.length()) {} | 35 : data_(reinterpret_cast<const uint8_t*>(in.data())), len_(in.length()) {} |
24 | 36 |
25 Input::Input(const std::string* s) : Input(base::StringPiece(*s)) {} | 37 Input::Input(const std::string* s) : Input(base::StringPiece(*s)) {} |
26 | 38 |
27 std::string Input::AsString() const { | 39 std::string Input::AsString() const { |
28 return std::string(reinterpret_cast<const char*>(data_), len_); | 40 return std::string(reinterpret_cast<const char*>(data_), len_); |
(...skipping 83 matching lines...) Loading... |
112 | 124 |
113 Mark::Mark(const uint8_t* ptr) : ptr_(ptr) { | 125 Mark::Mark(const uint8_t* ptr) : ptr_(ptr) { |
114 } | 126 } |
115 | 127 |
116 Mark::Mark() : ptr_(nullptr) { | 128 Mark::Mark() : ptr_(nullptr) { |
117 } | 129 } |
118 | 130 |
119 } // namespace der | 131 } // namespace der |
120 | 132 |
121 } // namespace net | 133 } // namespace net |
OLD | NEW |