Stream wrapper for input of binary data that converts from little-endian to host ordering. */
| 275 | to host ordering. |
| 276 | */ |
| 277 | class ILeStream : public IStream |
| 278 | { |
| 279 | public: |
| 280 | /** |
| 281 | Default constructor. |
| 282 | */ |
| 283 | PDAL_EXPORT ILeStream() |
| 284 | {} |
| 285 | |
| 286 | /** |
| 287 | Constructor that opens the file and maps it to a stream. |
| 288 | |
| 289 | \param filename Filename. |
| 290 | */ |
| 291 | PDAL_EXPORT ILeStream(const std::string& filename) : IStream(filename) |
| 292 | {} |
| 293 | |
| 294 | /** |
| 295 | Constructor that maps to a provided stream. |
| 296 | |
| 297 | \param stream Stream to extract from. |
| 298 | */ |
| 299 | PDAL_EXPORT ILeStream(std::istream *stream) : IStream(stream) |
| 300 | {} |
| 301 | |
| 302 | /** |
| 303 | Extract an unsigned byte from the stream. |
| 304 | |
| 305 | \param v unsigned byte to populate |
| 306 | \return This stream. |
| 307 | */ |
| 308 | PDAL_EXPORT ILeStream& operator >> (uint8_t& v) |
| 309 | { |
| 310 | v = (uint8_t)m_stream->get(); |
| 311 | return *this; |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | Extract an unsigned byte from the stream. |
| 316 | |
| 317 | \param v unsigned byte to populate |
| 318 | \return This stream. |
| 319 | */ |
| 320 | PDAL_EXPORT ILeStream& operator >> (int8_t& v) |
| 321 | { |
| 322 | v = (int8_t)m_stream->get(); |
| 323 | return *this; |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | Extract an unsigned short from the stream. |
| 328 | |
| 329 | \param v unsigned short to populate |
| 330 | \return This stream. |
| 331 | */ |
| 332 | PDAL_EXPORT ILeStream& operator >> (uint16_t& v) |
| 333 | { |
| 334 | m_stream->read((char *)&v, sizeof(v)); |