MCPcopy Create free account
hub / github.com/PDAL/PDAL / getBytestream

Method getBytestream

plugins/e57/libE57Format/src/Packet.cpp:438–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438char *DataPacket::getBytestream( unsigned bytestreamNumber, unsigned &byteCount )
439{
440#ifdef E57_VERBOSE
441 std::cout << "getBytestream called, bytestreamNumber=" << bytestreamNumber << std::endl;
442#endif
443
444 // Verify that packet is correct type
445 if ( header.packetType != DATA_PACKET )
446 {
447 throw E57_EXCEPTION2( ErrorBadCVPacket, "packetType=" + toString( header.packetType ) );
448 }
449
450 // Check bytestreamNumber in bounds
451 if ( bytestreamNumber >= header.bytestreamCount )
452 {
453 throw E57_EXCEPTION2( ErrorInternal,
454 "bytestreamNumber=" + toString( bytestreamNumber ) +
455 " bytestreamCount=" + toString( header.bytestreamCount ) );
456 }
457
458 // Calc positions in packet
459 auto bsbLength = reinterpret_cast<uint16_t *>( &payload[0] );
460 auto streamBase = reinterpret_cast<char *>( &bsbLength[header.bytestreamCount] );
461
462 // Sum size of preceding stream buffers to get position
463 unsigned totalPreceding = 0;
464 for ( unsigned i = 0; i < bytestreamNumber; i++ )
465 {
466 totalPreceding += bsbLength[i];
467 }
468
469 byteCount = bsbLength[bytestreamNumber];
470
471 // Double check buffer is completely within packet
472 if ( ( sizeof( DataPacketHeader ) + 2 * header.bytestreamCount + totalPreceding + byteCount ) >
473 header.packetLogicalLengthMinus1 + 1U )
474 {
475 throw E57_EXCEPTION2( ErrorInternal, "bytestreamCount=" + toString( header.bytestreamCount ) +
476 " totalPreceding=" + toString( totalPreceding ) +
477 " byteCount=" + toString( byteCount ) +
478 " packetLogicalLengthMinus1=" +
479 toString( header.packetLogicalLengthMinus1 ) );
480 }
481
482 // Return start of buffer
483 return ( &streamBase[totalPreceding] );
484}
485
486unsigned DataPacket::getBytestreamBufferLength( unsigned bytestreamNumber )
487{

Callers 1

feedPacketToDecodersMethod · 0.80

Calls 1

toStringFunction · 0.70

Tested by

no test coverage detected