diff --git a/externals/nitro/modules/c++/nitf/include/nitf/FieldDescriptor.hpp b/externals/nitro/modules/c++/nitf/include/nitf/FieldDescriptor.hpp index 1ce6ccedb..e2d088c5c 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/FieldDescriptor.hpp +++ b/externals/nitro/modules/c++/nitf/include/nitf/FieldDescriptor.hpp @@ -21,15 +21,17 @@ * */ +#pragma once #ifndef NITRO_nitf_FieldDescriptor_hpp_INCLUDED_ #define NITRO_nitf_FieldDescriptor_hpp_INCLUDED_ -#pragma once #include #include #include #include +#include + #include "nitf/FieldDescriptor.h" #include "nitf/Field.hpp" #include "nitf/Object.hpp" @@ -84,8 +86,7 @@ namespace nitf template inline std::vector getFieldDescriptors(const nitf_StructFieldDescriptor(&descriptors)[N]) { - // constexpr auto extent = std::extent::value; - const std::span s(descriptors, N); + const auto s = sys::make_span(descriptors, N); return getFieldDescriptors(s); } } diff --git a/externals/nitro/modules/c++/nitf/include/nitf/NITFBufferList.hpp b/externals/nitro/modules/c++/nitf/include/nitf/NITFBufferList.hpp index 806559dc1..e03c6c707 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/NITFBufferList.hpp +++ b/externals/nitro/modules/c++/nitf/include/nitf/NITFBufferList.hpp @@ -61,7 +61,7 @@ struct NITRO_NITFCPP_API NITFBuffer std::span getBytes() const noexcept { - return std::span(static_cast(mData), mNumBytes); + return sys::make_span(static_cast(mData), mNumBytes); } }; diff --git a/externals/nitro/modules/c++/nitf/include/nitf/SegmentSource.hpp b/externals/nitro/modules/c++/nitf/include/nitf/SegmentSource.hpp index 4e6357bc8..3a53c3c25 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/SegmentSource.hpp +++ b/externals/nitro/modules/c++/nitf/include/nitf/SegmentSource.hpp @@ -74,9 +74,9 @@ struct NITRO_NITFCPP_API SegmentMemorySource : public SegmentSource SegmentMemorySource(const sys::byte* data, nitf::Off size, nitf::Off start, int byteSkip, bool copyData); - SegmentMemorySource(const std::span& data, nitf::Off start, + SegmentMemorySource(std::span data, nitf::Off start, int byteSkip, bool copyData); - SegmentMemorySource(const std::span& data, nitf::Off start, + SegmentMemorySource(std::span data, nitf::Off start, int byteSkip, bool copyData); SegmentMemorySource(const std::vector& data, nitf::Off start, int byteSkip, bool copyData); diff --git a/externals/nitro/modules/c++/nitf/include/nitf/coda-oss.hpp b/externals/nitro/modules/c++/nitf/include/nitf/coda-oss.hpp index 9a4dbe764..bb4e9720f 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/coda-oss.hpp +++ b/externals/nitro/modules/c++/nitf/include/nitf/coda-oss.hpp @@ -73,6 +73,8 @@ #include #include +#include + #if _MSC_VER #pragma warning(pop) #endif // _MSC_VER diff --git a/externals/nitro/modules/c++/nitf/source/ByteProvider.cpp b/externals/nitro/modules/c++/nitf/source/ByteProvider.cpp index 5d1f564b7..c908b2a8c 100644 --- a/externals/nitro/modules/c++/nitf/source/ByteProvider.cpp +++ b/externals/nitro/modules/c++/nitf/source/ByteProvider.cpp @@ -634,7 +634,7 @@ void ByteProvider::getBytes(const void* imageData, static std::span make_span(const std::vector& v) noexcept { const void* const pData = v.data(); - return std::span(static_cast(pData), v.size()); + return sys::make_span(static_cast(pData), v.size()); } void nitf::ByteProvider::getFileHeader(std::span& result) const noexcept diff --git a/externals/nitro/modules/c++/nitf/source/J2KCompressor.cpp b/externals/nitro/modules/c++/nitf/source/J2KCompressor.cpp index b648f76c8..98648338e 100644 --- a/externals/nitro/modules/c++/nitf/source/J2KCompressor.cpp +++ b/externals/nitro/modules/c++/nitf/source/J2KCompressor.cpp @@ -309,7 +309,7 @@ class TileWriter final for (size_t row = 0; row < resizedTileDims.row; ++row) { const auto srcTileRowStart = tileData + row * tileDims.col; - const std::span src(srcTileRowStart, resizedTileDims.col); + const auto src = sys::make_span(srcTileRowStart, resizedTileDims.col); // partialTileBuffer.data() + row * resizedTileDims.col auto dest = partialTileBuffer.begin(); @@ -390,7 +390,7 @@ class CodestreamOp final mCompressionParams(compressionParams) { mImageBlock.resize(mCompressionParams.getTileDims().area()); - mpImageBlock = std::span(mImageBlock.data(), mImageBlock.size()); + mpImageBlock = sys::make_span(mImageBlock); } CodestreamOp(const CodestreamOp&) = delete; CodestreamOp& operator=(const CodestreamOp&) = delete; @@ -509,8 +509,7 @@ void j2k::Compressor::compress( std::vector& bytesPerTile) const { compressedData.resize(getMaxBytesRequiredToCompress()); - const auto compressedDataView = compress(rawImageData, - std::span(compressedData.data(), compressedData.size()), bytesPerTile); + const auto compressedDataView = compress(rawImageData, sys::make_span(compressedData), bytesPerTile); compressedData.resize(compressedDataView.size()); } @@ -531,7 +530,7 @@ void j2k::Compressor::compressTile( { compressedTile.resize(getMaxBytesRequiredToCompress(1)); std::vector bytesPerTile; - std::span compressedView(compressedTile.data(), compressedTile.size()); + auto compressedView = sys::make_span(compressedTile); compressedView = compressTileSubrange(rawImageData, types::Range(tileIndex, 1), compressedView, bytesPerTile); compressedTile.resize(compressedView.size()); @@ -668,7 +667,7 @@ std::span j2k::Compressor::compressTileSubrange( dest += numBytesThisTile; } - return std::span(compressedData.data(), numBytesWritten); + return sys::make_span(compressedData.data(), numBytesWritten); } diff --git a/externals/nitro/modules/c++/nitf/source/J2KReader.cpp b/externals/nitro/modules/c++/nitf/source/J2KReader.cpp index 0b2a151e0..647c41b67 100644 --- a/externals/nitro/modules/c++/nitf/source/J2KReader.cpp +++ b/externals/nitro/modules/c++/nitf/source/J2KReader.cpp @@ -50,12 +50,12 @@ std::span j2k::Reader::readRegion(uint32_t x0, uint32_t y0, uint32_t x1 uint8_t* pBuf = nullptr; const auto bufSize = impl_.callNativeOrThrow(j2k_Reader_readRegion, x0, y0, x1, y1, &pBuf); buf = make_Buffer(pBuf); // turn over ownership (and test our utility routine) - return std::span(buf.get(), bufSize); + return sys::make_span(buf.get(), bufSize); } std::span j2k::Reader::readRegion(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, std::span buf) { // "buf" is already allocated, maybe from a previous call auto buf_ = buf.data(); const auto bufSize = impl_.callNativeOrThrow(j2k_Reader_readRegion, x0, y0, x1, y1, &buf_); - return std::span(buf_, bufSize); // "bufSize" may have changed + return sys::make_span(buf_, bufSize); // "bufSize" may have changed } \ No newline at end of file diff --git a/externals/nitro/modules/c++/nitf/source/J2KWriter.cpp b/externals/nitro/modules/c++/nitf/source/J2KWriter.cpp index 31f721954..afceb6109 100644 --- a/externals/nitro/modules/c++/nitf/source/J2KWriter.cpp +++ b/externals/nitro/modules/c++/nitf/source/J2KWriter.cpp @@ -77,6 +77,6 @@ void j2k::WriteTiler::setTile(uint32_t tileX, uint32_t tileY, uint32_t i) const auto offset_ = index * tileSize_ * bytes * numComponents_; const auto offset = gsl::narrow(offset_); - const std::span buf(buf_.data() + offset, tileSize_); + const auto buf = sys::make_span(buf_.data() + offset, tileSize_); writer_.setTile(tileX, tileY, buf); } \ No newline at end of file diff --git a/externals/nitro/modules/c++/nitf/source/SegmentSource.cpp b/externals/nitro/modules/c++/nitf/source/SegmentSource.cpp index f74d7a7dc..3a4677890 100644 --- a/externals/nitro/modules/c++/nitf/source/SegmentSource.cpp +++ b/externals/nitro/modules/c++/nitf/source/SegmentSource.cpp @@ -41,18 +41,18 @@ SegmentMemorySource::SegmentMemorySource(const std::string& data, : SegmentMemorySource(data.c_str(), gsl::narrow(data.size()), start, byteSkip, copyData) { } -SegmentMemorySource::SegmentMemorySource(const std::span& data, nitf::Off start, +SegmentMemorySource::SegmentMemorySource(std::span data, nitf::Off start, int byteSkip, bool copyData) : SegmentMemorySource(data.data(), gsl::narrow(data.size()), start, byteSkip, copyData) { } -static const sys::byte* data(const std::span& data) noexcept +static const sys::byte* data(std::span data) noexcept { const void* pData = data.data(); return static_cast(pData); } -SegmentMemorySource::SegmentMemorySource(const std::span& s, nitf::Off start, +SegmentMemorySource::SegmentMemorySource(std::span s, nitf::Off start, int byteSkip, bool copyData) : SegmentMemorySource(data(s), gsl::narrow(s.size()), start, byteSkip, copyData) { @@ -60,13 +60,13 @@ SegmentMemorySource::SegmentMemorySource(const std::span& s, ni SegmentMemorySource::SegmentMemorySource(const std::vector& data, nitf::Off start, int byteSkip, bool copyData) - : SegmentMemorySource(std::span(data.data(), data.size()), start, byteSkip, copyData) + : SegmentMemorySource(sys::make_span(data), start, byteSkip, copyData) { } SegmentMemorySource::SegmentMemorySource(const std::vector& data, nitf::Off start, int byteSkip, bool copyData) - : SegmentMemorySource(std::span(data.data(), data.size()), start, byteSkip, copyData) + : SegmentMemorySource(sys::make_span(data), start, byteSkip, copyData) { } } diff --git a/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp index c4177deb1..e57e2b1e1 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -270,7 +271,7 @@ void test_j2k_nitf_read_region_(const path& fname) const auto height = container.getHeight(); const auto result_ = j2kReader.readRegion(0, 0, width, height, buf); - const std::span result(result_.data(), result_.size()); + const auto result = sys::make_const_span(result_); const auto namePrefix = str::format("image-%d", (i + 1)); // TODO: Update write to only output tiles in read region @@ -351,7 +352,7 @@ TEST_CASE(test_j2k_compress_raw_image) types::RowCol rawDims; std::vector rawImage_; sio::lite::readSIO(inPathname, rawDims, rawImage_); - const std::span rawImage(rawImage_.data(), rawImage_.size()); + const auto rawImage = sys::make_span(rawImage_); const auto& tileDims = rawDims; const size_t numThreads = sys::OS().getNumCPUs() - 1; @@ -361,7 +362,7 @@ TEST_CASE(test_j2k_compress_raw_image) std::vector compressedImage_; std::vector bytesPerBlock; compressor.compress(rawImage, compressedImage_, bytesPerBlock); - const std::span compressedImage(compressedImage_.data(), compressedImage_.size()); + const auto compressedImage = sys::make_span(compressedImage_); const auto sumCompressedBytes = std::accumulate(bytesPerBlock.begin(), bytesPerBlock.end(), gsl::narrow(0)); TEST_ASSERT_EQ(sumCompressedBytes, compressedImage.size()); // "Size of compressed image does not match sum of bytes per block"