| 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 #ifndef NET_DER_INPUT_H_ | 5 #ifndef NET_DER_INPUT_H_ |
| 6 #define NET_DER_INPUT_H_ | 6 #define NET_DER_INPUT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 // Return true if the Input's data and |other|'s data are byte-wise equal. | 55 // Return true if the Input's data and |other|'s data are byte-wise equal. |
| 56 bool Equals(const Input& other) const; | 56 bool Equals(const Input& other) const; |
| 57 | 57 |
| 58 // Returns a pointer to the Input's data. This method is marked as "unsafe" | 58 // Returns a pointer to the Input's data. This method is marked as "unsafe" |
| 59 // because access to the Input's data should be done through ByteReader | 59 // because access to the Input's data should be done through ByteReader |
| 60 // instead. This method should only be used where using a ByteReader truly | 60 // instead. This method should only be used where using a ByteReader truly |
| 61 // is not an option. | 61 // is not an option. |
| 62 const uint8_t* UnsafeData() const { return data_; } | 62 const uint8_t* UnsafeData() const { return data_; } |
| 63 | 63 |
| 64 // Returns a copy of the data represented by this object as a std::string. |
| 65 std::string AsString() const; |
| 66 |
| 64 private: | 67 private: |
| 65 const uint8_t* data_; | 68 const uint8_t* data_; |
| 66 size_t len_; | 69 size_t len_; |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 // This class provides ways to read data from an Input in a bounds-checked way. | 72 // This class provides ways to read data from an Input in a bounds-checked way. |
| 70 // The ByteReader is designed to read through the input sequentially. Once a | 73 // The ByteReader is designed to read through the input sequentially. Once a |
| 71 // byte has been read with a ByteReader, the caller can't go back and re-read | 74 // byte has been read with a ByteReader, the caller can't go back and re-read |
| 72 // that byte with the same reader. Of course, the caller can create multiple | 75 // that byte with the same reader. Of course, the caller can create multiple |
| 73 // ByteReaders for the same input (or copy an existing ByteReader). | 76 // ByteReaders for the same input (or copy an existing ByteReader). |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 explicit Mark(const uint8_t* ptr); | 151 explicit Mark(const uint8_t* ptr); |
| 149 Mark(); | 152 Mark(); |
| 150 const uint8_t* ptr_; | 153 const uint8_t* ptr_; |
| 151 }; | 154 }; |
| 152 | 155 |
| 153 } // namespace der | 156 } // namespace der |
| 154 | 157 |
| 155 } // namespace net | 158 } // namespace net |
| 156 | 159 |
| 157 #endif // NET_DER_INPUT_H_ | 160 #endif // NET_DER_INPUT_H_ |
| OLD | NEW |