Fetch data from the stream into a string. NOTE - Stops when a null byte is encountered. Use a buffer/vector reader to read data with embedded nulls. \param s String to fill. \param size Maximum number of bytes to extract. */
| 211 | \param size Maximum number of bytes to extract. |
| 212 | */ |
| 213 | PDAL_EXPORT void get(std::string& s, size_t size) |
| 214 | { |
| 215 | // Could do this by appending to a string with a stream, but this |
| 216 | // is probably fast enough for now (there's only a simple increment |
| 217 | // to advance an istream iterator, which you'd have to call in a loop). |
| 218 | |
| 219 | // Zero-fill for null termination and to avoid reading uninitiallized |
| 220 | // memory when, for example, trying to read an empty file. |
| 221 | std::vector<char> buf(size + 1, 0); |
| 222 | m_stream->read(buf.data(), size); |
| 223 | s = buf.data(); |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | Fetch data from the stream into a vector of char. |
no test coverage detected