| 606 | } |
| 607 | |
| 608 | double SourceDestBufferImpl::getNextDouble() |
| 609 | { |
| 610 | /// don't checkImageFileOpen |
| 611 | |
| 612 | /// Verify index is within bounds |
| 613 | if ( nextIndex_ >= capacity_ ) |
| 614 | { |
| 615 | throw E57_EXCEPTION2( ErrorInternal, "pathName=" + pathName_ ); |
| 616 | } |
| 617 | |
| 618 | /// Fetch value from source buffer. |
| 619 | /// Convert from other formats to floating point if requested |
| 620 | char *p = &base_[nextIndex_ * stride_]; |
| 621 | double value; |
| 622 | switch ( memoryRepresentation_ ) |
| 623 | { |
| 624 | case Int8: |
| 625 | if ( !doConversion_ ) |
| 626 | { |
| 627 | throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ ); |
| 628 | } |
| 629 | value = static_cast<double>( *reinterpret_cast<int8_t *>( p ) ); |
| 630 | break; |
| 631 | case UInt8: |
| 632 | if ( !doConversion_ ) |
| 633 | { |
| 634 | throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ ); |
| 635 | } |
| 636 | value = static_cast<double>( *reinterpret_cast<uint8_t *>( p ) ); |
| 637 | break; |
| 638 | case Int16: |
| 639 | if ( !doConversion_ ) |
| 640 | { |
| 641 | throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ ); |
| 642 | } |
| 643 | value = static_cast<double>( *reinterpret_cast<int16_t *>( p ) ); |
| 644 | break; |
| 645 | case UInt16: |
| 646 | if ( !doConversion_ ) |
| 647 | { |
| 648 | throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ ); |
| 649 | } |
| 650 | value = static_cast<double>( *reinterpret_cast<uint16_t *>( p ) ); |
| 651 | break; |
| 652 | case Int32: |
| 653 | if ( !doConversion_ ) |
| 654 | { |
| 655 | throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ ); |
| 656 | } |
| 657 | value = static_cast<double>( *reinterpret_cast<int32_t *>( p ) ); |
| 658 | break; |
| 659 | case UInt32: |
| 660 | if ( !doConversion_ ) |
| 661 | { |
| 662 | throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ ); |
| 663 | } |
| 664 | value = static_cast<double>( *reinterpret_cast<uint32_t *>( p ) ); |
| 665 | break; |