From 845f0c2b60c8c7c5f02422d6aea6263e485c627c Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 19 Apr 2022 17:38:34 -0400 Subject: [PATCH] latest from coda-oss and nitro --- .../mt/WorkSharingBalancedRunnable1D.h | 4 +--- .../c++/str/include/str/EncodedString.h | 2 ++ .../modules/c++/str/include/str/Manip.h | 8 ++++++- .../modules/c++/str/source/EncodedString.cpp | 5 ++++ .../c++/str/unittests/test_base_convert.cpp | 23 ++++++++++++++++++- .../modules/c++/nitf/include/nitf/exports.hpp | 20 +++++++++------- .../c++/nitf/unittests/test_tre_mods++.cpp | 2 +- 7 files changed, 50 insertions(+), 14 deletions(-) diff --git a/externals/coda-oss/modules/c++/mt/include/mt/WorkSharingBalancedRunnable1D.h b/externals/coda-oss/modules/c++/mt/include/mt/WorkSharingBalancedRunnable1D.h index caced9c51..fa4af345c 100644 --- a/externals/coda-oss/modules/c++/mt/include/mt/WorkSharingBalancedRunnable1D.h +++ b/externals/coda-oss/modules/c++/mt/include/mt/WorkSharingBalancedRunnable1D.h @@ -247,9 +247,7 @@ void runWorkSharingBalanced1D(size_t numElements, { threadPoolEndElements.push_back(numElements); - threadPoolCounters.push_back( - std::shared_ptr( - new sys::AtomicCounter(0))); + threadPoolCounters.push_back(std::make_shared(0)); const types::Range range(0, numElements); WorkSharingBalancedRunnable1D(range, diff --git a/externals/coda-oss/modules/c++/str/include/str/EncodedString.h b/externals/coda-oss/modules/c++/str/include/str/EncodedString.h index ea12d799f..407beaac4 100644 --- a/externals/coda-oss/modules/c++/str/include/str/EncodedString.h +++ b/externals/coda-oss/modules/c++/str/include/str/EncodedString.h @@ -56,6 +56,8 @@ class EncodedString final return s_; } + // No "public" operator=() for these; this class is mostly for storage and/or conversion, + // not extensive manipulation. Create a new instance and assign/move that. void assign(coda_oss::u8string::const_pointer); void assign(str::W1252string::const_pointer); void assign(std::string::const_pointer); diff --git a/externals/coda-oss/modules/c++/str/include/str/Manip.h b/externals/coda-oss/modules/c++/str/include/str/Manip.h index 2a2707867..73d55cb4c 100644 --- a/externals/coda-oss/modules/c++/str/include/str/Manip.h +++ b/externals/coda-oss/modules/c++/str/include/str/Manip.h @@ -35,7 +35,12 @@ namespace str { -// non-const overload for .data() in C++17 + +CODA_OSS_disable_warning_push +#if _MSC_VER +#pragma warning(disable: 26460) //The reference argument 's' for function 'str::data' can be marked as const (con.3). +#endif + // non-const overload for .data() in C++17 template inline CharT* data(std::basic_string& s) noexcept { @@ -50,6 +55,7 @@ inline CharT* data(std::basic_string& s) noexcept CODA_OSS_disable_warning_pop #endif // CODA_OSS_cpp17 } +CODA_OSS_disable_warning_pop template inline const CharT* data(const std::basic_string& s) noexcept // to make generic programming easier { diff --git a/externals/coda-oss/modules/c++/str/source/EncodedString.cpp b/externals/coda-oss/modules/c++/str/source/EncodedString.cpp index d19b1eb2e..5e0652d19 100644 --- a/externals/coda-oss/modules/c++/str/source/EncodedString.cpp +++ b/externals/coda-oss/modules/c++/str/source/EncodedString.cpp @@ -122,6 +122,11 @@ str::EncodedString& str::EncodedString::operator=(const EncodedString& es) } return *this; } +str::EncodedString::EncodedString(const EncodedString& es) +{ + *this = es; +} + str::EncodedString& str::EncodedString::operator=(EncodedString&& es) noexcept { if (this != &es) diff --git a/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp b/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp index 0654872d6..bc5b5256b 100644 --- a/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp +++ b/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp @@ -385,8 +385,29 @@ TEST_CASE(test_EncodedString) { str::EncodedString es; TEST_ASSERT_TRUE(es.native().empty()); - es = str::EncodedString("abc"); + { + str::EncodedString es_copy(es); // copy + TEST_ASSERT_TRUE(es_copy.native().empty()); + } + es = str::EncodedString("abc"); // assignment + TEST_ASSERT_EQ(es.native(), "abc"); + { + str::EncodedString es_copy(es); // copy, again; this time w/o default content + TEST_ASSERT_EQ(es_copy.native(), "abc"); + } + + str::EncodedString abc(es); // copy, for use below + TEST_ASSERT_EQ(abc.native(), "abc"); + + str::EncodedString es2; + es = std::move(es2); // move assignment + TEST_ASSERT_TRUE(es.native().empty()); + str::EncodedString abc_(abc); // copy + es = std::move(abc_); // move assignment, w/o default content TEST_ASSERT_EQ(es.native(), "abc"); + + str::EncodedString es3(std::move(abc)); // move constructor + TEST_ASSERT_EQ(es3.native(), "abc"); } int main(int, char**) diff --git a/externals/nitro/modules/c++/nitf/include/nitf/exports.hpp b/externals/nitro/modules/c++/nitf/include/nitf/exports.hpp index 6d7650504..7baed9f99 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/exports.hpp +++ b/externals/nitro/modules/c++/nitf/include/nitf/exports.hpp @@ -2,21 +2,26 @@ #define NITRO_nitf_exports_hpp_INCLUDED_ #pragma once -// Use Windows naming conventions (DLL, LIB) because this really only matters -// for _MSC_VER, see below. +// Need to specify how this module will be consumed, either NITRO_NITFCPP_LIB (static library) +// or NITRO_NITFCPP_DLL (aka "shared" library). +// +// Use Windows naming conventions (DLL, LIB) because this really only matters for _MSC_VER, see below. #if !defined(NITRO_NITFCPP_LIB) && !defined(NITRO_NITFCPP_DLL) - // Building a static library (not a DLL) is the default. #define NITRO_NITFCPP_LIB 1 + //#define NITRO_NITFCPP_DLL 1 #endif -#if !defined(NITRO_NITFCPP_DLL) - #if defined(NITRO_NITFCPP_EXPORTS) && defined(NITRO_NITFCPP_LIB) +#if defined(NITRO_NITFCPP_EXPORTS) + #if defined(NITRO_NITFCPP_LIB) #error "Can't export from a LIB'" #endif - #if !defined(NITRO_NITFCPP_LIB) + #if !defined(NITRO_NITFCPP_DLL) #define NITRO_NITFCPP_DLL 1 #endif #endif +#if defined(NITRO_NITFCPP_LIB) && defined(NITRO_NITFCPP_DLL) + #error "Both NITRO_NITFCPP_LIB and NITRO_NITFCPP_DLL are #define'd'" +#endif // The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the NITRO_NITFCPP_EXPORTS @@ -25,11 +30,10 @@ // NITRO_NITFCPP_API functions as being imported from a DLL, whereas this DLL sees symbols // defined with this macro as being exported. // https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html -#if NITRO_NITFCPP_EXPORTS +#ifdef NITRO_NITFCPP_EXPORTS #if defined(__GNUC__) // && HAVE_VISIBILITY #define NITRO_NITFCPP_API __attribute__((visibility("default"))) #elif defined(_MSC_VER) // && (defined(_WINDLL) && !defined(_LIB)) - // Visual Studio projects define _WINDLL or _LIB, but not the compiler #define NITRO_NITFCPP_API __declspec(dllexport) #else // https://stackoverflow.com/a/2164853/8877 diff --git a/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp index d81d3ff72..cf067f1a6 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp @@ -64,7 +64,7 @@ // actually hook this up. But it's kind of neat code that I don't want to lose. struct /*namespace*/ TREs { - class NITRO_NITFCPP_API ENGRDA final + class ENGRDA final { nitf::TRE tre_;