Skip to content

Commit

Permalink
Squashed 'externals/nitro/' changes from cdda3982c..3822f6ef3
Browse files Browse the repository at this point in the history
3822f6ef3 Merge branch 'main' into cpp17
8f974e995 NITRO-2.11.3 (#554)
f4ba98270 Merge commit 'd2ea428ce2ead7e3330b671f2b4916fa5fe1c862' into cpp17
d2ea428ce Squashed 'externals/coda-oss/' changes from 7b90b5a46b..d95aa8dd3b
2f048ade3 Merge branch 'main' into cpp17
870aa6afd update to coda-oss 2023-06-05 (#553)

git-subtree-dir: externals/nitro
git-subtree-split: 3822f6ef339d0e90d85ad442200596bc472dff29
  • Loading branch information
Dan Smith authored and Dan Smith committed Jun 5, 2023
1 parent 7998a72 commit 64a32e4
Show file tree
Hide file tree
Showing 41 changed files with 684 additions and 240 deletions.
8 changes: 7 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# NITRO (NITF i/o) Release Notes

## [Version 2.11.3](https://github.com/mdaus/nitro/releases/tag/NITRO-2.11.3); June 5, 2023
* [coda-oss](https://github.com/mdaus/coda-oss) release [2023-06-05](https://github.com/mdaus/coda-oss/releases/tag/2023-06-05)
* Fix display of [certain TREs](https://github.com/mdaus/nitro/issues/529).
* Adjust compiler flags for clean *CMake* builds.
* Implement `DecompressionInterface::adapterFreeBlock()` to fix decompression.

## [Version 2.11.2](https://github.com/mdaus/nitro/releases/tag/NITRO-2.11.2); December 14, 2022
* [coda-oss](https://github.com/mdaus/coda-oss) release [2022-12-14](https://github.com/mdaus/coda-oss/releases/tag/2022-12-14)
* Further work at getting unittests to work better when included elsewhere (e.g., SIX) as **externals**.
Expand All @@ -20,7 +26,7 @@ except that C++14 is now required. [master](https://github.com/mdaus/nitro/tree
* [coda-oss](https://github.com/mdaus/coda-oss) release [2022-08-30](https://github.com/mdaus/coda-oss/releases/tag/2022-08-30)
* Build JPEG decompression as a plug-in.
* tweak unittests so they run in SIX.
* Final C++11 release 🤞🏻; future releases will be C++14 from [main](https://github.com/mdaus/nitro/tree/main).
* ~~Final C++11 release 🤞🏻; future releases will be C++14 from [main](https://github.com/mdaus/nitro/tree/main).~~

## [Version 2.10.11](https://github.com/mdaus/nitro/releases/tag/NITRO-2.10.11); August 2, 2022
* [coda-oss](https://github.com/mdaus/coda-oss) release [2022-08-02](https://github.com/mdaus/coda-oss/releases/tag/2022-08-02)
Expand Down
8 changes: 7 additions & 1 deletion externals/coda-oss/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
```
# coda-oss Release Notes

## [Release 2023-??-??](https://github.com/mdaus/coda-oss/releases/tag/2023-??-??)
## [Release 2023-06-05](https://github.com/mdaus/coda-oss/releases/tag/2023-06-05)
* *zlib* updated to [1.2.13](https://github.com/madler/zlib/releases/tag/v1.2.13).
* new `mem::ComplexView` class to make it easier to process complex data stored in parallel.
* adjust compiler flags for clean *CMake* builds.
* wrap common "file open" routines (e.g., `fopen()`) to support `sys::expandEnvironmentVariables()`.
* add header-only [HighFive](https://github.com/BlueBrain/HighFive) HDF5-wrapper library.
* Added a handful of [HighFive](https://github.com/BlueBrain/HighFive) utility routines.
* `mt::transform_async()` removed, it doesn't match C++17 techniques.'
* Revamp `sys::byteSwap()` for improved type-safety and
[better performance](https://devblogs.microsoft.com/cppblog/a-tour-of-4-msvc-backend-improvements/).
* Added case-insensitive string comparison utilties: `str::eq()` and `str::ne()`;
`xml::lite::Uri`s compare case-insensitive.

## [Release 2022-12-14](https://github.com/mdaus/coda-oss/releases/tag/2022-12-14)
* removed remaining vestiges of `std::auto_ptr`, provide `mem::AutoPtr` for the tiny handful of
Expand Down
2 changes: 2 additions & 0 deletions externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
std::map<std::string, Argument*> longOptionsFlags;
std::vector<Argument*> positionalArgs;

positionalArgs.reserve(mArgs.size());
for (auto& arg_ : mArgs)
{
cli::Argument* arg = arg_.get();
Expand Down Expand Up @@ -336,6 +337,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
}

std::vector < std::string > explodedArgs;
explodedArgs.reserve(args.size());
// next, check for combined short options
for (size_t i = 0, s = args.size(); i < s; ++i)
{
Expand Down
1 change: 1 addition & 0 deletions externals/coda-oss/modules/c++/coda-oss-lite.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
<ClInclude Include="sys\include\sys\SemaphorePosix.h" />
<ClInclude Include="sys\include\sys\SemaphoreWin32.h" />
<ClInclude Include="sys\include\sys\Span.h" />
<ClInclude Include="sys\include\sys\SysInt.h" />
<ClInclude Include="sys\include\sys\StopWatch.h" />
<ClInclude Include="sys\include\sys\String.h" />
<ClInclude Include="sys\include\sys\SystemException.h" />
Expand Down
3 changes: 3 additions & 0 deletions externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@
<ClInclude Include="sys\include\sys\Span.h">
<Filter>sys</Filter>
</ClInclude>
<ClInclude Include="sys\include\sys\SysInt.h">
<Filter>sys</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
Expand Down
14 changes: 7 additions & 7 deletions externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* License along with this program; If not, http://www.gnu.org/licenses/.
*
*/
#pragma once
#ifndef CODA_OSS_coda_oss_bit_h_INCLUDED_
#define CODA_OSS_coda_oss_bit_h_INCLUDED_
#pragma once

#include <stdlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -58,28 +58,28 @@ namespace coda_oss
#if defined(_MSC_VER)
// These routines should generate a single instruction; see
// https://devblogs.microsoft.com/cppblog/a-tour-of-4-msvc-backend-improvements/
inline uint16_t byteswap(uint16_t val)
inline uint16_t byteswap(uint16_t val) noexcept
{
return _byteswap_ushort(val);
}
inline uint32_t byteswap(uint32_t val)
inline uint32_t byteswap(uint32_t val) noexcept
{
return _byteswap_ulong(val);
}
inline uint64_t byteswap(uint64_t val)
inline uint64_t byteswap(uint64_t val) noexcept
{
return _byteswap_uint64(val);
}
#elif defined(__GNUC__)
inline uint16_t byteswap(uint16_t val)
inline uint16_t byteswap(uint16_t val) noexcept
{
return bswap_16(val);
}
inline uint32_t byteswap(uint32_t val)
inline uint32_t byteswap(uint32_t val) noexcept
{
return bswap_32(val);
}
inline uint64_t byteswap(uint64_t val)
inline uint64_t byteswap(uint64_t val) noexcept
{
return bswap_64(val);
}
Expand Down
33 changes: 24 additions & 9 deletions externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifndef CODA_OSS_coda_oss_span_h_INCLUDED_
#define CODA_OSS_coda_oss_span_h_INCLUDED_
#pragma once

#include <type_traits>

#include <type_traits>

#include "coda_oss/namespace_.h"
#include "coda_oss/span_.h"
Expand All @@ -41,21 +45,32 @@ namespace coda_oss

// https://en.cppreference.com/w/cpp/container/span/as_bytes
template <typename T>
span<const byte> as_bytes(span<const T> s) noexcept
inline auto as_bytes(span<const T> s) noexcept
{
const void* const p = s.data();
return span<const byte>(static_cast<const byte*>(p), s.size_bytes());
// https://en.cppreference.com/w/cpp/types/is_trivially_copyable "... serialized to/from binary files ..."
static_assert(std::is_trivially_copyable<T>::value, "must be 'trivially' copyable.");

const void* const p_ = s.data();
auto const p = static_cast<const byte*>(p_);
return span<const byte>(p, s.size_bytes());
}
template <typename T>
span<const byte> as_bytes(span<T> s) noexcept
inline auto as_bytes(span<T> s) noexcept
{
return as_bytes(span<const T>(s.data(), s.size()));
const span<const T> s_(s.data(), s.size());
return as_bytes(s_);
}
template <typename T>
span<byte> as_writable_bytes(span<T> s) noexcept
inline span<byte> as_writable_bytes(span<T> s) noexcept
{
void* const p = s.data();
return span<byte>(static_cast<byte*>(p), s.size_bytes());
// https://en.cppreference.com/w/cpp/types/is_trivially_copyable "... serialized to/from binary files ..."
static_assert(std::is_trivially_copyable<T>::value, "must be 'trivially' copyable.");

static_assert(!std::is_const<T>::value, "T cannot be 'const'");

void* const p_ = s.data();
auto const p = static_cast<byte*>(p_);
return span<byte>(p, s.size_bytes());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ static_assert(CODA_OSS_MAKE_VERSION_MMPB(9999, 9999, 9999, 9999) <= UINT64_MAX,

// Do this ala C++ ... we don't currently have major/minor/patch
//#define CODA_OSS_VERSION_ 20210910L // c.f. __cplusplus
#define CODA_OSS_VERSION_ 2022 ## 0012 ## 0014 ## 0000 ## L
#define CODA_OSS_VERSION_ 2023 ## 0006 ## 0005 ## 0000 ## L

// Use the same macros other projects might want to use; overkill for us.
#define CODA_OSS_VERSION_MAJOR 2022
#define CODA_OSS_VERSION_MINOR 12
#define CODA_OSS_VERSION_PATCH 14
#define CODA_OSS_VERSION_MAJOR 2023
#define CODA_OSS_VERSION_MINOR 6
#define CODA_OSS_VERSION_PATCH 5
#define CODA_OSS_VERSION_BUILD 0
#define CODA_OSS_VERSION CODA_OSS_MAKE_VERSION_MMPB(CODA_OSS_VERSION_MAJOR, CODA_OSS_VERSION_MINOR, CODA_OSS_VERSION_PATCH, CODA_OSS_VERSION_BUILD)

Expand Down
6 changes: 3 additions & 3 deletions externals/coda-oss/modules/c++/mt/include/mt/RequestQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ struct RequestQueue
}

// Check to see if its empty
inline bool isEmpty()
bool isEmpty() const
{
return (mRequestQueue.size() == 0);
return mRequestQueue.empty();
}

// Check the length
inline int length()
int length() const
{
return mRequestQueue.size();
}
Expand Down
6 changes: 3 additions & 3 deletions externals/coda-oss/modules/c++/net/source/URL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,22 @@ bool net::URLParams::contains(std::string key) const
net::URLParams::ParamValues& net::URLParams::get(std::string key)
{
net::URLParams::Params::iterator it = mParams.find(key);
if (it == mParams.end() || it->second.size() == 0)
if (it == mParams.end() || it->second.empty())
throw except::NoSuchKeyException(Ctxt(key));
return it->second;
}

const net::URLParams::ParamValues& net::URLParams::get(std::string key) const
{
net::URLParams::Params::const_iterator it = mParams.find(key);
if (it == mParams.end() || it->second.size() == 0)
if (it == mParams.end() || it->second.empty())
throw except::NoSuchKeyException(Ctxt(key));
return it->second;
}
std::string net::URLParams::getFirst(std::string key) const
{
net::URLParams::Params::const_iterator it = mParams.find(key);
if (it == mParams.end() || it->second.size() == 0)
if (it == mParams.end() || it->second.empty())
throw except::NoSuchKeyException(Ctxt(key));
return it->second.front();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <cmath>

#include <types/RowCol.h>
#include <gsl/gsl.h>

namespace polygon
{
Expand All @@ -47,14 +48,13 @@ namespace polygon
* square will have 1 pixel of its top edge missing.
*/
template <typename PointT>
class Intersections
struct Intersections final
{
public:
/*!
* \class Intersection
* \brief Represents an intersection
*/
struct Intersection
struct Intersection final
{
//! First (inclusive) column
size_t first;
Expand All @@ -63,7 +63,7 @@ class Intersections
size_t last;

//! \return Number of columns
size_t length() const
size_t length() const noexcept
{
return last - first + 1;
}
Expand Down Expand Up @@ -172,19 +172,18 @@ class Intersections
types::RowCol<sys::SSize_T> offset)
{
std::vector<types::RowCol<PointT> > shiftedPoints(points);
for (size_t ii = 0; ii < shiftedPoints.size(); ++ii)
for (auto&& shiftedPoint : shiftedPoints)
{
// Get the polygon points with respect to the offset
shiftedPoints[ii].row -= offset.row;
shiftedPoints[ii].col -= offset.col;
shiftedPoint -= offset;

// TODO: The original implementation did this (plus subtracted 0.5
// from each row and col which we're not doing here).
// Without this small delta, if you have points that are
// right on a row, we skip drawing some rows
// (test_draw_polygon will illustrate this). I wonder if we
// could tweak the sl0 and sl1 logic to avoid this.
PointT& rowPoint(shiftedPoints[ii].row);
PointT& rowPoint(shiftedPoint.row);
if (std::floor(rowPoint) == rowPoint)
{
// Add small amount to move it off the scan line
Expand All @@ -195,7 +194,7 @@ class Intersections
// We need to get all scanline intersections of polygon edges
mIntersections.resize(dims.row);

const sys::SSize_T lastRow = static_cast<sys::SSize_T>(dims.row) - 1;
const auto lastRow = gsl::narrow<sys::SSize_T>(dims.row) - 1;

for (size_t ii = 0; ii < shiftedPoints.size(); ++ii)
{
Expand Down Expand Up @@ -256,9 +255,9 @@ class Intersections
// that situation.
for (sys::SSize_T row = sl0; row <= sl1; ++row)
{
const PointT delt = row - r0;
const PointT sli = c0 + delt * dcdr;
mIntersections[row].push_back(sli);
const auto delt = static_cast<PointT>(row) - r0;
const auto sli = c0 + delt * dcdr;
mIntersections[gsl::narrow<size_t>(row)].push_back(sli);
}
}

Expand All @@ -273,6 +272,12 @@ class Intersections
}
}
}

// `const` member data means copy/move must be implemented
Intersections(const Intersections&) = delete;
Intersections& operator=(const Intersections&) = delete;
Intersections(Intersections&&) = delete;
Intersections& operator=(Intersections&&) = delete;

private:
const types::RowCol<size_t> mDims;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ void sio::lite::FileHeader::addUserData(const std::string& field,
void sio::lite::FileHeader::addUserData(const std::string& field, int data)
{
std::vector<sys::byte> vec;
vec.reserve(sizeof(int));
char* cData = (char*)&data;
for (int i = 0, size = sizeof(int); i < size; ++i)
vec.push_back((sys::byte)cData[i]);
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/str/include/str/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct CODA_OSS_API Format final
return mString;
}

operator std::string& ()
operator std::string& () noexcept
{
return mString;
}
Expand Down
12 changes: 10 additions & 2 deletions externals/coda-oss/modules/c++/str/include/str/Manip.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ inline std::string join(const std::vector<T>& toks, const std::string& with)
if (toks.empty())
return "";

const auto len = static_cast<int>(toks.size());
const auto len = toks.size();
std::ostringstream oss;
int i = 0;
size_t i = 0;
for (; i < len - 1; i++)
{
oss << str::toString(toks[i]) << with;
Expand All @@ -196,6 +196,14 @@ inline std::string join(const std::vector<T>& toks, const std::string& with)
return oss.str();
}

// CASE INSENSTIVE string comparision routines.
// Short names w/o a "case insenstive" indicator would seem OK as
// normal (i.e., case sensitive) comparisons will use `==` and `!=` operators.
//
// Note that calling ne() directly can be faster than !eq() because the
// comparison can stop as soon as a mis-match is found.
CODA_OSS_API bool eq(const std::string& lhs, const std::string& rhs) noexcept;
CODA_OSS_API bool ne(const std::string& lhs, const std::string& rhs) noexcept;

}

Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/str/include/str/Tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Tokenizer
* Method to return the resultant vector
* \return The vector that was created by the tokenizer
*/
operator Tokenizer::Tokens& ()
operator Tokenizer::Tokens& () noexcept
{
return vec;
}
Expand Down
Loading

0 comments on commit 64a32e4

Please sign in to comment.