From 83d33c9fead1a77ef17b5900ee98453b76b40371 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Tue, 2 Jun 2020 17:01:45 -0400 Subject: [PATCH] Fix building with E57_MAX_VERBOSE defined (#44) Also turns on E57_MAX_VERBOSE for debug builds in the CI --- .github/workflows/build.yml | 6 +-- .travis.yml | 2 +- src/CheckedFile.cpp | 4 +- src/Decoder.cpp | 72 +++++++++++++++++-------------- src/E57FormatImpl.cpp | 85 ++++++++++++++++++++----------------- src/E57XmlParser.cpp | 40 ++++++++--------- src/Encoder.cpp | 82 ++++++++++++++++++----------------- src/ImageFileImpl.cpp | 4 +- src/StructureNodeImpl.cpp | 9 ++-- 9 files changed, 162 insertions(+), 142 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fe11ad..7f99b80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,17 +16,14 @@ jobs: - { name: "macOS Clang", os: macos-latest, - generator: "Ninja", } - { name: "Ubuntu GCC", os: ubuntu-latest, - generator: "Ninja", } - { name: "Windows MSVC", os: windows-latest, - generator: "Ninja", } steps: @@ -75,8 +72,9 @@ jobs: cmake -B libE57Format-build - -G "${{ matrix.config.generator }}" + -G "Ninja" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_CXX_FLAGS_DEBUG="-g -DE57_MAX_VERBOSE" . - name: Build diff --git a/.travis.yml b/.travis.yml index 0dc1671..cecd002 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ addons: before_script: - mkdir build-${BUILD_TYPE} - cd build-${BUILD_TYPE} - - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} .. + - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_FLAGS_DEBUG="-g -DE57_MAX_VERBOSE" .. script: - if [[ "${COVERITY_SCAN_BRANCH}" != 1 ]]; then diff --git a/src/CheckedFile.cpp b/src/CheckedFile.cpp index ce0be80..b35ebf6 100644 --- a/src/CheckedFile.cpp +++ b/src/CheckedFile.cpp @@ -377,7 +377,7 @@ CheckedFile &CheckedFile::operator<<( double d ) template CheckedFile &CheckedFile::writeFloatingPoint( FTYPE value, int precision ) { #ifdef E57_MAX_VERBOSE - cout << "CheckedFile::writeFloatingPoint, value=" << value << " precision=" << precision << std::endl; + std::cout << "CheckedFile::writeFloatingPoint, value=" << value << " precision=" << precision << std::endl; #endif std::stringstream ss; @@ -672,7 +672,7 @@ void CheckedFile::unlink() #ifdef E57_MAX_VERBOSE if ( result < 0 ) { - cout << "std::remove() failed, result=" << result << std::endl; + std::cout << "std::remove() failed, result=" << result << std::endl; } #endif } diff --git a/src/Decoder.cpp b/src/Decoder.cpp index e98244d..cff3feb 100644 --- a/src/Decoder.cpp +++ b/src/Decoder.cpp @@ -47,7 +47,7 @@ std::shared_ptr Decoder::DecoderFactory( unsigned bytestreamNumber, //! NodeImplSharedPtr decodeNode = prototype->get( path ); #ifdef E57_MAX_VERBOSE - cout << "Node to decode:" << std::endl; //??? + std::cout << "Node to decode:" << std::endl; //??? decodeNode->dump( 2 ); #endif @@ -207,8 +207,8 @@ void BitpackDecoder::destBufferSetNew( std::vector &dbufs ) size_t BitpackDecoder::inputProcess( const char *source, const size_t availableByteCount ) { #ifdef E57_MAX_VERBOSE - cout << "BitpackDecoder::inputprocess() called, source=" << ( source ? source : "none" ) - << " availableByteCount=" << availableByteCount << std::endl; + std::cout << "BitpackDecoder::inputprocess() called, source=" << ( source ? source : "none" ) + << " availableByteCount=" << availableByteCount << std::endl; #endif size_t bytesUnsaved = availableByteCount; size_t bitsEaten = 0; @@ -233,10 +233,14 @@ size_t BitpackDecoder::inputProcess( const char *source, const size_t availableB unsigned i; unsigned firstByte = inBufferFirstBit_ / 8; for ( i = 0; i < byteCount && i < 20; i++ ) - cout << " inBuffer[" << firstByte + i << "]=" << (unsigned)(unsigned char)( inBuffer_[firstByte + i] ) - << std::endl; + { + std::cout << " inBuffer[" << firstByte + i << "]=" << (unsigned)(unsigned char)( inBuffer_[firstByte + i] ) + << std::endl; + } if ( i < byteCount ) - cout << " " << byteCount - i << "source bytes unprinted..." << std::endl; + { + std::cout << " " << byteCount - i << "source bytes unprinted..." << std::endl; + } } #endif @@ -252,13 +256,13 @@ size_t BitpackDecoder::inputProcess( const char *source, const size_t availableB size_t firstNaturalBit = firstWord * bitsPerWord_; size_t endBit = inBufferEndByte_ * 8; #ifdef E57_MAX_VERBOSE - cout << " feeding aligned decoder " << endBit - inBufferFirstBit_ << " bits." << std::endl; + std::cout << " feeding aligned decoder " << endBit - inBufferFirstBit_ << " bits." << std::endl; #endif bitsEaten = inputProcessAligned( &inBuffer_[firstWord * bytesPerWord_], inBufferFirstBit_ - firstNaturalBit, endBit - firstNaturalBit ); #ifdef E57_MAX_VERBOSE - cout << " bitsEaten=" << bitsEaten << " firstWord=" << firstWord << " firstNaturalBit=" << firstNaturalBit - << " endBit=" << endBit << std::endl; + std::cout << " bitsEaten=" << bitsEaten << " firstWord=" << firstWord << " firstNaturalBit=" << firstNaturalBit + << " endBit=" << endBit << std::endl; #endif #ifdef E57_DEBUG if ( bitsEaten > endBit - inBufferFirstBit_ ) @@ -348,8 +352,8 @@ BitpackFloatDecoder::BitpackFloatDecoder( unsigned bytestreamNumber, SourceDestB size_t BitpackFloatDecoder::inputProcessAligned( const char *inbuf, const size_t firstBit, const size_t endBit ) { #ifdef E57_MAX_VERBOSE - cout << "BitpackFloatDecoder::inputProcessAligned() called, inbuf=" << inbuf << " firstBit=" << firstBit - << " endBit=" << endBit << std::endl; + std::cout << "BitpackFloatDecoder::inputProcessAligned() called, inbuf=" << inbuf << " firstBit=" << firstBit + << " endBit=" << endBit << std::endl; #endif /// Read from inbuf, decode, store in destBuffer /// Repeat until have filled destBuffer, or completed all records @@ -385,7 +389,7 @@ size_t BitpackFloatDecoder::inputProcessAligned( const char *inbuf, const size_t n = static_cast( maxRecordCount_ - currentRecordIndex_ ); #ifdef E57_MAX_VERBOSE - cout << " n:" << n << std::endl; //??? + std::cout << " n:" << n << std::endl; //??? #endif if ( precision_ == E57_SINGLE ) @@ -399,7 +403,7 @@ size_t BitpackFloatDecoder::inputProcessAligned( const char *inbuf, const size_t float value = *inp; #ifdef E57_MAX_VERBOSE - cout << " got float value=" << value << std::endl; + std::cout << " got float value=" << value << std::endl; #endif destBuffer_->setNextFloat( value ); inp++; @@ -416,7 +420,7 @@ size_t BitpackFloatDecoder::inputProcessAligned( const char *inbuf, const size_t double value = *inp; #ifdef E57_MAX_VERBOSE - cout << " got double value=" << value << std::endl; + std::cout << " got double value=" << value << std::endl; #endif destBuffer_->setNextDouble( value ); inp++; @@ -452,8 +456,8 @@ BitpackStringDecoder::BitpackStringDecoder( unsigned bytestreamNumber, SourceDes size_t BitpackStringDecoder::inputProcessAligned( const char *inbuf, const size_t firstBit, const size_t endBit ) { #ifdef E57_MAX_VERBOSE - cout << "BitpackStringDecoder::inputProcessAligned() called, inbuf=" << inbuf << " firstBit=" << firstBit - << " endBit=" << endBit << std::endl; + std::cout << "BitpackStringDecoder::inputProcessAligned() called, inbuf=" << inbuf << " firstBit=" << firstBit + << " endBit=" << endBit << std::endl; #endif /// Read from inbuf, decode, store in destBuffer /// Repeat until have filled destBuffer, or completed all records @@ -473,8 +477,8 @@ size_t BitpackStringDecoder::inputProcessAligned( const char *inbuf, const size_ while ( currentRecordIndex_ < maxRecordCount_ && nBytesRead < nBytesAvailable ) { #ifdef E57_MAX_VERBOSE - cout << "read string loop1: readingPrefix=" << readingPrefix_ << " prefixLength=" << prefixLength_ - << " nBytesPrefixRead=" << nBytesPrefixRead_ << " nBytesStringRead=" << nBytesStringRead_ << std::endl; + std::cout << "read string loop1: readingPrefix=" << readingPrefix_ << " prefixLength=" << prefixLength_ + << " nBytesPrefixRead=" << nBytesPrefixRead_ << " nBytesStringRead=" << nBytesStringRead_ << std::endl; #endif if ( readingPrefix_ ) { @@ -498,8 +502,9 @@ size_t BitpackStringDecoder::inputProcessAligned( const char *inbuf, const size_ } #ifdef E57_MAX_VERBOSE - cout << "read string loop2: readingPrefix=" << readingPrefix_ << " prefixLength=" << prefixLength_ - << " nBytesPrefixRead=" << nBytesPrefixRead_ << " nBytesStringRead=" << nBytesStringRead_ << std::endl; + std::cout << "read string loop2: readingPrefix=" << readingPrefix_ << " prefixLength=" << prefixLength_ + << " nBytesPrefixRead=" << nBytesPrefixRead_ << " nBytesStringRead=" << nBytesStringRead_ + << std::endl; #endif /// If got all of prefix, convert to length and get ready to read /// string @@ -535,8 +540,9 @@ size_t BitpackStringDecoder::inputProcessAligned( const char *inbuf, const size_ nBytesStringRead_ = 0; } #ifdef E57_MAX_VERBOSE - cout << "read string loop3: readingPrefix=" << readingPrefix_ << " prefixLength=" << prefixLength_ - << " nBytesPrefixRead=" << nBytesPrefixRead_ << " nBytesStringRead=" << nBytesStringRead_ << std::endl; + std::cout << "read string loop3: readingPrefix=" << readingPrefix_ << " prefixLength=" << prefixLength_ + << " nBytesPrefixRead=" << nBytesPrefixRead_ << " nBytesStringRead=" << nBytesStringRead_ + << std::endl; #endif } @@ -627,8 +633,8 @@ size_t BitpackIntegerDecoder::inputProcessAligned( const char *inbuf, const size_t endBit ) { #ifdef E57_MAX_VERBOSE - cout << "BitpackIntegerDecoder::inputProcessAligned() called, inbuf=" << (void *)( inbuf ) - << " firstBit=" << firstBit << " endBit=" << endBit << std::endl; + std::cout << "BitpackIntegerDecoder::inputProcessAligned() called, inbuf=" << (void *)( inbuf ) + << " firstBit=" << firstBit << " endBit=" << endBit << std::endl; #endif /// Read from inbuf, decode, store in destBuffer @@ -663,7 +669,7 @@ size_t BitpackIntegerDecoder::inputProcessAligned( const char *inbuf, recordCount = static_cast( maxRecordCount_ - currentRecordIndex_ ); #ifdef E57_MAX_VERBOSE - cout << " recordCount=" << recordCount << std::endl; + std::cout << " recordCount=" << recordCount << std::endl; #endif auto inp = reinterpret_cast( inbuf ); @@ -689,8 +695,8 @@ size_t BitpackIntegerDecoder::inputProcessAligned( const char *inbuf, RegisterT low = inp[wordPosition]; #ifdef E57_MAX_VERBOSE - cout << " bitOffset: " << bitOffset << std::endl; - cout << " low: " << binaryString( low ) << std::endl; + std::cout << " bitOffset: " << bitOffset << std::endl; + std::cout << " low: " << binaryString( low ) << std::endl; #endif RegisterT w; @@ -700,7 +706,7 @@ size_t BitpackIntegerDecoder::inputProcessAligned( const char *inbuf, RegisterT high = inp[wordPosition + 1]; #ifdef E57_MAX_VERBOSE - cout << " high:" << binaryString( high ) << std::endl; + std::cout << " high:" << binaryString( high ) << std::endl; #endif /// Shift high to just above the lower bits, shift low LSBit to bit0, @@ -716,7 +722,7 @@ size_t BitpackIntegerDecoder::inputProcessAligned( const char *inbuf, } #ifdef E57_MAX_VERBOSE - cout << " w: " << binaryString( w ) << std::endl; + std::cout << " w: " << binaryString( w ) << std::endl; #endif /// Mask off uninteresting bits @@ -726,7 +732,7 @@ size_t BitpackIntegerDecoder::inputProcessAligned( const char *inbuf, int64_t value = minimum_ + static_cast( w ); #ifdef E57_MAX_VERBOSE - cout << " Storing value=" << value << std::endl; + std::cout << " Storing value=" << value << std::endl; #endif /// The parameter isScaledInteger_ determines which version of @@ -746,7 +752,7 @@ size_t BitpackIntegerDecoder::inputProcessAligned( const char *inbuf, wordPosition++; } #ifdef E57_MAX_VERBOSE - cout << " Processed " << i + 1 << " records, wordPosition=" << wordPosition << " decoder:" << std::endl; + std::cout << " Processed " << i + 1 << " records, wordPosition=" << wordPosition << " decoder:" << std::endl; dump( 4 ); #endif } @@ -797,8 +803,8 @@ void ConstantIntegerDecoder::destBufferSetNew( std::vector &db size_t ConstantIntegerDecoder::inputProcess( const char *source, const size_t availableByteCount ) { #ifdef E57_MAX_VERBOSE - cout << "ConstantIntegerDecoder::inputprocess() called, source=" << (void *)( source ) - << " availableByteCount=" << availableByteCount << std::endl; + std::cout << "ConstantIntegerDecoder::inputprocess() called, source=" << (void *)( source ) + << " availableByteCount=" << availableByteCount << std::endl; #endif /// We don't need any input bytes to produce output, so ignore source and diff --git a/src/E57FormatImpl.cpp b/src/E57FormatImpl.cpp index 18f4441..325df79 100644 --- a/src/E57FormatImpl.cpp +++ b/src/E57FormatImpl.cpp @@ -1369,7 +1369,7 @@ CompressedVectorWriterImpl::CompressedVectorWriterImpl( std::shared_ptrdestImageFile_ ); @@ -1418,7 +1418,7 @@ void CompressedVectorWriterImpl::close() /// current start of free space). sectionLogicalLength_ = imf->unusedLogicalStart_ - sectionHeaderLogicalStart_; #ifdef E57_MAX_VERBOSE - cout << " sectionLogicalLength_=" << sectionLogicalLength_ << std::endl; //??? + std::cout << " sectionLogicalLength_=" << sectionLogicalLength_ << std::endl; //??? #endif /// Prepare CompressedVectorSectionHeader @@ -1428,7 +1428,7 @@ void CompressedVectorWriterImpl::close() header.indexPhysicalOffset = topIndexPhysicalOffset_; ///??? can be zero, if no data written ???not set /// yet #ifdef E57_MAX_VERBOSE - cout << " CompressedVectorSectionHeader:" << std::endl; + std::cout << " CompressedVectorSectionHeader:" << std::endl; header.dump( 4 ); //??? #endif #ifdef E57_DEBUG @@ -1448,7 +1448,7 @@ void CompressedVectorWriterImpl::close() bytestreams_.clear(); #ifdef E57_MAX_VERBOSE - cout << " CompressedVectorWriter:" << std::endl; + std::cout << " CompressedVectorWriter:" << std::endl; dump( 4 ); #endif } @@ -1509,7 +1509,7 @@ void CompressedVectorWriterImpl::write( std::vector &sbufs, co void CompressedVectorWriterImpl::write( const size_t requestedRecordCount ) { #ifdef E57_MAX_VERBOSE - cout << "CompressedVectorWriterImpl::write() called" << std::endl; //??? + std::cout << "CompressedVectorWriterImpl::write() called" << std::endl; //??? #endif checkImageFileOpen( __FILE__, __LINE__, static_cast( __FUNCTION__ ) ); checkWriterOpen( __FILE__, __LINE__, static_cast( __FUNCTION__ ) ); @@ -1540,7 +1540,7 @@ void CompressedVectorWriterImpl::write( const size_t requestedRecordCount ) totalRecordCount += endRecordIndex - bytestream->currentRecordIndex(); } #ifdef E57_MAX_VERBOSE - cout << " totalRecordCount=" << totalRecordCount << std::endl; //??? + std::cout << " totalRecordCount=" << totalRecordCount << std::endl; //??? #endif /// We are done if have no more work, break out of loop @@ -1557,7 +1557,7 @@ void CompressedVectorWriterImpl::write( const size_t requestedRecordCount ) /// packets is efficient). #ifdef E57_MAX_VERBOSE - cout << " currentPacketSize()=" << currentPacketSize() << std::endl; //??? + std::cout << " currentPacketSize()=" << currentPacketSize() << std::endl; //??? #endif #ifdef E57_WRITE_CRAZY_PACKET_MODE @@ -1584,9 +1584,9 @@ void CompressedVectorWriterImpl::write( const size_t requestedRecordCount ) } #ifdef E57_MAX_VERBOSE - float totalBytesPerRecord = max( totalBitsPerRecord / 8, 0.1F ); //??? trust + float totalBytesPerRecord = std::max( totalBitsPerRecord / 8, 0.1F ); //??? trust - cout << " totalBytesPerRecord=" << totalBytesPerRecord << std::endl; //??? + std::cout << " totalBytesPerRecord=" << totalBytesPerRecord << std::endl; //??? #endif /// Don't allow straggler to get too far behind. ??? @@ -1635,7 +1635,7 @@ size_t CompressedVectorWriterImpl::currentPacketSize() const uint64_t CompressedVectorWriterImpl::packetWrite() { #ifdef E57_MAX_VERBOSE - cout << "CompressedVectorWriterImpl::packetWrite() called" << std::endl; //??? + std::cout << "CompressedVectorWriterImpl::packetWrite() called" << std::endl; //??? #endif /// Double check that we have work to do @@ -1643,14 +1643,14 @@ uint64_t CompressedVectorWriterImpl::packetWrite() if ( totalOutput == 0 ) return ( 0 ); #ifdef E57_MAX_VERBOSE - cout << " totalOutput=" << totalOutput << std::endl; //??? + std::cout << " totalOutput=" << totalOutput << std::endl; //??? #endif /// Calc maximum number of bytestream values can put in data packet. size_t packetMaxPayloadBytes = DATA_PACKET_MAX - sizeof( DataPacketHeader ) - bytestreams_.size() * sizeof( uint16_t ); #ifdef E57_MAX_VERBOSE - cout << " packetMaxPayloadBytes=" << packetMaxPayloadBytes << std::endl; //??? + std::cout << " packetMaxPayloadBytes=" << packetMaxPayloadBytes << std::endl; //??? #endif /// Allocate vector for number of bytes that each bytestream will write to @@ -1678,7 +1678,9 @@ uint64_t CompressedVectorWriterImpl::packetWrite() } #ifdef E57_MAX_VERBOSE for ( unsigned i = 0; i < bytestreams_.size(); i++ ) - cout << " count[" << i << "]=" << count.at( i ) << std::endl; //??? + { + std::cout << " count[" << i << "]=" << count.at( i ) << std::endl; //??? + } #endif #ifdef E57_DEBUG @@ -1700,7 +1702,7 @@ uint64_t CompressedVectorWriterImpl::packetWrite() /// here char *packet = reinterpret_cast( &dataPacket_ ); #ifdef E57_MAX_VERBOSE - cout << " packet=" << packet << std::endl; //??? + std::cout << " packet=" << packet << std::endl; //??? #endif /// To be safe, clear header part of packet @@ -1710,20 +1712,20 @@ uint64_t CompressedVectorWriterImpl::packetWrite() /// dataPacket_ auto bsbLength = reinterpret_cast( &packet[sizeof( DataPacketHeader )] ); #ifdef E57_MAX_VERBOSE - cout << " bsbLength=" << bsbLength << std::endl; //??? + std::cout << " bsbLength=" << bsbLength << std::endl; //??? #endif for ( unsigned i = 0; i < bytestreams_.size(); i++ ) { bsbLength[i] = static_cast( count.at( i ) ); // %%% Truncation #ifdef E57_MAX_VERBOSE - cout << " Writing " << bsbLength[i] << " bytes into bytestream " << i << std::endl; //??? + std::cout << " Writing " << bsbLength[i] << " bytes into bytestream " << i << std::endl; //??? #endif } /// Get pointer to end of data so far char *p = reinterpret_cast( &bsbLength[bytestreams_.size()] ); #ifdef E57_MAX_VERBOSE - cout << " after bsbLength, p=" << p << std::endl; //??? + std::cout << " after bsbLength, p=" << p << std::endl; //??? #endif /// Write contents of each bytestream in dataPacket_ @@ -1748,7 +1750,7 @@ uint64_t CompressedVectorWriterImpl::packetWrite() /// Length of packet is difference in beginning pointer and ending pointer auto packetLength = static_cast( p - packet ); ///??? pointer diff portable? #ifdef E57_MAX_VERBOSE - cout << " packetLength=" << packetLength << std::endl; //??? + std::cout << " packetLength=" << packetLength << std::endl; //??? #endif #ifdef E57_DEBUG @@ -1771,7 +1773,7 @@ uint64_t CompressedVectorWriterImpl::packetWrite() *p++ = 0; packetLength++; #ifdef E57_MAX_VERBOSE - cout << " padding with zero byte, new packetLength=" << packetLength << std::endl; //??? + std::cout << " padding with zero byte, new packetLength=" << packetLength << std::endl; //??? #endif } @@ -1790,7 +1792,7 @@ uint64_t CompressedVectorWriterImpl::packetWrite() imf->file_->write( packet, packetLength ); #ifdef E57_MAX_VERBOSE -// cout << "data packet:" << std::endl; +// std::cout << "data packet:" << std::endl; // dataPacket_.dump(4); #endif @@ -1887,7 +1889,7 @@ CompressedVectorReaderImpl::CompressedVectorReaderImpl( std::shared_ptr( __FUNCTION__ ) ); @@ -1999,8 +2001,8 @@ CompressedVectorReaderImpl::CompressedVectorReaderImpl( std::shared_ptr &dbufs unsigned CompressedVectorReaderImpl::read() { #ifdef E57_MAX_VERBOSE - cout << "CompressedVectorReaderImpl::read() called" << std::endl; //??? + std::cout << "CompressedVectorReaderImpl::read() called" << std::endl; //??? #endif checkImageFileOpen( __FILE__, __LINE__, static_cast( __FUNCTION__ ) ); checkReaderOpen( __FILE__, __LINE__, static_cast( __FUNCTION__ ) ); @@ -2148,10 +2150,14 @@ uint64_t CompressedVectorReaderImpl::earliestPacketNeededForInput() const } #ifdef E57_MAX_VERBOSE if ( earliestPacketLogicalOffset == E57_UINT64_MAX ) - cout << "earliestPacketNeededForInput returning none found" << std::endl; + { + std::cout << "earliestPacketNeededForInput returning none found" << std::endl; + } else - cout << "earliestPacketNeededForInput returning " << earliestPacketLogicalOffset << " for channel[" - << earliestChannel << "]" << std::endl; + { + std::cout << "earliestPacketNeededForInput returning " << earliestPacketLogicalOffset << " for channel[" + << earliestChannel << "]" << std::endl; + } #endif return earliestPacketLogicalOffset; } @@ -2218,14 +2224,14 @@ void CompressedVectorReaderImpl::feedPacketToDecoders( uint64_t currentPacketLog size_t bytesProcessed = channel.decoder->inputProcess( uneatenStart, uneatenLength ); #ifdef E57_MAX_VERBOSE - cout << " stream[" << channel.bytestreamNumber << "]: feeding decoder " << uneatenLength << " bytes" - << std::endl; + std::cout << " stream[" << channel.bytestreamNumber << "]: feeding decoder " << uneatenLength << " bytes" + << std::endl; if ( uneatenLength == 0 ) { channel.dump( 8 ); } - cout << " stream[" << channel.bytestreamNumber << "]: bytesProcessed=" << bytesProcessed << std::endl; + std::cout << " stream[" << channel.bytestreamNumber << "]: bytesProcessed=" << bytesProcessed << std::endl; #endif /// Adjust counts of bytestream location @@ -2236,7 +2242,8 @@ void CompressedVectorReaderImpl::feedPacketToDecoders( uint64_t currentPacketLog if ( channel.isInputBlocked() ) { #ifdef E57_MAX_VERBOSE - cout << " stream[" << channel.bytestreamNumber << "] has exhausted its input in current packet" << std::endl; + std::cout << " stream[" << channel.bytestreamNumber << "] has exhausted its input in current packet" + << std::endl; #endif channelHasExhaustedPacket = true; nextPacketLogicalOffset = currentPacketLogicalOffset + dpkt->header.packetLogicalLengthMinus1 + 1; @@ -2268,8 +2275,8 @@ void CompressedVectorReaderImpl::feedPacketToDecoders( uint64_t currentPacketLog channel.currentBytestreamBufferLength = dpkt->getBytestreamBufferLength( channel.bytestreamNumber ); #ifdef E57_MAX_VERBOSE - cout << " set new stream buffer for channel[" << channel.bytestreamNumber - << "], length=" << channel.currentBytestreamBufferLength << std::endl; + std::cout << " set new stream buffer for channel[" << channel.bytestreamNumber + << "], length=" << channel.currentBytestreamBufferLength << std::endl; #endif /// ??? perform flush if new packet flag set? } @@ -2280,7 +2287,7 @@ void CompressedVectorReaderImpl::feedPacketToDecoders( uint64_t currentPacketLog /// Reached end without finding data packet, mark exhausted channels as /// finished #ifdef E57_MAX_VERBOSE - cout << " at end of data packets" << std::endl; + std::cout << " at end of data packets" << std::endl; #endif if ( nextPacketLogicalOffset >= sectionEndLogicalOffset_ ) { @@ -2289,7 +2296,7 @@ void CompressedVectorReaderImpl::feedPacketToDecoders( uint64_t currentPacketLog if ( ( channel.currentPacketLogicalOffset == currentPacketLogicalOffset ) && channel.isInputBlocked() ) { #ifdef E57_MAX_VERBOSE - cout << " Marking channel[" << channel.bytestreamNumber << "] as finished" << std::endl; + std::cout << " Marking channel[" << channel.bytestreamNumber << "] as finished" << std::endl; #endif channel.inputFinished = true; } @@ -2302,8 +2309,8 @@ void CompressedVectorReaderImpl::feedPacketToDecoders( uint64_t currentPacketLog uint64_t CompressedVectorReaderImpl::findNextDataPacket( uint64_t nextPacketLogicalOffset ) { #ifdef E57_MAX_VERBOSE - cout << " searching for next data packet, nextPacketLogicalOffset=" << nextPacketLogicalOffset - << " sectionEndLogicalOffset=" << sectionEndLogicalOffset_ << std::endl; + std::cout << " searching for next data packet, nextPacketLogicalOffset=" << nextPacketLogicalOffset + << " sectionEndLogicalOffset=" << sectionEndLogicalOffset_ << std::endl; #endif /// Starting at nextPacketLogicalOffset, search for next data packet until @@ -2320,7 +2327,7 @@ uint64_t CompressedVectorReaderImpl::findNextDataPacket( uint64_t nextPacketLogi if ( dpkt->header.packetType == DATA_PACKET ) { #ifdef E57_MAX_VERBOSE - cout << " Found next data packet at nextPacketLogicalOffset=" << nextPacketLogicalOffset << std::endl; + std::cout << " Found next data packet at nextPacketLogicalOffset=" << nextPacketLogicalOffset << std::endl; #endif return nextPacketLogicalOffset; } diff --git a/src/E57XmlParser.cpp b/src/E57XmlParser.cpp index f8306a3..61d1283 100644 --- a/src/E57XmlParser.cpp +++ b/src/E57XmlParser.cpp @@ -254,18 +254,18 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca const Attributes &attributes ) { #ifdef E57_MAX_VERBOSE - cout << "startElement" << std::endl; - cout << space( 2 ) << "URI: " << toUString( uri ) << std::endl; - cout << space( 2 ) << "localName: " << toUString( localName ) << std::endl; - cout << space( 2 ) << "qName: " << toUString( qName ) << std::endl; + std::cout << "startElement" << std::endl; + std::cout << space( 2 ) << "URI: " << toUString( uri ) << std::endl; + std::cout << space( 2 ) << "localName: " << toUString( localName ) << std::endl; + std::cout << space( 2 ) << "qName: " << toUString( qName ) << std::endl; for ( size_t i = 0; i < attributes.getLength(); i++ ) { - cout << space( 2 ) << "Attribute[" << i << "]" << std::endl; - cout << space( 4 ) << "URI: " << toUString( attributes.getURI( i ) ) << std::endl; - cout << space( 4 ) << "localName: " << toUString( attributes.getLocalName( i ) ) << std::endl; - cout << space( 4 ) << "qName: " << toUString( attributes.getQName( i ) ) << std::endl; - cout << space( 4 ) << "value: " << toUString( attributes.getValue( i ) ) << std::endl; + std::cout << space( 2 ) << "Attribute[" << i << "]" << std::endl; + std::cout << space( 4 ) << "URI: " << toUString( attributes.getURI( i ) ) << std::endl; + std::cout << space( 4 ) << "localName: " << toUString( attributes.getLocalName( i ) ) << std::endl; + std::cout << space( 4 ) << "qName: " << toUString( attributes.getQName( i ) ) << std::endl; + std::cout << space( 4 ) << "value: " << toUString( attributes.getValue( i ) ) << std::endl; } #endif /// Get Type attribute @@ -279,7 +279,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca if ( node_type == "Integer" ) { #ifdef E57_MAX_VERBOSE - cout << "got a Integer" << std::endl; + std::cout << "got a Integer" << std::endl; #endif //??? check validity of numeric strings pi.nodeType = E57_INTEGER; @@ -314,7 +314,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca else if ( node_type == "ScaledInteger" ) { #ifdef E57_MAX_VERBOSE - cout << "got a ScaledInteger" << std::endl; + std::cout << "got a ScaledInteger" << std::endl; #endif pi.nodeType = E57_SCALED_INTEGER; @@ -371,7 +371,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca else if ( node_type == "Float" ) { #ifdef E57_MAX_VERBOSE - cout << "got a Float" << std::endl; + std::cout << "got a Float" << std::endl; #endif pi.nodeType = E57_FLOAT; @@ -431,7 +431,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca else if ( node_type == "String" ) { #ifdef E57_MAX_VERBOSE - cout << "got a String" << std::endl; + std::cout << "got a String" << std::endl; #endif pi.nodeType = E57_STRING; @@ -441,7 +441,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca else if ( node_type == "Blob" ) { #ifdef E57_MAX_VERBOSE - cout << "got a Blob" << std::endl; + std::cout << "got a Blob" << std::endl; #endif pi.nodeType = E57_BLOB; @@ -463,7 +463,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca else if ( node_type == "Structure" ) { #ifdef E57_MAX_VERBOSE - cout << "got a Structure" << std::endl; + std::cout << "got a Structure" << std::endl; #endif pi.nodeType = E57_STRUCTURE; @@ -479,7 +479,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca if ( toUString( attributes.getQName( i ) ) == "xmlns" ) { #ifdef E57_VERBOSE - cout << "declared default namespace, URI=" << toUString( attributes.getValue( i ) ) << std::endl; + std::cout << "declared default namespace, URI=" << toUString( attributes.getValue( i ) ) << std::endl; #endif imf_->extensionsAdd( "", toUString( attributes.getValue( i ) ) ); gotDefault = true; @@ -520,7 +520,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca else if ( node_type == "Vector" ) { #ifdef E57_MAX_VERBOSE - cout << "got a Vector" << std::endl; + std::cout << "got a Vector" << std::endl; #endif pi.nodeType = E57_VECTOR; @@ -558,7 +558,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca else if ( node_type == "CompressedVector" ) { #ifdef E57_MAX_VERBOSE - cout << "got a CompressedVector" << std::endl; + std::cout << "got a CompressedVector" << std::endl; #endif pi.nodeType = E57_COMPRESSED_VECTOR; @@ -596,7 +596,7 @@ void E57XmlParser::startElement( const XMLCh *const uri, const XMLCh *const loca void E57XmlParser::endElement( const XMLCh *const uri, const XMLCh *const localName, const XMLCh *const qName ) { #ifdef E57_MAX_VERBOSE - cout << "endElement" << std::endl; + std::cout << "endElement" << std::endl; #endif /// Pop the node that just ended @@ -785,7 +785,7 @@ void E57XmlParser::characters( const XMLCh *const chars, const XMLSize_t length { //??? use length to make ustring #ifdef E57_MAX_VERBOSE - cout << "characters, chars=\"" << toUString( chars ) << "\" length=" << length << std::endl; + std::cout << "characters, chars=\"" << toUString( chars ) << "\" length=" << length << std::endl; #endif /// Get active element ParseInfo &pi = stack_.top(); diff --git a/src/Encoder.cpp b/src/Encoder.cpp index 0021736..3661d5c 100644 --- a/src/Encoder.cpp +++ b/src/Encoder.cpp @@ -53,7 +53,7 @@ std::shared_ptr Encoder::EncoderFactory( unsigned bytestreamNumber, NodeImplSharedPtr encodeNode = prototype->get( path ); #ifdef E57_MAX_VERBOSE - cout << "Node to encode:" << std::endl; //??? + std::cout << "Node to encode:" << std::endl; //??? encodeNode->dump( 2 ); #endif switch ( encodeNode->type() ) @@ -223,7 +223,7 @@ size_t BitpackEncoder::outputAvailable() void BitpackEncoder::outputRead( char *dest, const size_t byteCount ) { #ifdef E57_MAX_VERBOSE - cout << "BitpackEncoder::outputRead() called, dest=" << dest << " byteCount=" << byteCount << std::endl; //??? + std::cout << "BitpackEncoder::outputRead() called, dest=" << dest << " byteCount=" << byteCount << std::endl; //??? #endif /// Check we have enough bytes in queue @@ -238,11 +238,16 @@ void BitpackEncoder::outputRead( char *dest, const size_t byteCount ) { unsigned i; for ( i = 0; i < byteCount && i < 20; i++ ) - cout << " outBuffer[" << outBufferFirst_ + i - << "]=" << static_cast( static_cast( outBuffer_[outBufferFirst_ + i] ) ) - << std::endl; //??? + { + std::cout << " outBuffer[" << outBufferFirst_ + i + << "]=" << static_cast( static_cast( outBuffer_[outBufferFirst_ + i] ) ) + << std::endl; //??? + } + if ( i < byteCount ) - cout << " " << byteCount - 1 << " bytes unprinted..." << std::endl; + { + std::cout << " " << byteCount - 1 << " bytes unprinted..." << std::endl; + } } #endif @@ -360,7 +365,7 @@ BitpackFloatEncoder::BitpackFloatEncoder( unsigned bytestreamNumber, SourceDestB uint64_t BitpackFloatEncoder::processRecords( size_t recordCount ) { #ifdef E57_MAX_VERBOSE - cout << " BitpackFloatEncoder::processRecords() called, recordCount=" << recordCount << std::endl; //??? + std::cout << " BitpackFloatEncoder::processRecords() called, recordCount=" << recordCount << std::endl; //??? #endif /// Before we add any more, try to shift current contents of outBuffer_ down @@ -394,7 +399,7 @@ uint64_t BitpackFloatEncoder::processRecords( size_t recordCount ) { outp[i] = sourceBuffer_->getNextFloat(); #ifdef E57_MAX_VERBOSE - cout << "encoding float: " << outp[i] << std::endl; + std::cout << "encoding float: " << outp[i] << std::endl; #endif } } @@ -408,7 +413,7 @@ uint64_t BitpackFloatEncoder::processRecords( size_t recordCount ) { outp[i] = sourceBuffer_->getNextDouble(); #ifdef E57_MAX_VERBOSE - cout << "encoding double: " << outp[i] << std::endl; + std::cout << "encoding double: " << outp[i] << std::endl; #endif } } @@ -456,7 +461,7 @@ BitpackStringEncoder::BitpackStringEncoder( unsigned bytestreamNumber, SourceDes uint64_t BitpackStringEncoder::processRecords( size_t recordCount ) { #ifdef E57_MAX_VERBOSE - cout << " BitpackStringEncoder::processRecords() called, recordCount=" << recordCount << std::endl; //??? + std::cout << " BitpackStringEncoder::processRecords() called, recordCount=" << recordCount << std::endl; //??? #endif /// Before we add any more, try to shift current contents of outBuffer_ down @@ -481,13 +486,13 @@ uint64_t BitpackStringEncoder::processRecords( size_t recordCount ) if ( len <= 127 ) { #ifdef E57_MAX_VERBOSE - cout << "encoding short string: (len=" << len - << ") " - "" - << currentString_ - << "" - "" - << std::endl; + std::cout << "encoding short string: (len=" << len + << ") " + "" + << currentString_ + << "" + "" + << std::endl; #endif /// We can use the short length prefix: b0=0, b7-b1=len auto lengthPrefix = static_cast( len << 1 ); @@ -502,13 +507,13 @@ uint64_t BitpackStringEncoder::processRecords( size_t recordCount ) throw E57_EXCEPTION2( E57_ERROR_INTERNAL, "bytesFree=" + toString( bytesFree ) ); #endif #ifdef E57_MAX_VERBOSE - cout << "encoding long string: (len=" << len - << ") " - "" - << currentString_ - << "" - "" - << std::endl; + std::cout << "encoding long string: (len=" << len + << ") " + "" + << currentString_ + << "" + "" + << std::endl; #endif /// We use the long length prefix: b0=1, b63-b1=len, and store in /// little endian order Shift the length and set the least @@ -554,7 +559,7 @@ uint64_t BitpackStringEncoder::processRecords( size_t recordCount ) prefixComplete_ = false; currentCharPosition_ = 0; #ifdef E57_MAX_VERBOSE - cout << "getting next string, length=" << currentString_.length() << std::endl; + std::cout << "getting next string, length=" << currentString_.length() << std::endl; #endif } } @@ -626,8 +631,8 @@ template uint64_t BitpackIntegerEncoder::process { //??? what are state guarantees if get an exception during transfer? #ifdef E57_MAX_VERBOSE - cout << "BitpackIntegerEncoder::processRecords() called, sizeof(RegisterT)=" << sizeof( RegisterT ) - << " recordCount=" << recordCount << std::endl; + std::cout << "BitpackIntegerEncoder::processRecords() called, sizeof(RegisterT)=" << sizeof( RegisterT ) + << " recordCount=" << recordCount << std::endl; dump( 4 ); #endif #ifdef E57_MAX_DEBUG @@ -660,8 +665,8 @@ template uint64_t BitpackIntegerEncoder::process /// fit. recordCount = std::min( recordCount, maxOutputRecords ); #ifdef E57_MAX_VERBOSE - cout << " outputWordCapacity=" << outputWordCapacity << " maxOutputRecords=" << maxOutputRecords - << " recordCount=" << recordCount << std::endl; + std::cout << " outputWordCapacity=" << outputWordCapacity << " maxOutputRecords=" << maxOutputRecords + << " recordCount=" << recordCount << std::endl; #endif /// Form the starting address for next available location in outBuffer @@ -691,8 +696,9 @@ template uint64_t BitpackIntegerEncoder::process auto uValue = static_cast( rawValue - minimum_ ); #ifdef E57_MAX_VERBOSE - cout << "encoding integer rawValue=" << binaryString( rawValue ) << " = " << hexString( rawValue ) << std::endl; - cout << " uValue =" << binaryString( uValue ) << " = " << hexString( uValue ) << std::endl; + std::cout << "encoding integer rawValue=" << binaryString( rawValue ) << " = " << hexString( rawValue ) + << std::endl; + std::cout << " uValue =" << binaryString( uValue ) << " = " << hexString( uValue ) << std::endl; #endif #ifdef E57_DEBUG /// Double check that no bits outside of the mask are set @@ -705,8 +711,8 @@ template uint64_t BitpackIntegerEncoder::process /// See if uValue bits will fit in register unsigned newRegisterBitsUsed = registerBitsUsed_ + bitsPerRecord_; #ifdef E57_MAX_VERBOSE - cout << " registerBitsUsed=" << registerBitsUsed_ << " newRegisterBitsUsed=" << newRegisterBitsUsed - << std::endl; + std::cout << " registerBitsUsed=" << registerBitsUsed_ << " newRegisterBitsUsed=" << newRegisterBitsUsed + << std::endl; #endif if ( newRegisterBitsUsed > 8 * sizeof( RegisterT ) ) { @@ -755,7 +761,7 @@ template uint64_t BitpackIntegerEncoder::process registerBitsUsed_ = newRegisterBitsUsed; } #ifdef E57_MAX_VERBOSE - cout << " After " << outTransferred << " transfers and " << i + 1 << " records, encoder:" << std::endl; + std::cout << " After " << outTransferred << " transfers and " << i + 1 << " records, encoder:" << std::endl; dump( 4 ); #endif } @@ -780,9 +786,9 @@ template uint64_t BitpackIntegerEncoder::process template bool BitpackIntegerEncoder::registerFlushToOutput() { #ifdef E57_MAX_VERBOSE - cout << "BitpackIntegerEncoder::registerFlushToOutput() called, " - "sizeof(RegisterT)=" - << sizeof( RegisterT ) << std::endl; + std::cout << "BitpackIntegerEncoder::registerFlushToOutput() called, " + "sizeof(RegisterT)=" + << sizeof( RegisterT ) << std::endl; dump( 4 ); #endif /// If have any used bits in register, transfer to output, padded in MSBits @@ -838,7 +844,7 @@ ConstantIntegerEncoder::ConstantIntegerEncoder( unsigned bytestreamNumber, Sourc uint64_t ConstantIntegerEncoder::processRecords( size_t recordCount ) { #ifdef E57_MAX_VERBOSE - cout << "ConstantIntegerEncoder::processRecords() called, recordCount=" << recordCount << std::endl; + std::cout << "ConstantIntegerEncoder::processRecords() called, recordCount=" << recordCount << std::endl; dump( 4 ); #endif diff --git a/src/ImageFileImpl.cpp b/src/ImageFileImpl.cpp index 862c0e5..ce4373c 100644 --- a/src/ImageFileImpl.cpp +++ b/src/ImageFileImpl.cpp @@ -186,7 +186,7 @@ namespace e57 /// Second phase of construction, now we have a well-formed ImageFile object. #ifdef E57_MAX_VERBOSE - std::cout << "ImageFileImpl() called, fileName=" << fileName << " mode=" << mode << std::endl; + std::cout << "ImageFileImpl() called, fileName= mode=r" << std::endl; #endif unusedLogicalStart_ = sizeof( E57FileHeader ); fileName_ = ""; @@ -774,7 +774,7 @@ namespace e57 #ifdef E57_MAX_VERBOSE std::cout << "pathNameParse returning: isRelative=" << isRelative << " fields.size()=" << fields.size() << " fields="; - for ( int i = 0; i < fields.size(); i++ ) + for ( size_t i = 0; i < fields.size(); i++ ) { std::cout << fields[i] << ","; } diff --git a/src/StructureNodeImpl.cpp b/src/StructureNodeImpl.cpp index 819f9a8..e8c0bde 100644 --- a/src/StructureNodeImpl.cpp +++ b/src/StructureNodeImpl.cpp @@ -243,7 +243,8 @@ void StructureNodeImpl::set( const ustring &pathName, NodeImplSharedPtr ni, bool // COMPRESSED_VECTOR #ifdef E57_MAX_VERBOSE - cout << "StructureNodeImpl::set(pathName=" << pathName << ", ni, autoPathCreate=" << autoPathCreate << std::endl; + std::cout << "StructureNodeImpl::set(pathName=" << pathName << ", ni, autoPathCreate=" << autoPathCreate + << std::endl; #endif bool isRelative; @@ -269,9 +270,11 @@ void StructureNodeImpl::set( const std::vector &fields, unsigned level, bool autoPathCreate ) { #ifdef E57_MAX_VERBOSE - cout << "StructureNodeImpl::set: level=" << level << std::endl; + std::cout << "StructureNodeImpl::set: level=" << level << std::endl; for ( unsigned i = 0; i < fields.size(); i++ ) - cout << " field[" << i << "]: " << fields.at( i ) << std::endl; + { + std::cout << " field[" << i << "]: " << fields.at( i ) << std::endl; + } #endif checkImageFileOpen( __FILE__, __LINE__, static_cast( __FUNCTION__ ) );