Returns a std::string containing |num_bytes| of input data. Using this and |.c_str()| on the resulting string is the best way to get an immutable null-terminated C string. If fewer than |num_bytes| of data remain, returns a shorter std::string containing all of the data that's left.
| 134 | // null-terminated C string. If fewer than |num_bytes| of data remain, returns |
| 135 | // a shorter std::string containing all of the data that's left. |
| 136 | inline std::string FuzzedDataProvider::ConsumeBytesAsString(size_t num_bytes) { |
| 137 | static_assert(sizeof(std::string::value_type) == sizeof(uint8_t), |
| 138 | "ConsumeBytesAsString cannot convert the data to a string."); |
| 139 | |
| 140 | num_bytes = std::min(num_bytes, remaining_bytes_); |
| 141 | std::string result( |
| 142 | reinterpret_cast<const std::string::value_type *>(data_ptr_), num_bytes); |
| 143 | Advance(num_bytes); |
| 144 | return result; |
| 145 | } |
| 146 | |
| 147 | // Returns a std::string of length from 0 to |max_length|. When it runs out of |
| 148 | // input data, returns what remains of the input. Designed to be more stable |
no outgoing calls
no test coverage detected