From 1c6328b4ea28f44694e46081e859945802ee89ca Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 1 Dec 2023 11:05:43 -0500 Subject: [PATCH] Squashed 'externals/nitro/' changes from b5612a7df..f6179b4e1 f6179b4e1 Merge branch 'main' into cpp17 09f2f458f use $(SolutionDir) to get to externals 19b260009 Merge branch 'main' into cpp17 3de4c5059 latest from CODA-OSS (#605) b5d609a0a need #pragma warning(disable) outside push/pop 185f02f14 Merge commit '5efbb0c81357a6ee4da4209e42668c942cb915da' into cpp17 5efbb0c81 Squashed 'externals/coda-oss/' changes from aba8366d8b..0ed92d85a7 0678478cb latest from CODA-OSS 3afd90921 develop/sync_externals d0d99025d Squashed 'externals/coda-oss/' changes from 1ec9a072c4..aba8366d8b c16779d74 Merge commit 'd0d99025d060792e63273741fab6e4a99700b49a' into cpp17 2f4fef813 latest from CODA-OSS 261f3752f Merge branch 'main' into cpp17 dc3a8ecf0 export more symbols (#604) 22f11f42b build as a DLL in Visual Studio (#603) 8d8184c27 NITRO can now build DLLs (#602) d3f58f038 added environment variable to enable pre-loading of TREs (#601) 4f1a05b23 /guard:cf 85a113021 Merge branch 'main' of https://github.com/mdaus/nitro a1cec9cf6 Merge branch 'main' of https://github.com/mdaus/nitro 6801fa735 Merge branch 'main' of https://github.com/mdaus/nitro eca918471 /guard:cf 5d540334b /guard:cf git-subtree-dir: externals/nitro git-subtree-split: f6179b4e11c0b236b0838ad9bd17c9591194b09a --- UnitTest/UnitTest.cpp | 4 +- UnitTest/UnitTest.vcxproj | 13 +- UnitTest/pch.h | 11 +- externals/coda-oss/UnitTest/UnitTest.vcxproj | 8 +- externals/coda-oss/cmake/CodaBuild.cmake | 4 + .../coda-oss/modules/c++/coda-oss.vcxproj | 9 +- .../modules/c++/coda-oss.vcxproj.filters | 5 + .../c++/coda_oss/include/coda_oss/mdspan.h | 73 +++++++++ .../c++/coda_oss/include/coda_oss/mdspan_.h | 151 ++++++++++++++++++ .../c++/coda_oss/include/coda_oss/optional.h | 7 +- .../c++/config/include/config/Exports.h | 34 ++-- .../coda-oss/modules/c++/gsl/CMakeLists.txt | 2 - .../c++/hdf5.lite/include/hdf5/lite/SpanRC.h | 81 +--------- .../hdf5.lite/include/hdf5/lite/highfive.h | 6 +- .../c++/hdf5.lite/unittests/test_highfive.cpp | 22 +-- .../modules/c++/io/include/io/Serializable.h | 6 +- .../c++/logging/include/logging/Setup.h | 4 +- externals/coda-oss/modules/c++/pch.h | 10 +- .../c++/plugin/include/plugin/ErrorHandler.h | 8 +- .../sio.lite/include/sio/lite/FileHeader.h | 4 +- .../sio.lite/include/sio/lite/FileReader.h | 4 - .../sio.lite/include/sio/lite/SioFileReader.h | 7 +- .../sio.lite/include/sio/lite/StreamReader.h | 4 +- .../modules/c++/std/include/import/std.h | 1 + .../modules/c++/std/include/std/mdspan | 46 ++++++ .../modules/c++/sys/include/sys/DLL.h | 5 +- .../modules/c++/sys/include/sys/FileFinder.h | 15 +- .../c++/sys/include/sys/sys_filesystem.h | 1 + .../c++/tiff/include/tiff/FileReader.h | 2 +- .../c++/tiff/include/tiff/FileWriter.h | 2 +- .../modules/c++/tiff/include/tiff/Header.h | 6 +- .../modules/c++/tiff/include/tiff/IFD.h | 6 +- .../modules/c++/tiff/include/tiff/IFDEntry.h | 10 +- .../c++/tiff/include/tiff/ImageReader.h | 5 +- .../c++/tiff/include/tiff/ImageWriter.h | 5 +- .../modules/c++/tiff/include/tiff/KnownTags.h | 22 ++- .../c++/tiff/include/tiff/TiffFileReader.h | 6 +- .../c++/tiff/include/tiff/TiffFileWriter.h | 7 +- .../c++/tiff/include/tiff/TypeFactory.h | 6 +- .../modules/c++/tiff/source/KnownTags.cpp | 8 - .../modules/c++/types/include/types/RowCol.h | 8 +- .../c++/xml.lite/include/xml/lite/Element.h | 2 +- modules/c++/nitf-c++.vcxproj | 15 +- modules/c++/nitf/apps/show_nitf++/pch.h | 5 - .../nitf/apps/show_nitf++/show_nitf++.vcxproj | 7 +- modules/c++/nitf/include/nitf/coda-oss.hpp | 1 + modules/c++/nitf/include/nitf/exports.hpp | 40 +++-- modules/c++/pch.h | 11 +- modules/c/j2k/J2KCompress.vcxproj | 4 +- modules/c/j2k/J2KDecompress.vcxproj | 4 +- modules/c/j2k/source/OpenJPEGImpl.c | 8 + modules/c/nitf-c.vcxproj | 15 +- modules/c/nitf-c.vcxproj.filters | 3 + modules/c/nitf/TEST_DES.vcxproj | 8 +- modules/c/nitf/include/nitf/BandInfo.h | 2 +- modules/c/nitf/include/nitf/Defines.h | 2 +- modules/c/nitf/include/nitf/Field.h | 4 +- modules/c/nitf/include/nitf/ImageIO.h | 36 ++--- modules/c/nitf/include/nitf/NitfWriter.h | 8 +- .../c/nitf/include/nitf/PluginIdentifier.h | 2 +- modules/c/nitf/include/nitf/PluginRegistry.h | 8 +- modules/c/nitf/include/nitf/System.h | 2 +- modules/c/nitf/source/Field.c | 4 +- modules/c/nitf/source/ImageIO.c | 4 +- modules/c/nitf/source/PluginRegistry.c | 85 ++++++++-- modules/c/nitf/source/TRE.c | 2 +- modules/c/nitf/source/TREs.c | 4 +- modules/c/nrt/include/nrt/Defines.h | 15 ++ modules/c/nrt/include/nrt/Error.h | 4 +- modules/c/nrt/include/nrt/Exports.h | 107 +++++++++++++ modules/c/nrt/include/nrt/Types.h | 10 +- modules/c/nrt/include/nrt/Utils.h | 22 +-- modules/c/nrt/source/Utils.c | 16 +- modules/c/pch.h | 6 + nitro.sln | 12 +- 75 files changed, 781 insertions(+), 335 deletions(-) create mode 100644 externals/coda-oss/modules/c++/coda_oss/include/coda_oss/mdspan.h create mode 100644 externals/coda-oss/modules/c++/coda_oss/include/coda_oss/mdspan_.h create mode 100644 externals/coda-oss/modules/c++/std/include/std/mdspan create mode 100644 modules/c/nrt/include/nrt/Exports.h diff --git a/UnitTest/UnitTest.cpp b/UnitTest/UnitTest.cpp index 96add941b2..ea4c5718fd 100644 --- a/UnitTest/UnitTest.cpp +++ b/UnitTest/UnitTest.cpp @@ -8,6 +8,8 @@ TEST_MODULE_INITIALIZE(methodName) { // module initialization code - nitf_PluginRegistry_PreloadedTREHandlersEnable(NRT_TRUE); + //nitf_PluginRegistry_PreloadedTREHandlersEnable(NRT_TRUE); + _putenv("NITF_PRELOADED_TRE_HANDLERS_ENABLE=default"); + nitf::Test::j2kSetNitfPluginPath(); } \ No newline at end of file diff --git a/UnitTest/UnitTest.vcxproj b/UnitTest/UnitTest.vcxproj index 386b6ec315..9ea47fcc6f 100644 --- a/UnitTest/UnitTest.vcxproj +++ b/UnitTest/UnitTest.vcxproj @@ -58,7 +58,7 @@ Level4 true $(ProjectDir);$(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)externals\coda-oss\modules\c++;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - _DEBUG;%(PreprocessorDefinitions) + _DEBUG;%(PreprocessorDefinitions);CODA_OSS_LIBRARY_SHARED=1 true pch.h AdvancedVectorExtensions2 @@ -71,6 +71,8 @@ stdc11 true true + Guard + ProgramDatabase Windows @@ -85,7 +87,7 @@ true true $(ProjectDir);$(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)externals\coda-oss\modules\c++;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - NDEBUG;%(PreprocessorDefinitions) + NDEBUG;%(PreprocessorDefinitions);CODA_OSS_LIBRARY_SHARED=1 true pch.h AdvancedVectorExtensions2 @@ -96,6 +98,7 @@ stdcpp17 stdc11 true + Guard Windows @@ -257,15 +260,15 @@ + + {9997e895-5161-4ddf-8f3f-099894cb2f21} + {8f357a19-799e-4971-850e-3f28485c130b} {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - {78849481-d356-4cc7-b182-31c21f857ed1} - diff --git a/UnitTest/pch.h b/UnitTest/pch.h index 37e984a9ed..86707841a5 100644 --- a/UnitTest/pch.h +++ b/UnitTest/pch.h @@ -20,20 +20,15 @@ // We're building in Visual Studio ... used to control where we get a little bit of config info #define NITRO_PCH 1 +#ifndef CODA_OSS_LIBRARY_SHARED +#define CODA_OSS_LIBRARY_SHARED 1 +#endif #include #include #include #include -#pragma comment(lib, "io-c++") -#pragma comment(lib, "io-c++") -#pragma comment(lib, "except-c++") -#pragma comment(lib, "sys-c++") -#pragma comment(lib, "str-c++") -#pragma comment(lib, "sio.lite-c++.lib") -#pragma comment(lib, "math-c++") -#pragma comment(lib, "mt-c++") #include #include diff --git a/externals/coda-oss/UnitTest/UnitTest.vcxproj b/externals/coda-oss/UnitTest/UnitTest.vcxproj index a0585026c1..87b0d8302a 100644 --- a/externals/coda-oss/UnitTest/UnitTest.vcxproj +++ b/externals/coda-oss/UnitTest/UnitTest.vcxproj @@ -23,15 +23,12 @@ DynamicLibrary true v143 - false Unicode DynamicLibrary - false v143 true - false Unicode @@ -58,7 +55,7 @@ Level4 true $(VCInstallDir)UnitTest\include;$(ProjectDir);$(SolutionDir)modules\c++;$(SolutionDir)modules\c++\avx\include;$(SolutionDir)modules\c++\cli\include;$(SolutionDir)modules\c++\config\include;$(SolutionDir)modules\c++\coda_oss\include;$(SolutionDir)modules\c++\gsl\include;$(SolutionDir)modules\c++\hdf5.lite\include;$(SolutionDir)modules\c++\io\include;$(SolutionDir)modules\c++\std\include;$(SolutionDir)modules\c++\str\include;$(SolutionDir)modules\c++\sys\include;$(SolutionDir)modules\c++\except\include;$(SolutionDir)modules\c++\logging\include;$(SolutionDir)modules\c++\math\include;$(SolutionDir)modules\c++\math.linear\include;$(SolutionDir)modules\c++\math.poly\include;$(SolutionDir)modules\c++\mem\include;$(SolutionDir)modules\c++\mt\include;$(SolutionDir)modules\c++\polygon\include;$(SolutionDir)modules\c++\re\include;$(SolutionDir)modules\c++\types\include;$(SolutionDir)modules\c++\units\include;$(SolutionDir)modules\c++\xml.lite\include;$(SolutionDir)modules\c++\zip\include;$(SolutionDir)modules\drivers;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;%(AdditionalIncludeDirectories) - _DEBUG;%(PreprocessorDefinitions);MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 + _DEBUG;%(PreprocessorDefinitions);MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1;CODA_OSS_LIBRARY_SHARED=1 true pch.h true @@ -88,7 +85,7 @@ true true $(VCInstallDir)UnitTest\include;$(ProjectDir);$(SolutionDir)modules\c++;$(SolutionDir)modules\c++\avx\include;$(SolutionDir)modules\c++\cli\include;$(SolutionDir)modules\c++\config\include;$(SolutionDir)modules\c++\coda_oss\include;$(SolutionDir)modules\c++\gsl\include;$(SolutionDir)modules\c++\hdf5.lite\include;$(SolutionDir)modules\c++\io\include;$(SolutionDir)modules\c++\std\include;$(SolutionDir)modules\c++\str\include;$(SolutionDir)modules\c++\sys\include;$(SolutionDir)modules\c++\except\include;$(SolutionDir)modules\c++\logging\include;$(SolutionDir)modules\c++\math\include;$(SolutionDir)modules\c++\math.linear\include;$(SolutionDir)modules\c++\math.poly\include;$(SolutionDir)modules\c++\mem\include;$(SolutionDir)modules\c++\mt\include;$(SolutionDir)modules\c++\polygon\include;$(SolutionDir)modules\c++\re\include;$(SolutionDir)modules\c++\types\include;$(SolutionDir)modules\c++\units\include;$(SolutionDir)modules\c++\xml.lite\include;$(SolutionDir)modules\c++\zip\include;$(SolutionDir)modules\drivers;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;%(AdditionalIncludeDirectories) - NDEBUG;%(PreprocessorDefinitions);MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 + NDEBUG;%(PreprocessorDefinitions);MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1;CODA_OSS_LIBRARY_SHARED=1 true pch.h true @@ -101,6 +98,7 @@ AdvancedVectorExtensions2 stdcpp17 stdc11 + Speed Windows diff --git a/externals/coda-oss/cmake/CodaBuild.cmake b/externals/coda-oss/cmake/CodaBuild.cmake index ca1c3961b3..c4c859da6e 100644 --- a/externals/coda-oss/cmake/CodaBuild.cmake +++ b/externals/coda-oss/cmake/CodaBuild.cmake @@ -128,8 +128,12 @@ macro(coda_initialize_build) option(BUILD_SHARED_LIBS "Build shared libraries instead of static." OFF) if(BUILD_SHARED_LIBS) set(CODA_LIBRARY_TYPE "shared") + add_definitions(-DCODA_OSS_LIBRARY_SHARED=1) + add_definitions(-UCODA_OSS_LIBRARY_STATIC) else() set(CODA_LIBRARY_TYPE "static") + add_definitions(-DCODA_OSS_LIBRARY_STATIC=1) + add_definitions(-UCODA_OSS_LIBRARY_SHARED) endif() option(CODA_BUILD_TESTS "build tests" ON) diff --git a/externals/coda-oss/modules/c++/coda-oss.vcxproj b/externals/coda-oss/modules/c++/coda-oss.vcxproj index 1199fd0d6f..14e428c45a 100644 --- a/externals/coda-oss/modules/c++/coda-oss.vcxproj +++ b/externals/coda-oss/modules/c++/coda-oss.vcxproj @@ -19,6 +19,8 @@ + + @@ -511,6 +513,7 @@ + @@ -539,7 +542,6 @@ DynamicLibrary - false v143 true @@ -568,7 +570,7 @@ Level4 true - _DEBUG;_LIB;%(PreprocessorDefinitions);CODA_OSS_EXPORTS;CODA_OSS_DLL;MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 + _DEBUG;%(PreprocessorDefinitions);MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1;CODA_OSS_EXPORTS;CODA_OSS_LIBRARY_SHARED=1 pch.h cli\include;coda_oss\include;config\include;dbi\include;except\include;gsl\include;hdf5.lite\include;io\include;logging\include;math\include;math.linear\include;math.poly\include;mem\include;mt\include;net\include;net.ssl\include;plugin\include;polygon\include;re\include;sio.lite\include;std\include;str\include;sys\include;tiff\include;types\include;unique\include;units\include;xml.lite\include;zip\include;$(ProjectDir)include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\$(ProjectName)\out\install\$(Platform)-$(Configuration)\include Use @@ -601,7 +603,7 @@ true true true - NDEBUG;_LIB;%(PreprocessorDefinitions);CODA_OSS_EXPORTS;CODA_OSS_DLL;MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 + NDEBUG;%(PreprocessorDefinitions);MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1;CODA_OSS_EXPORTS;CODA_OSS_LIBRARY_SHARED=1 pch.h cli\include;coda_oss\include;config\include;dbi\include;except\include;gsl\include;hdf5.lite\include;io\include;logging\include;math\include;math.linear\include;math.poly\include;mem\include;mt\include;net\include;net.ssl\include;plugin\include;polygon\include;re\include;sio.lite\include;std\include;str\include;sys\include;tiff\include;types\include;unique\include;units\include;xml.lite\include;zip\include;$(ProjectDir)include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\$(ProjectName)\out\install\$(Platform)-$(Configuration)\include Use @@ -617,6 +619,7 @@ stdc11 true Level3 + Speed diff --git a/externals/coda-oss/modules/c++/coda-oss.vcxproj.filters b/externals/coda-oss/modules/c++/coda-oss.vcxproj.filters index b4c6f3d77f..ce620b81eb 100644 --- a/externals/coda-oss/modules/c++/coda-oss.vcxproj.filters +++ b/externals/coda-oss/modules/c++/coda-oss.vcxproj.filters @@ -952,6 +952,8 @@ tiff + + @@ -1563,5 +1565,8 @@ sys + + std + \ No newline at end of file diff --git a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/mdspan.h b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/mdspan.h new file mode 100644 index 0000000000..3569440f41 --- /dev/null +++ b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/mdspan.h @@ -0,0 +1,73 @@ +/* ========================================================================= + * This file is part of coda_oss-c++ + * ========================================================================= + * + * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * © Copyright 2023, Maxar Technologies, Inc. + * + * coda_oss-c++ is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; If not, + * see . + * + */ +#pragma once + +#include "coda_oss/CPlusPlus.h" + +// This should always work ... it's in a `details` namespace +#include "coda_oss/mdspan_.h" + +// This logic needs to be here rather than so that `coda_oss::mdspan` will +// be the same as `std::mdspan`. +#ifndef CODA_OSS_HAVE_std_mdspan_ + #define CODA_OSS_HAVE_std_mdspan_ 0 // assume no +#endif +#ifndef CODA_OSS_HAVE_experimental_mdspan_ + #define CODA_OSS_HAVE_experimental_mdspan_ 0 // assume no std::experimental::mdspan +#endif +#if CODA_OSS_cpp17 // __has_include + #if __has_include() // not until C++23 + #include + #undef CODA_OSS_HAVE_std_mdspan_ + #define CODA_OSS_HAVE_std_mdspan_ 1 // provided by the implementation, probably C++23 + #endif + + #if CODA_OSS_cpp20 // Can't even #include this file with older C++14/17 compilers! :-( + // Put this in a __has_include so that it's optional. Our simple implemtnation works + // for our needs, and this brings along a lot of code that our older compilers don't + // like. By the time we need more functionality, maybe we'll be using C++23? + // + // Until then, having this available allows checking our implementation against + // something much more real. https://github.com/kokkos/mdspan + #if __has_include("coda_oss/experimental/mdspan") + #include "coda_oss/experimental/mdspan" + #undef CODA_OSS_HAVE_experimental_mdspan_ + #define CODA_OSS_HAVE_experimental_mdspan_ 1 // provided coda_oss/experimental/mdspan + #endif + #endif +#endif // CODA_OSS_cpp17 + +namespace coda_oss +{ + #if CODA_OSS_HAVE_std_mdspan_ + using std::mdspan; + using std::dextents; + #elif CODA_OSS_HAVE_experimental_mdspan_ + using std::experimental::mdspan; + using std::experimental::dextents; + #else + using details::mdspan; + using details::dextents; + #endif +} + diff --git a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/mdspan_.h b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/mdspan_.h new file mode 100644 index 0000000000..b678051d83 --- /dev/null +++ b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/mdspan_.h @@ -0,0 +1,151 @@ +/* ========================================================================= + * This file is part of coda_oss-c++ + * ========================================================================= + * + * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * © Copyright 2023, Maxar Technologies, Inc. + * + * coda_oss-c++ is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; If not, + * see . + * + */ +#pragma once + +#include + +#include + +#include "coda_oss/span.h" + +// This is a simple, partial, and incomplete implementation of `std::mdspan` (in C++23). +// https://en.cppreference.com/w/cpp/container/mdspan +// +// Why? Our (current) needs are much more limited than all the use-cases for `std::mdspan`: +// dynamic (not static) extents, rank of 2 (rows × cols), contiguous memory, ... +// By the time we really need more features, maybe we'll be using C++23? +namespace coda_oss +{ +namespace details +{ + // https://en.cppreference.com/w/cpp/container/mdspan/extents +template +struct dextents final // this is actually supposed to be an alias template with all dynamic extents +{ + static_assert(Rank == 2, "Rank must have a value of 2"); + using index_type = IndexType; + using size_type = index_type; + using rank_type = size_t; + + constexpr dextents() = default; + + // These are supposed to be templates, but we don't need that complication right now. + constexpr dextents(index_type i0, index_type i1) noexcept : exts_{i0, i1} + { + } + constexpr explicit dextents(const std::array& exts) noexcept : exts_(exts) + { + } + + dextents(const dextents&) = default; + dextents& operator=(const dextents&) = default; + dextents(dextents&&) = default; + dextents& operator=(dextents&&) = default; + + constexpr index_type extent(rank_type r) const noexcept + { + return exts_[r]; + } + + static constexpr auto rank() noexcept + { + return Rank; + } + +private: + std::array exts_; +}; + +template +class mdspan final +{ + coda_oss::span s_; // `span` instead of a raw pointer to get more range checking. + TExtents ext_; + + // c.f., `types::RowCol` + template + static size_t area(const dextents& exts) + { + return exts.extent(0) * exts.extent(1); + } + +public: + using extents_type = TExtents; + using size_type = typename extents_type::size_type; + using data_handle_type = T*; + using reference = T&; + + constexpr mdspan() = default; + + // Again, these are supposed to be templates ... + mdspan(data_handle_type p, const extents_type& ext) noexcept : s_(p, area(ext)), ext_(ext) + { + } + mdspan(data_handle_type p, const std::array& dims) noexcept : mdspan(p, extents_type(dims)) + { + } + + mdspan(const mdspan&) = default; + mdspan& operator=(const mdspan&) = default; + mdspan(mdspan&&) = default; + mdspan& operator=(mdspan&&) = default; + + constexpr data_handle_type data_handle() const noexcept + { + return s_.data(); + } + + /*constexpr*/ reference operator[](size_t idx) const noexcept + { + assert(idx < size()); // prevents "constexpr" in C++11 + return data_handle()[idx]; + } + /*constexpr*/ reference operator()(size_t r, size_t c) const noexcept + { + const auto offset = (r * extent(1)) + c; + return (*this)[offset]; + } + + constexpr size_t size() const noexcept + { + return s_.size(); + } + + constexpr bool empty() const noexcept + { + return s_.empty(); + } + + auto extent(size_type rank) const + { + return ext_.extent(rank); + } + + static constexpr auto rank() noexcept + { + return extents_type::rank(); + } +}; +} +} + diff --git a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/optional.h b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/optional.h index f1fab3a0b1..86298871cf 100644 --- a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/optional.h +++ b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/optional.h @@ -24,6 +24,9 @@ #include "coda_oss/CPlusPlus.h" +// always compile; it's in a details namespace +#include "coda_oss/optional_.h" + // This logic needs to be here rather than so that `coda_oss::optional` will // be the same as `std::optional`. #ifndef CODA_OSS_HAVE_std_optional_ @@ -37,10 +40,6 @@ #endif #endif // CODA_OSS_cpp17 -#if !CODA_OSS_HAVE_std_optional_ -#include "coda_oss/optional_.h" -#endif - namespace coda_oss { #if CODA_OSS_HAVE_std_optional_ diff --git a/externals/coda-oss/modules/c++/config/include/config/Exports.h b/externals/coda-oss/modules/c++/config/include/config/Exports.h index 6b77d9fd74..71949e7c7b 100644 --- a/externals/coda-oss/modules/c++/config/include/config/Exports.h +++ b/externals/coda-oss/modules/c++/config/include/config/Exports.h @@ -1,22 +1,30 @@ -#ifndef CODA_OSS_config_Exports_h_INCLUDED_ -#define CODA_OSS_config_Exports_h_INCLUDED_ #pragma once #include "config/compiler_extensions.h" -// Need to specify how this code will be consumed, either CODA_OSS_LIB (static library) -// or CODA_OSS_DLL (aka "shared" library). For DLLs, it needs to be set for BOTH +// Need to specify how this code will be consumed, either CODA_OSS_LIB_ (static library) +// or CODA_OSS_DLL_ (aka "shared" library). For DLLs, it needs to be set for BOTH // "exporting" (building this code) and "importing" (consuming). // // Use Windows naming conventions (DLL, LIB) because this really only matters for _MSC_VER, see below. -#if !defined(CODA_OSS_LIB) && !defined(CODA_OSS_DLL) - #define CODA_OSS_LIB 1 - //#define CODA_OSS_DLL 1 +#if !defined(CODA_OSS_LIB_) && !defined(CODA_OSS_DLL_) + #if CODA_OSS_LIBRARY_SHARED + #if CODA_OSS_LIBRARY_STATIC + #error "CODA_OSS_LIBRARY_SHARED already #define'd'" + #endif + #define CODA_OSS_DLL_ 1 // Symbols must be exported and imported (see below). + #else + // CODA_OSS_LIBRARY_STATIC doesn't have to be defined + #define CODA_OSS_LIB_ 1 // Static library, all symbols visible. + #endif #endif -#if defined(CODA_OSS_LIB) && defined(CODA_OSS_DLL) - #error "Both CODA_OSS_LIB and CODA_OSS_DLL are #define'd'" +#if !defined(CODA_OSS_LIB_) && !defined(CODA_OSS_DLL_) + #error "One of CODA_OSS_LIB_ pr CODA_OSS_DLL_ must be #define'd'" #endif -#if defined(CODA_OSS_EXPORTS) && defined(CODA_OSS_LIB) +#if defined(CODA_OSS_LIB_) && defined(CODA_OSS_DLL_) + #error "Both CODA_OSS_LIB_ and CODA_OSS_DLL_ are #define'd'" +#endif +#if defined(CODA_OSS_EXPORTS) && defined(CODA_OSS_LIB_) #error "Can't export from a LIB'" #endif @@ -35,10 +43,10 @@ // We need to know whether we're consuming (importing) a DLL or static LIB // The default is a static LIB as that's what existing code/builds expect. - #ifdef CODA_OSS_DLL + #ifdef CODA_OSS_DLL_ // Actually, it seems that the linker is able to figure this out from the .LIB, so // there doesn't seem to be a need for __declspec(dllimport). Clients don't - // need to #define CODA_OSS_DLL ... ? Well, almost ... it looks + // need to #define CODA_OSS_DLL_ ... ? Well, almost ... it looks // like __declspec(dllimport) is needed to get virtual "inline"s (e.g., // destructors) correct. #define CODA_OSS_API CODA_OSS_library_import @@ -50,5 +58,3 @@ #if defined(_MSC_VER) #pragma warning(disable: 4251) // '...' : class '...' needs to have dll-interface to be used by clients of struct '...' #endif - -#endif // CODA_OSS_config_Exports_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/gsl/CMakeLists.txt b/externals/coda-oss/modules/c++/gsl/CMakeLists.txt index 6f17aa7797..10d694163b 100644 --- a/externals/coda-oss/modules/c++/gsl/CMakeLists.txt +++ b/externals/coda-oss/modules/c++/gsl/CMakeLists.txt @@ -4,5 +4,3 @@ coda_add_module( ${MODULE_NAME} VERSION 1.0 DEPS config-c++) - - diff --git a/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/SpanRC.h b/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/SpanRC.h index 9392890bb2..aea2d9c51b 100644 --- a/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/SpanRC.h +++ b/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/SpanRC.h @@ -20,22 +20,11 @@ * */ +#pragma once #ifndef CODA_OSS_hdf5_lite_SpanRC_h_INCLUDED_ #define CODA_OSS_hdf5_lite_SpanRC_h_INCLUDED_ -#pragma once -/*! - * \file SpanRC.h - * - * This is a super-simple version of C++23's mdspan. It's here because 1) don't want widespread use, and - * 2) CODA already has a View2D. - */ - -#include - -#include "config/Exports.h" -#include "coda_oss/span.h" -#include "types/RowCol.h" +#include "coda_oss/mdspan.h" namespace hdf5 { @@ -43,71 +32,7 @@ namespace lite { template -struct SpanRC final -{ - using size_type = types::RowCol; - using element_type = T; - using pointer = T*; - using reference = T&; - - SpanRC() = default; - SpanRC(pointer p, size_type rc) noexcept : s_(p, rc.area()), rc_(rc) - { - } - SpanRC(pointer p, size_t r, size_t c) noexcept : SpanRC(p, size_type(r, c)) - { - } - SpanRC(const SpanRC&) noexcept = default; - - constexpr pointer data() const noexcept - { - return s_.data(); - } - - /*constexpr*/ reference operator[](size_t idx) const noexcept - { - assert(idx < size()); // prevents "constexpr" in C++11 - return data()[idx]; - } - /*constexpr*/ reference operator()(size_t r, size_t c) const noexcept - { - const auto offset = (r * dims().col) + c; - return (*this)[offset]; - } - /*constexpr*/ reference operator[](size_type idx) const noexcept - { - return (*this)(idx.row, idx.col); - } - - constexpr size_t size() const noexcept - { - assert(s_.size() == rc_.area()); - return s_.size(); - } - constexpr size_t area() const noexcept - { - return size(); - } - - constexpr size_type size_bytes() const noexcept - { - return s_.size_bytes(); - } - - constexpr bool empty() const noexcept - { - return s_.empty(); - } - - const auto& dims() const - { - return rc_; - } - - private: - coda_oss::span s_; - types::RowCol rc_; -}; +using SpanRC = coda_oss::mdspan>; } } diff --git a/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/highfive.h b/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/highfive.h index fb276e681c..d5d91987bb 100644 --- a/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/highfive.h +++ b/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/highfive.h @@ -56,10 +56,10 @@ inline auto vv_load(const H5Easy::File& file, const std::string& dataset_name) template inline HighFive::DataSet writeDataSet(H5Easy::File& file, const std::string& dataset_name, SpanRC data /*, TODO ...*/) { - const std::vector dims{data.dims().row, data.dims().col}; + const std::vector dims{data.extent(0), data.extent(1)}; const HighFive::DataSpace dataspace{dims}; auto retval = file.createDataSet(dataset_name, dataspace); - retval.write_raw(data.data()); + retval.write_raw(data.data_handle()); return retval; } @@ -87,7 +87,7 @@ inline SpanRC readDataSet(const HighFive::DataSet& dataSet, std::vector& r result.resize(dims.area()); dataSet.read(result.data()); - return SpanRC(result.data(), dims); + return SpanRC(result.data(), std::array{dims.row, dims.col}); } template diff --git a/externals/coda-oss/modules/c++/hdf5.lite/unittests/test_highfive.cpp b/externals/coda-oss/modules/c++/hdf5.lite/unittests/test_highfive.cpp index f54526ab93..9fbfd76547 100644 --- a/externals/coda-oss/modules/c++/hdf5.lite/unittests/test_highfive.cpp +++ b/externals/coda-oss/modules/c++/hdf5.lite/unittests/test_highfive.cpp @@ -53,10 +53,11 @@ TEST_CASE(test_highfive_load) { std::vector lat; const auto rc = hdf5::lite::loadDataSet(file, "/g4/lat", lat); + static_assert(decltype(rc)::rank() == 2, "wrong rank()"); TEST_ASSERT_EQ(lat.size(), 19); - TEST_ASSERT_EQ(lat.size(), rc.area()); - TEST_ASSERT_EQ(rc.dims().row, 19); - TEST_ASSERT_EQ(rc.dims().col, 1); + TEST_ASSERT_EQ(lat.size(), rc.size()); + TEST_ASSERT_EQ(rc.extent(0), 19); + TEST_ASSERT_EQ(rc.extent(1), 1); TEST_ASSERT_ALMOST_EQ(lat[0], -90.0); TEST_ASSERT_ALMOST_EQ(lat[0], -lat[18]); } @@ -103,9 +104,9 @@ template static auto read_complex(const HighFive::DataSet& r, const HighFive::DataSet& i) { std::vector r_result; - hdf5::lite::readDataSet(r, r_result); + std::ignore = hdf5::lite::readDataSet(r, r_result); std::vector i_result; - hdf5::lite::readDataSet(i, i_result); + std::ignore = hdf5::lite::readDataSet(i, i_result); return std::make_pair(r, i); } template @@ -405,11 +406,11 @@ TEST_CASE(test_highfive_write) const types::RowCol dims{10, 20}; std::vector data_(dims.area()); - const hdf5::lite::SpanRC data(data_.data(), dims); + hdf5::lite::SpanRC data(data_.data(), std::array{dims.row, dims.col}); double d = 0.0; - for (size_t r = 0; r result; const auto rc = hdf5::lite::loadDataSet(file, "/DS1", result); - TEST_ASSERT(rc.dims() == dims); + TEST_ASSERT(rc.extent(0) == dims.row); + TEST_ASSERT(rc.extent(1) == dims.col); TEST_ASSERT_EQ(dims.area(), result.size()); for (size_t i = 0; i < result.size(); i++) { diff --git a/externals/coda-oss/modules/c++/io/include/io/Serializable.h b/externals/coda-oss/modules/c++/io/include/io/Serializable.h index e6d2363ae1..4db6eeab7e 100644 --- a/externals/coda-oss/modules/c++/io/include/io/Serializable.h +++ b/externals/coda-oss/modules/c++/io/include/io/Serializable.h @@ -19,10 +19,12 @@ * see . * */ - +#pragma once #ifndef __IO_SERIALIZABLE_H__ #define __IO_SERIALIZABLE_H__ +#include "config/Exports.h" + #include "io/InputStream.h" #include "io/OutputStream.h" @@ -46,7 +48,7 @@ namespace io * This object has a known derived type SOAPMessage, which is concretely * defined to handle SOAP objects */ -struct Serializable +struct CODA_OSS_API Serializable { Serializable() = default; virtual ~Serializable() noexcept(false) {} diff --git a/externals/coda-oss/modules/c++/logging/include/logging/Setup.h b/externals/coda-oss/modules/c++/logging/include/logging/Setup.h index ed6334d6e4..763767a49f 100644 --- a/externals/coda-oss/modules/c++/logging/include/logging/Setup.h +++ b/externals/coda-oss/modules/c++/logging/include/logging/Setup.h @@ -20,6 +20,7 @@ * */ +#pragma once #ifndef CODA_OSS_logging_Setup_h_INCLUDED_ #define CODA_OSS_logging_Setup_h_INCLUDED_ @@ -29,6 +30,7 @@ #include "mem/SharedPtr.h" #include "logging/Logger.h" #include "sys/filesystem.h" +#include "config/Exports.h" namespace logging { @@ -48,7 +50,7 @@ using path = coda_oss::filesystem::path; // still used in SWIG bindings * \param logCount - number of rotating logs to keep (default: 0 no rotation) * \param logBytes - number of bytes per rotating log (default: 0 no rotation) */ -std::unique_ptr setupLogger( +CODA_OSS_API std::unique_ptr setupLogger( const path& program, const std::string& logLevel = "warning", const path& logFile = "console", diff --git a/externals/coda-oss/modules/c++/pch.h b/externals/coda-oss/modules/c++/pch.h index 7952e6efa2..5cda65986c 100644 --- a/externals/coda-oss/modules/c++/pch.h +++ b/externals/coda-oss/modules/c++/pch.h @@ -5,8 +5,13 @@ // Do not add files here that you will be updating frequently as this negates the performance advantage. #pragma once -#ifndef CODA_OSS_pch_h_INCLUDED_ -#define CODA_OSS_pch_h_INCLUDED_ + +// We're building in Visual Studio ... used to control where we get a little bit +// of config info +#define CODA_OSS_PCH 1 +#ifndef CODA_OSS_LIBRARY_SHARED +#define CODA_OSS_LIBRARY_SHARED 1 +#endif #include "coda_oss/CPlusPlus.h" #include "config/disable_compiler_warnings.h" @@ -114,4 +119,3 @@ CODA_OSS_disable_warning_pop #include "hdf5/lite/H5_.h" #pragma comment(lib, "hdf5-c++.lib") -#endif //CODA_OSS_pch_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/plugin/include/plugin/ErrorHandler.h b/externals/coda-oss/modules/c++/plugin/include/plugin/ErrorHandler.h index be7ca3c8a8..234e6c5a18 100644 --- a/externals/coda-oss/modules/c++/plugin/include/plugin/ErrorHandler.h +++ b/externals/coda-oss/modules/c++/plugin/include/plugin/ErrorHandler.h @@ -19,7 +19,7 @@ * see . * */ - +#pragma once #ifndef __PLUGIN_ERROR_HANDLER_H__ #define __PLUGIN_ERROR_HANDLER_H__ @@ -27,9 +27,11 @@ #include #include +#include "config/Exports.h" + namespace plugin { -class ErrorHandler +class CODA_OSS_API ErrorHandler { public: ErrorHandler() {} @@ -47,7 +49,7 @@ class ErrorHandler virtual void onPluginError(except::Context& c) = 0; }; -class DefaultErrorHandler : public ErrorHandler +class CODA_OSS_API DefaultErrorHandler final : public ErrorHandler { public: DefaultErrorHandler(logging::LoggerPtr logger = logging::LoggerPtr()); diff --git a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/FileHeader.h b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/FileHeader.h index a5633e5098..1a76c16764 100644 --- a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/FileHeader.h +++ b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/FileHeader.h @@ -19,6 +19,7 @@ * see . * */ +#pragma once #ifndef __SIO_LITE_FILE_HEADER_H__ #define __SIO_LITE_FILE_HEADER_H__ @@ -28,6 +29,7 @@ #include #include #include +#include "config/Exports.h" #include "sio/lite/UserDataDictionary.h" #include "sio/lite/InvalidHeaderException.h" #include "sio/lite/UnsupportedDataTypeException.h" @@ -37,7 +39,7 @@ namespace sio namespace lite { -class FileHeader +class CODA_OSS_API FileHeader { public: /** Unsigned byte data */ diff --git a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/FileReader.h b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/FileReader.h index b94fbc1ae7..885b3b68b6 100644 --- a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/FileReader.h +++ b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/FileReader.h @@ -19,10 +19,6 @@ * see . * */ -#ifndef CODA_OSS_sio_lite_FileReader_h_INCLUDED_ -#define CODA_OSS_sio_lite_FileReader_h_INCLUDED_ #pragma once - #include "sio/lite/SioFileReader.h" -#endif // CODA_OSS_sio_lite_FileReader_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/SioFileReader.h b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/SioFileReader.h index 446476dfc7..54fe31c32f 100644 --- a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/SioFileReader.h +++ b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/SioFileReader.h @@ -19,12 +19,14 @@ * see . * */ +#pragma once #ifndef __SIO_LITE_FILE_READER_H__ #define __SIO_LITE_FILE_READER_H__ #include #include #include +#include "config/Exports.h" #include "sio/lite/InvalidHeaderException.h" #include "sio/lite/StreamReader.h" @@ -80,12 +82,9 @@ namespace lite \endcode */ -class FileReader : public StreamReader, public io::Seekable +class CODA_OSS_API FileReader : public StreamReader, public io::Seekable { - - public: - /** Constructor */ FileReader() : StreamReader() {} diff --git a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/StreamReader.h b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/StreamReader.h index 982b8900fb..efa9897ffc 100644 --- a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/StreamReader.h +++ b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/StreamReader.h @@ -19,10 +19,12 @@ * see . * */ +#pragma once #ifndef __SIO_LITE_STREAM_READER_H__ #define __SIO_LITE_STREAM_READER_H__ #include +#include "config/Exports.h" #include "sio/lite/FileHeader.h" namespace sio @@ -87,7 +89,7 @@ namespace lite \endcode * */ -class StreamReader : public io::InputStream +class CODA_OSS_API StreamReader : public io::InputStream { public: /** Constructor */ diff --git a/externals/coda-oss/modules/c++/std/include/import/std.h b/externals/coda-oss/modules/c++/std/include/import/std.h index 32702da30d..5c41ee61ba 100644 --- a/externals/coda-oss/modules/c++/std/include/import/std.h +++ b/externals/coda-oss/modules/c++/std/include/import/std.h @@ -102,6 +102,7 @@ CODA_OSS_disable_warning_system_header_push #include #include #include +#include CODA_OSS_disable_warning_pop diff --git a/externals/coda-oss/modules/c++/std/include/std/mdspan b/externals/coda-oss/modules/c++/std/include/std/mdspan new file mode 100644 index 0000000000..b25c5447d3 --- /dev/null +++ b/externals/coda-oss/modules/c++/std/include/std/mdspan @@ -0,0 +1,46 @@ +/* ========================================================================= + * This file is part of std-c++ + * ========================================================================= + * + * © Copyright 2023, Maxar Technologies, Inc. + * + * std-c++ is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; If not, http://www.gnu.org/licenses/. + * + */ +#pragma once + +#include "coda_oss/mdspan.h" +#include "coda_oss/CPlusPlus.h" + +// Make it (too?) easy for clients to get our various std:: implementations +#ifndef CODA_OSS_NO_std_mdspan + #if CODA_OSS_cpp23 + #include + #define CODA_OSS_NO_std_mdspan 1 // part of C++23 + #else + #define CODA_OSS_NO_std_mdspan 0 // use our own + #endif +#endif + +#if !CODA_OSS_NO_std_mdspan +namespace std // This is slightly uncouth: we're not supposed to augment "std". +{ + using coda_oss::mdspan; + using coda_oss::dextents; +} +#ifndef __cpp_lib_mdspan +#define __cpp_lib_mdspan 202002L // https://en.cppreference.com/w/cpp/feature_test#cpp_lib_mdspan +#endif + +#endif // CODA_OSS_NO_std_mdspan diff --git a/externals/coda-oss/modules/c++/sys/include/sys/DLL.h b/externals/coda-oss/modules/c++/sys/include/sys/DLL.h index 28fbb6be54..c384a461b8 100644 --- a/externals/coda-oss/modules/c++/sys/include/sys/DLL.h +++ b/externals/coda-oss/modules/c++/sys/include/sys/DLL.h @@ -20,7 +20,7 @@ * */ - +#pragma once #ifndef __SYS_DLL_H__ #define __SYS_DLL_H__ @@ -52,6 +52,7 @@ typedef void* DLL_FUNCTION_PTR; #include "except/Exception.h" #include "sys/Err.h" +#include "config/Exports.h" namespace sys @@ -124,7 +125,7 @@ struct DLLException : public except::Exception */ -struct DLL +struct CODA_OSS_API DLL { /*! * Construct a library object, but dont populate or load it diff --git a/externals/coda-oss/modules/c++/sys/include/sys/FileFinder.h b/externals/coda-oss/modules/c++/sys/include/sys/FileFinder.h index 0485de3c89..e60ec85534 100644 --- a/externals/coda-oss/modules/c++/sys/include/sys/FileFinder.h +++ b/externals/coda-oss/modules/c++/sys/include/sys/FileFinder.h @@ -20,6 +20,7 @@ * */ +#pragma once #ifndef __SYS_FILE_FINDER_H__ #define __SYS_FILE_FINDER_H__ @@ -37,7 +38,7 @@ namespace sys /** * Predicate interface for all entries */ -struct FilePredicate +struct CODA_OSS_API FilePredicate { using argument_type = std::string; using result_type = bool; @@ -58,7 +59,7 @@ struct ExistsPredicate : FilePredicate /** * Predicate that matches files only (no directories) */ -struct FileOnlyPredicate: public FilePredicate +struct CODA_OSS_API FileOnlyPredicate : public FilePredicate { virtual ~FileOnlyPredicate() = default; virtual bool operator()(const std::string& entry) const override; @@ -147,7 +148,7 @@ struct LogicalPredicate : public FilePredicate * The FileFinder class allows you to search for * files/directories in a clean way. */ -struct FileFinder final +struct CODA_OSS_API FileFinder final { FileFinder() = default; ~FileFinder() = default; @@ -167,7 +168,7 @@ struct FileFinder final // until either the file is found or we stop at a ".git" directory. // // This (obviously) might take a while, so consider whether the result should be cached. -coda_oss::filesystem::path findFirstFile(const coda_oss::filesystem::path& startingDirectory, const coda_oss::filesystem::path& filename); +CODA_OSS_API coda_oss::filesystem::path findFirstFile(const coda_oss::filesystem::path& startingDirectory, const coda_oss::filesystem::path& filename); coda_oss::filesystem::path findFirstDirectory(const coda_oss::filesystem::path& startingDirectory, const coda_oss::filesystem::path& dir); // This is here most to avoid creating a new module for a few utility routines @@ -175,11 +176,11 @@ namespace test // i.e., sys::test { // Try to find the specified "root" directory starting at the given path. // Used by unittest to find sample files. - coda_oss::filesystem::path findRootDirectory(const coda_oss::filesystem::path& p, const std::string& rootName, + CODA_OSS_API coda_oss::filesystem::path findRootDirectory(const coda_oss::filesystem::path& p, const std::string& rootName, std::function isRoot); - coda_oss::filesystem::path findCMakeBuildRoot(const coda_oss::filesystem::path& p); - bool isCMakeBuild(const coda_oss::filesystem::path& p); + CODA_OSS_API coda_oss::filesystem::path findCMakeBuildRoot(const coda_oss::filesystem::path& p); + bool CODA_OSS_API isCMakeBuild(const coda_oss::filesystem::path& p); coda_oss::filesystem::path findCMakeInstallRoot(const coda_oss::filesystem::path& p); bool isCMakeInstall(const coda_oss::filesystem::path& p); diff --git a/externals/coda-oss/modules/c++/sys/include/sys/sys_filesystem.h b/externals/coda-oss/modules/c++/sys/include/sys/sys_filesystem.h index 59df476a5d..3cbab0837e 100644 --- a/externals/coda-oss/modules/c++/sys/include/sys/sys_filesystem.h +++ b/externals/coda-oss/modules/c++/sys/include/sys/sys_filesystem.h @@ -79,6 +79,7 @@ struct CODA_OSS_API path final // N.B. this is an INCOMPLETE and NON-STANDARD im { *this = source; } + ~path() = default; path& operator=(const path&) = default; path& operator=(path&&) = default; diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/FileReader.h b/externals/coda-oss/modules/c++/tiff/include/tiff/FileReader.h index 88edb7c415..b80d508333 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/FileReader.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/FileReader.h @@ -20,9 +20,9 @@ * */ +#pragma once #ifndef CODA_OSS_tiff_FileReader_h_INCLUDED_ #define CODA_OSS_tiff_FileReader_h_INCLUDED_ -#pragma once #include "tiff/TiffFileReader.h" diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/FileWriter.h b/externals/coda-oss/modules/c++/tiff/include/tiff/FileWriter.h index d77af0d6f7..e86b034530 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/FileWriter.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/FileWriter.h @@ -20,9 +20,9 @@ * */ +#pragma once #ifndef CODA_OSS_tiff_FileWriter_h_INCLUDED_ #define CODA_OSS_tiff_FileWriter_h_INCLUDED_ -#pragma once #include "tiff/TiffFileWriter.h" diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/Header.h b/externals/coda-oss/modules/c++/tiff/include/tiff/Header.h index ed9da4f1e9..60b9e8b670 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/Header.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/Header.h @@ -19,11 +19,13 @@ * see . * */ - +#pragma once #ifndef __TIFF_HEADER_H__ #define __TIFF_HEADER_H__ #include +#include + #include "tiff/Common.h" namespace tiff @@ -34,7 +36,7 @@ namespace tiff * @class Header * @brief Contains TIFF header information *********************************************************************/ -class Header : public io::Serializable +class CODA_OSS_API Header : public io::Serializable { public: enum ByteOrder { MM, II }; diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h b/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h index 9120f581a5..ea5493db30 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h @@ -19,14 +19,16 @@ * see . * */ - +#pragma once #ifndef __TIFF_IFD_H__ #define __TIFF_IFD_H__ #include #include + #include #include +#include #include "tiff/IFDEntry.h" #include "tiff/KnownTags.h" @@ -45,7 +47,7 @@ namespace tiff * Contains functions for adding new entries to the IFD or adding * values to a specific IFD entry. *********************************************************************/ -class IFD : public io::Serializable +class CODA_OSS_API IFD : public io::Serializable { public: //! The IFDType diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/IFDEntry.h b/externals/coda-oss/modules/c++/tiff/include/tiff/IFDEntry.h index 75552676f3..e10285b996 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/IFDEntry.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/IFDEntry.h @@ -20,17 +20,19 @@ * */ - +#pragma once #ifndef __TIFF_IFD_ENTRY_H__ #define __TIFF_IFD_ENTRY_H__ -#pragma once #include #include #include + #include -#include "tiff/GenericType.h" #include "sys/Conf.h" +#include "config/Exports.h" + +#include "tiff/GenericType.h" namespace tiff { @@ -47,7 +49,7 @@ namespace tiff * functions for printing out the entry, reading and writing it to a * file, and accessing the data. *********************************************************************/ -class IFDEntry : public io::Serializable +class CODA_OSS_API IFDEntry : public io::Serializable { public: //! Constructor diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/ImageReader.h b/externals/coda-oss/modules/c++/tiff/include/tiff/ImageReader.h index 65898ce700..5ca4354bf9 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/ImageReader.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/ImageReader.h @@ -19,11 +19,12 @@ * see . * */ - +#pragma once #ifndef __TIFF_IMAGE_READER_H__ #define __TIFF_IMAGE_READER_H__ #include +#include #include "tiff/IFDEntry.h" #include "tiff/IFD.h" @@ -39,7 +40,7 @@ namespace tiff * Reads a TIFF image and parses out the IFD. Contains functions for * getting data from the image and retrieving the TIFF IFD. *********************************************************************/ -class ImageReader +class CODA_OSS_API ImageReader { public: /** diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/ImageWriter.h b/externals/coda-oss/modules/c++/tiff/include/tiff/ImageWriter.h index 412e291f92..cd4d7a3a2a 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/ImageWriter.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/ImageWriter.h @@ -19,11 +19,12 @@ * see . * */ - +#pragma once #ifndef __TIFF_IMAGE_WRITER_H__ #define __TIFF_IMAGE_WRITER_H__ #include +#include #include "tiff/Common.h" #include "tiff/IFDEntry.h" @@ -40,7 +41,7 @@ namespace tiff * Writes a TIFF image to a stream. Contains functions for writing * the image's IFD, and for putting data to a stream. *********************************************************************/ -class ImageWriter +class CODA_OSS_API ImageWriter { public: //! The ideal tile size if a tiled file. diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/KnownTags.h b/externals/coda-oss/modules/c++/tiff/include/tiff/KnownTags.h index 75bd106563..c34779d03d 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/KnownTags.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/KnownTags.h @@ -19,13 +19,14 @@ * see . * */ - +#pragma once #ifndef __TIFF_KNOWN_TAGS_H__ #define __TIFF_KNOWN_TAGS_H__ #include #include #include +#include #include "tiff/IFDEntry.h" @@ -35,10 +36,8 @@ namespace tiff /** * This class is a container for known TIFF tags. */ -class KnownTags +struct CODA_OSS_API KnownTags final { -public: - KnownTags(); //! Destructor @@ -71,14 +70,13 @@ class KnownTags tiff::IFDEntry *operator[](const unsigned short tagKey); //! Some common tags - static const char IMAGE_WIDTH[]; - static const char IMAGE_LENGTH[]; - static const char BITS_PER_SAMPLE[]; - static const char COMPRESSION[]; - static const char SAMPLES_PER_PIXEL[]; - static const char PHOTOMETRIC_INTERPRETATION[]; - static const char SAMPLE_FORMAT[]; - + static constexpr auto IMAGE_WIDTH = "ImageWidth"; + static constexpr auto IMAGE_LENGTH = "ImageLength"; + static constexpr auto BITS_PER_SAMPLE = "BitsPerSample"; + static constexpr auto COMPRESSION = "Compression"; + static constexpr auto SAMPLES_PER_PIXEL = "SamplesPerPixel"; + static constexpr auto PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation"; + static constexpr auto SAMPLE_FORMAT = "SampleFormat"; /** ***************************************************************** diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileReader.h b/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileReader.h index 47417b0db0..9d02446e9c 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileReader.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileReader.h @@ -19,13 +19,15 @@ * see . * */ - +#pragma once #ifndef __TIFF_FILE_READER_H__ #define __TIFF_FILE_READER_H__ #include #include + #include +#include #include "tiff/Header.h" #include "tiff/ImageReader.h" @@ -42,7 +44,7 @@ namespace tiff * to access a specific image within the file, and to read data from * a specific image in the file. *********************************************************************/ -struct FileReader +struct CODA_OSS_API FileReader { FileReader() = default; diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileWriter.h b/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileWriter.h index f6474c6e2e..bf994ba869 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileWriter.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileWriter.h @@ -19,13 +19,16 @@ * see . * */ - +#pragma once #ifndef __TIFF_FILE_WRITER_H__ #define __TIFF_FILE_WRITER_H__ #include #include + #include +#include + #include "tiff/Header.h" #include "tiff/ImageWriter.h" @@ -41,7 +44,7 @@ namespace tiff * to the same file. Contains function for manipulating each * sub-image and for writing data. *********************************************************************/ -struct FileWriter +struct CODA_OSS_API FileWriter { //! Constructor FileWriter() : diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/TypeFactory.h b/externals/coda-oss/modules/c++/tiff/include/tiff/TypeFactory.h index 5c4f21f025..5fe9c4730f 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/TypeFactory.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/TypeFactory.h @@ -19,10 +19,12 @@ * see . * */ - +#pragma once #ifndef __TIFF_TYPE_FACTORY_H__ #define __TIFF_TYPE_FACTORY_H__ +#include "config/Exports.h" + #include "tiff/GenericType.h" namespace tiff @@ -38,7 +40,7 @@ namespace tiff * assume a specific size for the data, see tiff::Const for the size * of each TIFF type. *********************************************************************/ -class TypeFactory +class CODA_OSS_API TypeFactory final { public: //! Default constructor diff --git a/externals/coda-oss/modules/c++/tiff/source/KnownTags.cpp b/externals/coda-oss/modules/c++/tiff/source/KnownTags.cpp index 60b3290794..ad7fa89827 100644 --- a/externals/coda-oss/modules/c++/tiff/source/KnownTags.cpp +++ b/externals/coda-oss/modules/c++/tiff/source/KnownTags.cpp @@ -28,14 +28,6 @@ #include "tiff/IFDEntry.h" #include -const char tiff::KnownTags::IMAGE_WIDTH[] = "ImageWidth"; -const char tiff::KnownTags::IMAGE_LENGTH[] = "ImageLength"; -const char tiff::KnownTags::BITS_PER_SAMPLE[] = "BitsPerSample"; -const char tiff::KnownTags::COMPRESSION[] = "Compression"; -const char tiff::KnownTags::SAMPLES_PER_PIXEL[] = "SamplesPerPixel"; -const char tiff::KnownTags::PHOTOMETRIC_INTERPRETATION[] = "PhotometricInterpretation"; -const char tiff::KnownTags::SAMPLE_FORMAT[] = "SampleFormat"; - tiff::KnownTags::KnownTags() { addEntry(254, tiff::Const::Type::LONG, "NewSubfileType"); diff --git a/externals/coda-oss/modules/c++/types/include/types/RowCol.h b/externals/coda-oss/modules/c++/types/include/types/RowCol.h index e13f125a2e..846280aaac 100644 --- a/externals/coda-oss/modules/c++/types/include/types/RowCol.h +++ b/externals/coda-oss/modules/c++/types/include/types/RowCol.h @@ -19,7 +19,7 @@ * see . * */ - + #pragma once #ifndef __TYPES_ROW_COL_H__ #define __TYPES_ROW_COL_H__ @@ -28,6 +28,7 @@ #include #include #include +#include #include "gsl/gsl.h" @@ -78,6 +79,11 @@ template class RowCol row = p.first; col = p.second; } + explicit RowCol(const std::array& a) noexcept + { + row = a[0]; + col = a[1]; + } template RowCol& operator=(const RowCol& p) noexcept { diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Element.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Element.h index 323b77aba3..ee4e05346e 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Element.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Element.h @@ -499,7 +499,7 @@ struct CODA_OSS_API Element // SOAPElement derives :-( coda_oss::u8string mCharacterData; }; -Element& add(const xml::lite::QName&, const std::string& value, Element& parent); +CODA_OSS_API Element& add(const xml::lite::QName&, const std::string& value, Element& parent); #ifndef SWIG // The (old) version of SWIG we're using doesn't like certain C++11 features. diff --git a/modules/c++/nitf-c++.vcxproj b/modules/c++/nitf-c++.vcxproj index 78e844251d..d0de3736b7 100644 --- a/modules/c++/nitf-c++.vcxproj +++ b/modules/c++/nitf-c++.vcxproj @@ -171,6 +171,9 @@ + + {9997e895-5161-4ddf-8f3f-099894cb2f21} + {f06550ad-cfc7-40b8-8727-6c82c69a8982} @@ -185,11 +188,11 @@ - StaticLibrary + DynamicLibrary v143 - StaticLibrary + DynamicLibrary v143 true @@ -216,7 +219,7 @@ Level4 true - _DEBUG;%(PreprocessorDefinitions) + _DEBUG;%(PreprocessorDefinitions);;NITRO_NITFCPP_EXPORTS;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)nitf\include;$(ProjectDir)..\c\nrt\include;$(ProjectDir)..\c\nitf\include;$(ProjectDir)..\c\j2k\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include Use @@ -242,7 +245,7 @@ true - $(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\install-$(Configuration)-$(Platform).$(PlatformToolset)\lib\ + $(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\ $(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\install-$(Configuration)-$(Platform).$(PlatformToolset)\lib\ @@ -253,7 +256,7 @@ true true true - NDEBUG;%(PreprocessorDefinitions) + NDEBUG;%(PreprocessorDefinitions);;NITRO_NITFCPP_EXPORTS;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)nitf\include;$(ProjectDir)..\c\nrt\include;$(ProjectDir)..\c\nitf\include;$(ProjectDir)..\c\j2k\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include Use @@ -276,7 +279,7 @@ true true true - $(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\install-$(Configuration)-$(Platform).$(PlatformToolset)\lib\ + $(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\ $(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\install-$(Configuration)-$(Platform).$(PlatformToolset)\lib\ diff --git a/modules/c++/nitf/apps/show_nitf++/pch.h b/modules/c++/nitf/apps/show_nitf++/pch.h index 9bb7897610..a7ba61b5cf 100644 --- a/modules/c++/nitf/apps/show_nitf++/pch.h +++ b/modules/c++/nitf/apps/show_nitf++/pch.h @@ -55,11 +55,6 @@ #include #include -#pragma comment(lib, "io-c++") -#pragma comment(lib, "except-c++") -#pragma comment(lib, "sys-c++") -#pragma comment(lib, "str-c++") - #pragma comment(lib, "ws2_32") diff --git a/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj b/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj index 423eaf6ec4..bad74a0952 100644 --- a/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj +++ b/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj @@ -49,7 +49,7 @@ Level4 true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _DEBUG;_CONSOLE;%(PreprocessorDefinitions);CODA_OSS_LIBRARY_SHARED=1 true $(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c\jpeg\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include Use @@ -81,7 +81,7 @@ true true true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + NDEBUG;_CONSOLE;%(PreprocessorDefinitions);CODA_OSS_LIBRARY_SHARED=1 true $(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c\jpeg\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include Use @@ -119,6 +119,9 @@ + + {9997e895-5161-4ddf-8f3f-099894cb2f21} + {8f357a19-799e-4971-850e-3f28485c130b} diff --git a/modules/c++/nitf/include/nitf/coda-oss.hpp b/modules/c++/nitf/include/nitf/coda-oss.hpp index 18467eac92..0e7c5e9c89 100644 --- a/modules/c++/nitf/include/nitf/coda-oss.hpp +++ b/modules/c++/nitf/include/nitf/coda-oss.hpp @@ -31,6 +31,7 @@ #include #include +#include // need #pragma warning(disable) outside push/pop CODA_OSS_disable_warning_push #if _MSC_VER #pragma warning(disable: 26432) // If you define or delete any default operation in the type '...', define or delete them all(c.21). diff --git a/modules/c++/nitf/include/nitf/exports.hpp b/modules/c++/nitf/include/nitf/exports.hpp index f87bfc2071..7d3b61f8fd 100644 --- a/modules/c++/nitf/include/nitf/exports.hpp +++ b/modules/c++/nitf/include/nitf/exports.hpp @@ -1,30 +1,38 @@ -#ifndef NITRO_nitf_exports_hpp_INCLUDED_ -#define NITRO_nitf_exports_hpp_INCLUDED_ #pragma once #include "config/compiler_extensions.h" -// Need to specify how this code will be consumed, either CODA_OSS_LIB (static library) -// or CODA_OSS_DLL (aka "shared" library). For DLLs, it needs to be set for BOTH +// Need to specify how this code will be consumed, either NITRO_NITFCPP_LIB_ (static library) +// or NITRO_NITFCPP_DLL_ (aka "shared" library). For DLLs, it needs to be set for BOTH // "exporting" (building this code) and "importing" (consuming). // // 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) - #define NITRO_NITFCPP_LIB 1 - //#define NITRO_NITFCPP_DLL 1 +#if !defined(NITRO_NITFCPP_LIB_) && !defined(NITRO_NITFCPP_DLL_) + #if CODA_OSS_LIBRARY_SHARED + #if CODA_OSS_LIBRARY_STATIC + #error "CODA_OSS_LIBRARY_SHARED already #define'd'" + #endif + #define NITRO_NITFCPP_DLL_ 1 // Symbols must be exported and imported (see below). + #else + // CODA_OSS_LIBRARY_STATIC doesn't have to be defined + #define NITRO_NITFCPP_LIB_ 1 // Static library, all symbols visible. + #endif +#endif +#if !defined(NITRO_NITFCPP_LIB_) && !defined(NITRO_NITFCPP_DLL_) + #error "One of NITRO_NITFCPP_LIB_ pr NITRO_NITFCPP_DLL_ must be #define'd'" #endif -#if defined(NITRO_NITFCPP_LIB) && defined(NITRO_NITFCPP_DLL) - #error "Both NITRO_NITFCPP_LIB and NITRO_NITFCPP_DLL are #define'd'" +#if defined(NITRO_NITFCPP_LIB_) && defined(NITRO_NITFCPP_DLL_) + #error "Both NITRO_NITFCPP_LIB_ and NITRO_NITFCPP_DLL_ are #define'd'" #endif -#if defined(NITRO_NITFCPP_EXPORTS) && defined(NITRO_NITFCPP_LIB) +#if defined(NITRO_NITFCPP_EXPORTS) && defined(NITRO_NITFCPP_LIB_) #error "Can't export from a LIB'" #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 CODA_OSS_EXPORTS +// from a DLL simpler. All files within this DLL are compiled with the NITRO_NITFCPP_EXPORTS // symbol defined on the command line. This symbol should not be defined on any project // that uses this DLL. This way any other project whose source files include this file see -// CODA_OSS_API functions as being imported from a DLL, whereas this DLL sees symbols +// 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 #ifdef NITRO_NITFCPP_EXPORTS @@ -35,12 +43,11 @@ // We need to know whether we're consuming (importing) a DLL or static LIB // The default is a static LIB as that's what existing code/builds expect. - #ifdef NITRO_NITFCPP_DLL + #ifdef NITRO_NITFCPP_DLL_ // Actually, it seems that the linker is able to figure this out from the .LIB, so // there doesn't seem to be a need for __declspec(dllimport). Clients don't - // need to #define NITRO_NITFCPP_DLL ... ? Well, almost ... it looks - // like __declspec(dllimport) is needed to get virtual "inline"s (e.g., - // destructors) correct. + // need to #define NITRO_NITFCPP_DLL_ ... ? Well, almost ... it looks + // like __declspec(dllimport) is needed to get virtual "inline"s (e.g., destructors) correct. #define NITRO_NITFCPP_API CODA_OSS_library_import #else #define NITRO_NITFCPP_API /* "importing" a static LIB */ @@ -51,4 +58,3 @@ #pragma warning(disable: 4251) // '...' : class '...' needs to have dll-interface to be used by clients of struct '...' #endif -#endif // NITRO_nitf_exports_hpp_INCLUDED_ diff --git a/modules/c++/pch.h b/modules/c++/pch.h index 03085c4ac3..5598704d55 100644 --- a/modules/c++/pch.h +++ b/modules/c++/pch.h @@ -31,6 +31,7 @@ CODA_OSS_disable_warning_pop #pragma warning(disable: 5105) // macro expansion producing '...' has undefined behavior #include #pragma warning(pop) +#pragma comment(lib, "Ws2_32") #pragma warning(disable: 4619) // #pragma warning: there is no warning number '...' #pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...' @@ -50,6 +51,9 @@ CODA_OSS_disable_warning_pop // We're building in Visual Studio ... used to control where we get a little bit of config info #define NITRO_PCH 1 +#ifndef CODA_OSS_LIBRARY_SHARED +#define CODA_OSS_LIBRARY_SHARED 1 +#endif // Yes, these are our files ... but they don't change very often, and if they do // change we want to rebuild everything anyway. @@ -58,7 +62,6 @@ CODA_OSS_disable_warning_pop #include "nitf/System.h" #include "nitf/Field.h" #include "nitf/Types.h" -#pragma comment(lib, "nitf-c") #pragma comment(lib, "openjpeg") #pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. @@ -78,9 +81,3 @@ CODA_OSS_disable_warning_pop #include "nitf/Handle.hpp" #include "nitf/coda-oss.hpp" -#pragma comment(lib, "io-c++") -#pragma comment(lib, "except-c++") -#pragma comment(lib, "sys-c++") -#pragma comment(lib, "str-c++") -#pragma comment(lib, "mt-c++") -#pragma comment(lib, "math-c++") \ No newline at end of file diff --git a/modules/c/j2k/J2KCompress.vcxproj b/modules/c/j2k/J2KCompress.vcxproj index 328651cf96..b8fcbacdac 100644 --- a/modules/c/j2k/J2KCompress.vcxproj +++ b/modules/c/j2k/J2KCompress.vcxproj @@ -64,7 +64,7 @@ Level4 true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH;HAVE_J2K_H + _DEBUG;_LIB;%(PreprocessorDefinitions);NITRO_NRT_EXPORTS;NITRO_PCH;HAVE_J2K_H;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)include;$(ProjectDir)..\nrt\include;$(ProjectDir)..\nitf\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) @@ -94,7 +94,7 @@ true true true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH;HAVE_J2K_H + NDEBUG;_LIB;%(PreprocessorDefinitions);NITRO_NRT_EXPORTS;NITRO_PCH;HAVE_J2K_H;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)include;$(ProjectDir)..\nrt\include;$(ProjectDir)..\nitf\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) diff --git a/modules/c/j2k/J2KDecompress.vcxproj b/modules/c/j2k/J2KDecompress.vcxproj index e5485c2dfd..d751cb81a6 100644 --- a/modules/c/j2k/J2KDecompress.vcxproj +++ b/modules/c/j2k/J2KDecompress.vcxproj @@ -64,7 +64,7 @@ Level4 true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH;HAVE_J2K_H + _DEBUG;_LIB;%(PreprocessorDefinitions);NITRO_NRT_EXPORTS;NITRO_PCH;HAVE_J2K_H;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)include;$(ProjectDir)..\nrt\include;$(ProjectDir)..\nitf\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) @@ -94,7 +94,7 @@ true true true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH;HAVE_J2K_H + NDEBUG;_LIB;%(PreprocessorDefinitions);NITRO_NRT_EXPORTS;NITRO_PCH;HAVE_J2K_H;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)include;$(ProjectDir)..\nrt\include;$(ProjectDir)..\nitf\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) diff --git a/modules/c/j2k/source/OpenJPEGImpl.c b/modules/c/j2k/source/OpenJPEGImpl.c index 11687c50f2..987b6f9767 100644 --- a/modules/c/j2k/source/OpenJPEGImpl.c +++ b/modules/c/j2k/source/OpenJPEGImpl.c @@ -649,6 +649,10 @@ OpenJPEG_readHeader(OpenJPEGReaderImpl *impl, nrt_Error *error) return rc; } +#if _MSC_VER +#pragma warning(push) +#pragma warning(disable: 6262) // Function uses '18832' bytes of stack. Consider moving some data to heap. +#endif J2KPRIV( NRT_BOOL) OpenJPEG_initImage_(OpenJPEGWriterImpl *impl, j2k_WriterOptions *writerOps, OPJ_CODEC_FORMAT format, nrt_Error *error) @@ -848,6 +852,10 @@ J2KPRIV( NRT_BOOL) OpenJPEG_initImage_(OpenJPEGWriterImpl *impl, return rc; } +#if _MSC_VER +#pragma warning(pop) +#endif + J2KPRIV(NRT_BOOL) OpenJPEG_initImage_j2k(OpenJPEGWriterImpl* impl, j2k_WriterOptions* writerOps, nrt_Error* error) { return OpenJPEG_initImage_(impl, writerOps, OPJ_CODEC_J2K, error); diff --git a/modules/c/nitf-c.vcxproj b/modules/c/nitf-c.vcxproj index eb575fba2f..8d1133a787 100644 --- a/modules/c/nitf-c.vcxproj +++ b/modules/c/nitf-c.vcxproj @@ -20,11 +20,11 @@ - StaticLibrary + DynamicLibrary v143 - StaticLibrary + DynamicLibrary v143 true @@ -50,7 +50,7 @@ Level4 true - _DEBUG;%(PreprocessorDefinitions);HAVE_OPENJPEG_H + _DEBUG;%(PreprocessorDefinitions);HAVE_OPENJPEG_H;NITRO_NRT_EXPORTS;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)nrt\include;$(ProjectDir)nitf\include;$(ProjectDir)jpeg\include;$(ProjectDir)j2k\include;$(ProjectDir)cgm\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;%(AdditionalIncludeDirectories) Use @@ -65,7 +65,7 @@ true AdvancedVectorExtensions2 CompileAsCpp - false + Sync MultiThreadedDebugDLL true stdcpp17 @@ -77,6 +77,7 @@ true + $(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\ @@ -84,7 +85,7 @@ true true true - NDEBUG;%(PreprocessorDefinitions);HAVE_OPENJPEG_H + NDEBUG;%(PreprocessorDefinitions);HAVE_OPENJPEG_H;NITRO_NRT_EXPORTS;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)nrt\include;$(ProjectDir)nitf\include;$(ProjectDir)jpeg\include;$(ProjectDir)j2k\include;$(ProjectDir)cgm\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;%(AdditionalIncludeDirectories) Use @@ -97,7 +98,7 @@ Level3 AdvancedVectorExtensions2 CompileAsCpp - false + Sync true stdcpp17 stdc11 @@ -109,6 +110,7 @@ true true true + $(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\ @@ -212,6 +214,7 @@ + diff --git a/modules/c/nitf-c.vcxproj.filters b/modules/c/nitf-c.vcxproj.filters index 6dd32c62a1..4bcb934f80 100644 --- a/modules/c/nitf-c.vcxproj.filters +++ b/modules/c/nitf-c.vcxproj.filters @@ -361,6 +361,9 @@ j2k + + nrt + diff --git a/modules/c/nitf/TEST_DES.vcxproj b/modules/c/nitf/TEST_DES.vcxproj index 84021cde79..3b7849be10 100644 --- a/modules/c/nitf/TEST_DES.vcxproj +++ b/modules/c/nitf/TEST_DES.vcxproj @@ -64,7 +64,7 @@ Level4 true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH + _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) @@ -84,6 +84,8 @@ true + + @@ -92,7 +94,7 @@ true true true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH + NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH;CODA_OSS_LIBRARY_SHARED=1 true $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) @@ -111,6 +113,8 @@ true true true + + diff --git a/modules/c/nitf/include/nitf/BandInfo.h b/modules/c/nitf/include/nitf/BandInfo.h index e73a9eb683..9672c29dff 100644 --- a/modules/c/nitf/include/nitf/BandInfo.h +++ b/modules/c/nitf/include/nitf/BandInfo.h @@ -94,7 +94,7 @@ NITFAPI(void) nitf_BandInfo_destruct(nitf_BandInfo ** info); * \param error An error to populate upon failure * \return A new object that is identical to the old */ -NITFPROT(nitf_BandInfo *) nitf_BandInfo_clone(nitf_BandInfo * source, +NITFAPI(nitf_BandInfo *) nitf_BandInfo_clone(nitf_BandInfo * source, nitf_Error * error); /*! diff --git a/modules/c/nitf/include/nitf/Defines.h b/modules/c/nitf/include/nitf/Defines.h index 8d5038d9bc..286fa20fec 100644 --- a/modules/c/nitf/include/nitf/Defines.h +++ b/modules/c/nitf/include/nitf/Defines.h @@ -32,7 +32,7 @@ * _Tre the name of the input TRE */ #ifndef NITF_PLUGIN_FUNCTION_EXPORT -#define NITF_PLUGIN_FUNCTION_EXPORT(retval_) NITFAPI(retval_) +#define NITF_PLUGIN_FUNCTION_EXPORT(retval_) NRTEXPORT(retval_) #endif #define NITF_DECLARE_PLUGIN(_Tre) \ static const char* _Tre##Ident[] = { \ diff --git a/modules/c/nitf/include/nitf/Field.h b/modules/c/nitf/include/nitf/Field.h index 2318c9b252..7df14945a7 100644 --- a/modules/c/nitf/include/nitf/Field.h +++ b/modules/c/nitf/include/nitf/Field.h @@ -363,8 +363,8 @@ NITFPROT(NITF_BOOL) nitf_Field_resetLength(nitf_Field * field, * Print the contents of this Field * \param field The field object */ -NITFPROT(void) nitf_Field_print(nitf_Field * field); -NITFPROT(void) nitf_Field_snprint(char* buffer, size_t buf_size, nitf_Field* field); +NITFAPI(void) nitf_Field_print(nitf_Field * field); +NITFAPI(void) nitf_Field_snprint(char* buffer, size_t buf_size, nitf_Field* field); /*! diff --git a/modules/c/nitf/include/nitf/ImageIO.h b/modules/c/nitf/include/nitf/ImageIO.h index 1cbae87903..196456ccfb 100644 --- a/modules/c/nitf/include/nitf/ImageIO.h +++ b/modules/c/nitf/include/nitf/ImageIO.h @@ -114,7 +114,7 @@ nitf_BlockingInfo; Memory allocation error\n */ -NITFPROT(nitf_BlockingInfo *) nitf_BlockingInfo_construct(nitf_Error * +NITFAPI(nitf_BlockingInfo *) nitf_BlockingInfo_construct(nitf_Error * error); /*! @@ -125,7 +125,7 @@ NITFPROT(nitf_BlockingInfo *) nitf_BlockingInfo_construct(nitf_Error * \return None */ -NITFPROT(void) nitf_BlockingInfo_destruct(nitf_BlockingInfo ** info); +NITFAPI(void) nitf_BlockingInfo_destruct(nitf_BlockingInfo ** info); /*! @@ -158,7 +158,7 @@ NITFPROT(void) nitf_BlockingInfo_destruct(nitf_BlockingInfo ** info); */ -NITFPROT(NITF_BOOL) nitf_ImageIO_writeSequential(nitf_ImageIO * nitf, +NITFAPI(NITF_BOOL) nitf_ImageIO_writeSequential(nitf_ImageIO * nitf, nitf_IOInterface* io, nitf_Error * error ); @@ -189,7 +189,7 @@ NITFPROT(NITF_BOOL) nitf_ImageIO_writeSequential(nitf_ImageIO * nitf, */ -NITFPROT(NITF_BOOL) nitf_ImageIO_writeDone(nitf_ImageIO * object, +NITFAPI(NITF_BOOL) nitf_ImageIO_writeDone(nitf_ImageIO * object, nitf_IOInterface* io, nitf_Error * error); @@ -225,7 +225,7 @@ NITFPROT(NITF_BOOL) nitf_ImageIO_writeDone(nitf_ImageIO * object, Invalid row count */ -NITFPROT(NITF_BOOL) nitf_ImageIO_writeRows(nitf_ImageIO * object, +NITFAPI(NITF_BOOL) nitf_ImageIO_writeRows(nitf_ImageIO * object, nitf_IOInterface* io, uint32_t numRows, uint8_t ** data, @@ -250,7 +250,7 @@ NITFPROT(NITF_BOOL) nitf_ImageIO_writeRows(nitf_ImageIO * object, I/O errors */ -NITFPROT(NITF_BOOL) nitf_ImageIO_flush(nitf_ImageIO * object, +NITFAPI(NITF_BOOL) nitf_ImageIO_flush(nitf_ImageIO * object, nitf_IOInterface* io, nitf_Error * error ); @@ -686,7 +686,7 @@ typedef int (*NITF_DOWN_SAMPLE_FUNCTION) (void *input, */ -NITFPROT(nitf_ImageIO *) +NITFAPI(nitf_ImageIO *) nitf_ImageIO_construct(nitf_ImageSubheader * subheader, uint64_t offset, uint64_t length, @@ -711,7 +711,7 @@ nitf_ImageIO_construct(nitf_ImageSubheader * subheader, Memory allocation error */ -NITFPROT(nitf_ImageIO *) nitf_ImageIO_clone(nitf_ImageIO * image, +NITFAPI(nitf_ImageIO *) nitf_ImageIO_clone(nitf_ImageIO * image, nitf_Error * error ); @@ -726,7 +726,7 @@ NITFPROT(nitf_ImageIO *) nitf_ImageIO_clone(nitf_ImageIO * image, \return None */ -NITFPROT(void) nitf_ImageIO_destruct(nitf_ImageIO ** nitf); +NITFAPI(void) nitf_ImageIO_destruct(nitf_ImageIO ** nitf); /*! \brief nitf_ImageIO_read - Read a sub-window @@ -765,7 +765,7 @@ NITFPROT(void) nitf_ImageIO_destruct(nitf_ImageIO ** nitf); System I/O or memory allocation errors */ -NITFPROT(NITF_BOOL) nitf_ImageIO_read(nitf_ImageIO * nitf, +NITFAPI(NITF_BOOL) nitf_ImageIO_read(nitf_ImageIO * nitf, nitf_IOInterface* io, nitf_SubWindow * subWindow, uint8_t ** user, @@ -782,7 +782,7 @@ NITFPROT(NITF_BOOL) nitf_ImageIO_read(nitf_ImageIO * nitf, \return Returns pixel size in bytes */ -NITFPROT(uint32_t) nitf_ImageIO_pixelSize(nitf_ImageIO * nitf); +NITFAPI(uint32_t) nitf_ImageIO_pixelSize(nitf_ImageIO * nitf); /*! \brief nitf_ImageIO_setFileOffset @@ -802,7 +802,7 @@ NITFPROT(uint32_t) nitf_ImageIO_pixelSize(nitf_ImageIO * nitf); I/O operation in progress */ -NITFPROT(NITF_BOOL) nitf_ImageIO_setFileOffset(nitf_ImageIO * nitf, +NITFAPI(NITF_BOOL) nitf_ImageIO_setFileOffset(nitf_ImageIO * nitf, uint64_t offset, nitf_Error * error ); @@ -833,7 +833,7 @@ NITFPROT(NITF_BOOL) nitf_ImageIO_setFileOffset(nitf_ImageIO * nitf, I/O error */ -NITFPROT(nitf_BlockingInfo *) nitf_ImageIO_getBlockingInfo(nitf_ImageIO * image, +NITFAPI(nitf_BlockingInfo *) nitf_ImageIO_getBlockingInfo(nitf_ImageIO * image, nitf_IOInterface* io, nitf_Error * error ); @@ -846,7 +846,7 @@ NITFPROT(nitf_BlockingInfo *) nitf_ImageIO_getBlockingInfo(nitf_ImageIO * image, \return Returns the current enable/disable state */ -NITFPROT(int) nitf_ImageIO_setWriteCaching +NITFAPI(int) nitf_ImageIO_setWriteCaching ( nitf_ImageIO * nitf, /*!< Object to modify */ int enable /*!< Enable cached writes if true */ @@ -860,7 +860,7 @@ NITFPROT(int) nitf_ImageIO_setWriteCaching \return None */ -NITFPROT(void) nitf_ImageIO_setReadCaching +NITFAPI(void) nitf_ImageIO_setReadCaching ( nitf_ImageIO * nitf /*!< Object to modify */ ); @@ -876,7 +876,7 @@ NITFPROT(void) nitf_ImageIO_setReadCaching \return None */ -NITFPROT(void) nitf_BlockingInfo_print(nitf_BlockingInfo * info, /*!< The structure to print */ +NITFAPI(void) nitf_BlockingInfo_print(nitf_BlockingInfo * info, /*!< The structure to print */ FILE * file /*!< FILE to use for print */ ); @@ -886,7 +886,7 @@ NITFPROT(void) nitf_BlockingInfo_print(nitf_BlockingInfo * info, /*!< The struc \b nitf_ImageIO_setupDirectBlockRead does some simple checks to prepare for reading blocks directly from the NITF (bypassing any reorganization of data) */ -NITFPROT(NITF_BOOL) nitf_ImageIO_setupDirectBlockRead(nitf_ImageIO *nitf, +NITFAPI(NITF_BOOL) nitf_ImageIO_setupDirectBlockRead(nitf_ImageIO *nitf, nitf_IOInterface *io, uint32_t numBands, nitf_Error *error); @@ -903,7 +903,7 @@ NITFPROT(NITF_BOOL) nitf_ImageIO_setupDirectBlockRead(nitf_ImageIO *nitf, \param blockSize The block size read \param error Error object */ -NITFPROT(uint8_t*) nitf_ImageIO_readBlockDirect(nitf_ImageIO* nitf, +NITFAPI(uint8_t*) nitf_ImageIO_readBlockDirect(nitf_ImageIO* nitf, nitf_IOInterface* io, uint32_t blockNumber, uint64_t* blockSize, diff --git a/modules/c/nitf/include/nitf/NitfWriter.h b/modules/c/nitf/include/nitf/NitfWriter.h index cdd1c3da21..3c764ef437 100644 --- a/modules/c/nitf/include/nitf/NitfWriter.h +++ b/modules/c/nitf/include/nitf/NitfWriter.h @@ -203,7 +203,7 @@ NITFAPI(NITF_BOOL) nitf_Writer_write(nitf_Writer * writer, nitf_Error * error); * \return NITF_SUCCESS on success, NITF_FAILURE otherwise * */ -NITFPROT(NITF_BOOL) nitf_Writer_writeHeader(nitf_Writer* writer, +NITFAPI(NITF_BOOL) nitf_Writer_writeHeader(nitf_Writer* writer, nitf_Off* fileLenOff, uint32_t* hdrLen, nitf_Error* error); @@ -221,7 +221,7 @@ NITFPROT(NITF_BOOL) nitf_Writer_writeHeader(nitf_Writer* writer, * * \return NITF_SUCCESS on success, NITF_FAILURE otherwise */ -NITFPROT(NITF_BOOL) +NITFAPI(NITF_BOOL) nitf_Writer_writeImageSubheader(nitf_Writer* writer, const nitf_ImageSubheader* subhdr, nitf_Version fver, @@ -242,7 +242,7 @@ nitf_Writer_writeImageSubheader(nitf_Writer* writer, * * \return NITF_SUCCESS on success, NITF_FAILURE otherwise */ -NITFPROT(NITF_BOOL) nitf_Writer_writeDESubheader(nitf_Writer* writer, +NITFAPI(NITF_BOOL) nitf_Writer_writeDESubheader(nitf_Writer* writer, const nitf_DESubheader* subhdr, uint32_t* userSublen, nitf_Version fver, @@ -261,7 +261,7 @@ NITFPROT(NITF_BOOL) nitf_Writer_writeDESubheader(nitf_Writer* writer, * * \return NITF_SUCCESS on success, NITF_FAILURE otherwise */ -NITFPROT(NITF_BOOL) nitf_Writer_writeInt64Field(nitf_Writer* writer, +NITFAPI(NITF_BOOL) nitf_Writer_writeInt64Field(nitf_Writer* writer, uint64_t field, uint32_t length, char fill, diff --git a/modules/c/nitf/include/nitf/PluginIdentifier.h b/modules/c/nitf/include/nitf/PluginIdentifier.h index 125ccd9029..4f025bc58b 100644 --- a/modules/c/nitf/include/nitf/PluginIdentifier.h +++ b/modules/c/nitf/include/nitf/PluginIdentifier.h @@ -70,7 +70,7 @@ typedef struct _nitf_TREPreloaded const char* name; NITF_PLUGIN_INIT_FUNCTION init; NITF_PLUGIN_TRE_HANDLER_FUNCTION handler; - NITF_BOOL enabled; // most preloaded TREs are disabled by default + int enabled; // most preloaded TREs are "not set" (disabled) by default } nitf_TREPreloaded; /* diff --git a/modules/c/nitf/include/nitf/PluginRegistry.h b/modules/c/nitf/include/nitf/PluginRegistry.h index 54feddb3fd..554e04deb3 100644 --- a/modules/c/nitf/include/nitf/PluginRegistry.h +++ b/modules/c/nitf/include/nitf/PluginRegistry.h @@ -94,9 +94,9 @@ nitf_PluginRegistry; * along with an error * */ -NITFPROT(nitf_PluginRegistry *) +NITFAPI(nitf_PluginRegistry *) nitf_PluginRegistry_getInstance(nitf_Error * error); -NITFPROT(nitf_PluginRegistry*) +NITFAPI(nitf_PluginRegistry*) nitf_PluginRegistry_getInstanceLog(nitf_Error* error, FILE* log); @@ -242,7 +242,7 @@ nitf_PluginRegistry_unload(nitf_PluginRegistry * reg, nitf_Error * error); * is -1 * \return The plugin main, or NULL */ -NITFPROT(nitf_TREHandler*) +NITFAPI(nitf_TREHandler*) nitf_PluginRegistry_retrieveTREHandler(nitf_PluginRegistry * reg, const char *ident, int *hadError, @@ -281,7 +281,7 @@ nitf_PluginRegistry_retrieveCompConstructor(nitf_PluginRegistry * reg, /* * Retrieves a compression interface for 'comp'. Returns NULL if this fails. */ -NITFPROT(nitf_CompressionInterface* ) +NITFAPI(nitf_CompressionInterface* ) nitf_PluginRegistry_retrieveCompInterface(const char *comp, nitf_Error* error); diff --git a/modules/c/nitf/include/nitf/System.h b/modules/c/nitf/include/nitf/System.h index 5a1bd298e2..57431babab 100644 --- a/modules/c/nitf/include/nitf/System.h +++ b/modules/c/nitf/include/nitf/System.h @@ -46,7 +46,7 @@ #define NITF_GUARD NRT_GUARD #define NITF_ENDGUARD NRT_ENDGUARD #define NITF_BOOL NRT_BOOL -#define NITFAPI(RT) NRTAPI(RT) +#define NITFAPI(RT) NRTAPI(RT) #define NITFPROT(RT) NRTPROT(RT) #define NITF_ATO32 NRT_ATO32 #define NITF_ATOU32 NRT_ATOU32 diff --git a/modules/c/nitf/source/Field.c b/modules/c/nitf/source/Field.c index 656b2bd172..bda591d2cd 100644 --- a/modules/c/nitf/source/Field.c +++ b/modules/c/nitf/source/Field.c @@ -1121,11 +1121,11 @@ static void nitf_Field_snprint_(char* buffer, size_t buf_size, nitf_Field* field break; } } -NITFPROT(void) nitf_Field_print(nitf_Field * field) +NITFAPI(void) nitf_Field_print(nitf_Field * field) { nitf_Field_snprint_(NULL /*buffer*/, 0 /*buf_size*/, field); } -NITFPROT(void) nitf_Field_snprint(char* buffer, size_t buf_size, nitf_Field* field) +NITFAPI(void) nitf_Field_snprint(char* buffer, size_t buf_size, nitf_Field* field) { nitf_Field_snprint_(buffer, buf_size, field); } diff --git a/modules/c/nitf/source/ImageIO.c b/modules/c/nitf/source/ImageIO.c index 989aef30eb..d08e513ba0 100644 --- a/modules/c/nitf/source/ImageIO.c +++ b/modules/c/nitf/source/ImageIO.c @@ -3566,7 +3566,7 @@ NITFPROT(NITF_BOOL) nitf_ImageIO_flush(nitf_ImageIO * object, /*========================= nitf_ImageIO_writeSequential =====================*/ -NITFPROT(NITF_BOOL) nitf_ImageIO_writeSequential(nitf_ImageIO * nitf, +NITFAPI(NITF_BOOL) nitf_ImageIO_writeSequential(nitf_ImageIO * nitf, nitf_IOInterface* io, nitf_Error * error) { @@ -3862,7 +3862,7 @@ NITFPROT(nitf_BlockingInfo *) nitf_BlockingInfo_construct(nitf_Error * /*=================== nitf_BlockingInfo_destruct ===========================*/ -NITFPROT(void) nitf_BlockingInfo_destruct(nitf_BlockingInfo ** info) +NITFAPI(void) nitf_BlockingInfo_destruct(nitf_BlockingInfo ** info) { NITF_FREE(*info); *info = NULL; diff --git a/modules/c/nitf/source/PluginRegistry.c b/modules/c/nitf/source/PluginRegistry.c index e675d53609..992cccd7af 100644 --- a/modules/c/nitf/source/PluginRegistry.c +++ b/modules/c/nitf/source/PluginRegistry.c @@ -522,7 +522,7 @@ nitf_PluginRegistry_loadPlugin(const char* fullName, nitf_Error* error) nitf_Utils_baseName(keyName, fullName, NITF_DLL_EXTENSION); /* Now init the plugin!!! */ - ident = doInit(dll, keyName, error); + ident = doInit(dll, keyName, error); return insertPlugin_("Successfully loaded plugin: [%s] at [%p]\n", reg, ident, dll, error); } @@ -971,8 +971,59 @@ insertCreator(nitf_DLL* dso, // Somebody might want to use a different set of preloadedTREs, or we might even want multiple // sets of preloaded TREs. There's nothing to support either of those right now, but it's easy enough -// to put the infrastructure in place to make it easy to hook-up. -extern nitf_TREPreloaded defaultPreloadedTREs[]; +// to put the infrastructure in place. +static nitf_TREPreloaded* getPreloadedTREs(const char* name) +{ + // Convert a name (e.g., "default") to a set of preloaded TREs. + // Only "default" is currently supported; see TREs.c + if (strcmp(name, "default") == 0) + { + extern nitf_TREPreloaded defaultPreloadedTREs[]; + return defaultPreloadedTREs; + } + return NULL; +} + +static void enable_notset_TREs(nitf_TREPreloaded preloadedTREs[], NITF_BOOL enable) +{ + // NITF_PRELOAD_TRES is set, update all TREs which haven't been touched + for (size_t i = 0;; i++) + { + const char* pKeyName = preloadedTREs[i].name; + if (pKeyName == NULL) // end of list + { + return; + } + if (preloadedTREs[i].enabled < 0) // default is -1 "not set" + { + preloadedTREs[i].enabled = enable; + } + } +} +static nitf_TREPreloaded* getNitfPreloadedTREs(const char* name) +{ + // If NITF_PRELOADED_TRE_HANDLERS_ENABLE is set to *name*", we'll preload those TREs. + // This will NOT override a call to nitf_PluginRegistry_PreloadedTREHandlersEnable(); + // by default, the `enabled` status of TREs is set to -1 "not set." + const char* envVar = getenv("NITF_PRELOADED_TRE_HANDLERS_ENABLE"); + if ((envVar != NULL) && (strcmp(envVar, name) == 0)) + { + nitf_TREPreloaded* preloadedTREs = getPreloadedTREs(name); + if (preloadedTREs != NULL) + { + enable_notset_TREs(preloadedTREs, NRT_TRUE /*enable*/); + return preloadedTREs; + } + } + + // Enviroment variable not set (or not set to *name*), return preloaded TREs as-is. + return getPreloadedTREs(name); +} +static nitf_TREPreloaded* getDefaultPreloadedTREs() +{ + return getNitfPreloadedTREs("default"); +} + static nitf_TREPreloaded* findPreloadedTRE_(nitf_TREPreloaded preloadedTREs[], const char* keyName) { if (preloadedTREs == NULL) @@ -1000,9 +1051,14 @@ static nitf_TREPreloaded* findPreloadedTRE_(nitf_TREPreloaded preloadedTREs[], c static const nitf_TREPreloaded* findPreloadedTRE(nitf_TREPreloaded preloadedTREs[], const char* keyName) { const nitf_TREPreloaded* retval = findPreloadedTRE_(preloadedTREs, keyName); - if ((retval != NULL) && (retval->enabled)) + if (retval != NULL) { - return retval; + if (retval->enabled < 0) + { + return NULL; // "not set" == disabled + } + const NRT_BOOL enabled = retval->enabled ? NRT_TRUE : NRT_FALSE; + return enabled ? retval : NULL; } return NULL; } @@ -1010,10 +1066,15 @@ static const nitf_TREPreloaded* findPreloadedTRE(nitf_TREPreloaded preloadedTREs static NITF_BOOL PreloadedTREHandlerEnable(nitf_TREPreloaded preloadedTREs[], const char* keyName, NITF_BOOL enable) { + if (preloadedTREs == NULL) + { + return NRT_FALSE; + } + nitf_TREPreloaded* result = findPreloadedTRE_(preloadedTREs, keyName); if (result != NULL) { - result->enabled = enable; + result->enabled = enable ? NRT_TRUE : NRT_FALSE; return NRT_TRUE; } return NRT_FALSE; @@ -1021,7 +1082,7 @@ static NITF_BOOL PreloadedTREHandlerEnable(nitf_TREPreloaded preloadedTREs[], NITFAPI(NITF_BOOL) nitf_PluginRegistry_PreloadedTREHandlerEnable(const char* keyName, NITF_BOOL enable) { - return PreloadedTREHandlerEnable(defaultPreloadedTREs, keyName, enable); + return PreloadedTREHandlerEnable(getDefaultPreloadedTREs(), keyName, enable); } static void preloadedTREHandlersEnable(nitf_TREPreloaded preloadedTREs[], NITF_BOOL enable) @@ -1038,14 +1099,13 @@ static void preloadedTREHandlersEnable(nitf_TREPreloaded preloadedTREs[], NITF_B { return; } - - preloadedTREs[i].enabled = enable; + preloadedTREs[i].enabled = enable ? NRT_TRUE : NRT_FALSE; } } NITFAPI(void) nitf_PluginRegistry_PreloadedTREHandlersEnable(NITF_BOOL enable) { - preloadedTREHandlersEnable(defaultPreloadedTREs, enable); + preloadedTREHandlersEnable(getDefaultPreloadedTREs(), enable); } /* @@ -1067,7 +1127,6 @@ static const char** preload_doInit(NITF_PLUGIN_INIT_FUNCTION init, const char* p static NRT_BOOL preloadTRE(nitf_TREPreloaded preloadedTREs[], const char* keyName, nitf_Error* error) { - const char** ident; nitf_PluginRegistry* reg = nitf_PluginRegistry_getInstance(error); /* Construct the DLL object */ @@ -1087,7 +1146,7 @@ static NRT_BOOL preloadTRE(nitf_TREPreloaded preloadedTREs[], dll->dsoMain = (NRT_DLL_FUNCTION_PTR)plugin->handler; /* Now init the plugin!!! */ - ident = preload_doInit(plugin->init, keyName, error); + const char** ident = preload_doInit(plugin->init, keyName, error); return insertPlugin_("Successfully pre-loaded plugin: [%s] at [%p]\n", reg, ident, dll, error); } @@ -1173,7 +1232,7 @@ nitf_PluginRegistry_retrieveTREHandler(nitf_PluginRegistry* reg, int* hadError, nitf_Error* error) { - return retrieveTREHandler(defaultPreloadedTREs, reg, treIdent, hadError, error); + return retrieveTREHandler(getDefaultPreloadedTREs(), reg, treIdent, hadError, error); } NITFPROT(nitf_CompressionInterface*) diff --git a/modules/c/nitf/source/TRE.c b/modules/c/nitf/source/TRE.c index 154f9acc24..55058c85d7 100644 --- a/modules/c/nitf/source/TRE.c +++ b/modules/c/nitf/source/TRE.c @@ -25,7 +25,7 @@ /* IF desc is null, look for it, if I can't load then fail */ -NITFAPI(nitf_TRE *) nitf_TRE_createSkeleton(const char* tag, +NITFPROT(nitf_TRE *) nitf_TRE_createSkeleton(const char* tag, nitf_Error* error) { nitf_TRE *tre = (nitf_TRE *) NITF_MALLOC(sizeof(nitf_TRE)); diff --git a/modules/c/nitf/source/TREs.c b/modules/c/nitf/source/TREs.c index c8cbf18251..8ac463b985 100644 --- a/modules/c/nitf/source/TREs.c +++ b/modules/c/nitf/source/TREs.c @@ -105,7 +105,7 @@ static nitf_TREHandler* TEST_PRELOADED_DES_handler(nitf_Error* error) { /******************************************************************************/ #define NITF_preload_TRE_(Tre_, enabled_) { #Tre_, Tre_##_init, Tre_##_handler, enabled_ } -#define NITF_preload_TRE(Tre_) NITF_preload_TRE_(Tre_, NRT_FALSE /*enabled*/) +#define NITF_preload_TRE(Tre_) NITF_preload_TRE_(Tre_, -1 /*not set*/) nitf_TREPreloaded defaultPreloadedTREs[] = { // Not preloading any TREs right now: with the existing system, @@ -122,7 +122,9 @@ nitf_TREPreloaded defaultPreloadedTREs[] = { NITF_preload_TRE(JITCID), NITF_preload_TRE(PTPRAA), NITF_preload_TRE(RPFHDR), + NITF_preload_TRE(XML_DATA_CONTENT), + //NITF_preload_TRE(TEST_DES), // This should ALWAYS come from the DLL/SO NITF_preload_TRE_(TEST_PRELOADED_DES, NRT_TRUE /*enabled*/), { NULL, NULL, NULL, NRT_FALSE } // end of list diff --git a/modules/c/nrt/include/nrt/Defines.h b/modules/c/nrt/include/nrt/Defines.h index 05cb856d26..7c0fea9650 100644 --- a/modules/c/nrt/include/nrt/Defines.h +++ b/modules/c/nrt/include/nrt/Defines.h @@ -38,6 +38,8 @@ # define NRT_BOOL int #endif +#include "nrt/Exports.h" + #if defined(WIN32) || defined(_WIN32) /* Negotiate the meaning of NRTAPI, NRTPROT (for public and protected) */ # if defined(NRT_MODULE_EXPORTS) @@ -74,6 +76,19 @@ #define NRT_SNPRINTF snprintf #define NRT_VSNPRINTF vsnprintf +// Export no matter what ... when you KNOW you're building a DLL/SO, e.g. a plugin +#define NRTEXPORT(RT) NRT_C NITRO_NRT_library_export RT // extern "C" __declspec(dllexport) void* foo(); + +// Adjust the above ... but w/o chaning too much :-( +#if defined(NRTAPI) && defined(CODA_OSS_LIBRARY_SHARED) + #undef NRTAPI + #ifdef NITRO_NRT_EXPORTS // See Exports.h + #define NRTAPI(RT) NRTEXPORT(RT) + #else + #define NRTAPI(RT) NRT_C NITRO_NRT_library_import RT // extern "C" __declspec(dllimport) void* foo(); + #endif +#endif + /* * This section describes a set of macros to help with * C++ compilation. The 'extern C' set is required to diff --git a/modules/c/nrt/include/nrt/Error.h b/modules/c/nrt/include/nrt/Error.h index 146e06ece9..440e909e1e 100644 --- a/modules/c/nrt/include/nrt/Error.h +++ b/modules/c/nrt/include/nrt/Error.h @@ -103,7 +103,7 @@ typedef struct _NRT_Error * \param func Context info from NRT_CTXT (if C99) & \param level The level of error (This is an enum value) */ -NRTPROT(void) nrt_Error_init(nrt_Error * error, const char *message, +NRTAPI(void) nrt_Error_init(nrt_Error * error, const char *message, const char *file, int line, const char *func, int level); @@ -138,7 +138,7 @@ NRTAPI(void) nrt_Error_fprintf(nrt_Error * error, FILE * file, * \param level The type of error (an enum value) * \param format A format string */ -NRTPROT(void) nrt_Error_initf(nrt_Error * error, const char *file, int line, +NRTAPI(void) nrt_Error_initf(nrt_Error * error, const char *file, int line, const char *func, int level, const char *format, ...); diff --git a/modules/c/nrt/include/nrt/Exports.h b/modules/c/nrt/include/nrt/Exports.h new file mode 100644 index 0000000000..d8bce40e92 --- /dev/null +++ b/modules/c/nrt/include/nrt/Exports.h @@ -0,0 +1,107 @@ +/* ========================================================================= + * This file is part of NITRO + * ========================================================================= + * + * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * © Copyright 2023, Maxar Technologies, Inc. + * + * NITRO is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, If not, + * see . + * + */ + +#pragma once + +// Need to specify how this code will be consumed, either NITRO_NRT_LIB_ (static library) +// or NITRO_NRT_DLL_ (aka "shared" library). For DLLs, it needs to be set for BOTH +// "exporting" (building this code) and "importing" (consuming). +// +// Use Windows naming conventions (DLL, LIB) because this really only matters for _MSC_VER, see below. +#if !defined(NITRO_NRT_LIB_) && !defined(NITRO_NRT_DLL_) + #if CODA_OSS_LIBRARY_SHARED + #if CODA_OSS_LIBRARY_STATIC + #error "CODA_OSS_LIBRARY_SHARED already #define'd'" + #endif + #define NITRO_NRT_DLL_ 1 // Symbols must be exported and imported (see below). + #else + // CODA_OSS_LIBRARY_STATIC doesn't have to be defined + #define NITRO_NRT_LIB_ 1 // Static library, all symbols visible. + #endif +#endif +#if !defined(NITRO_NRT_LIB_) && !defined(NITRO_NRT_DLL_) + #error "One of NITRO_NRT_LIB_ pr NITRO_NRT_DLL_ must be #define'd'" +#endif +#if defined(NITRO_NRT_LIB_) && defined(NITRO_NRT_DLL_) + #error "Both NITRO_NRT_LIB_ and NITRO_NRT_DLL_ are #define'd'" +#endif +#if defined(NITRO_NRT_EXPORTS) && defined(NITRO_NRT_LIB_) + #error "Can't export from a LIB'" +#endif + +// https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html +#if !defined(NITRO_NRT_library_export) && !defined(NITRO_NRT_library_import) + #if defined(__GNUC__) // && HAVE_VISIBILITY + // https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html + #define NITRO_NRT_library_export __attribute__((visibility("default"))) + + // For GCC, there's no difference in consuming ("importing") an .a or .so + #define NITRO_NRT_library_import /* no __declspec(dllimport) for GCC */ + + #elif defined(_MSC_VER) // && (defined(_WINDLL) && !defined(_LIB)) + #define NITRO_NRT_library_export __declspec(dllexport) + + // Actually, it seems that the linker is able to figure this out from the .LIB, + // so there doesn't seem to be a need for __declspec(dllimport). Clients don't + // need to #define NITRO_NITFCPP_DLL ... ? Well, almost ... it looks + // like __declspec(dllimport) is needed to get virtual "inline"s (e.g., + // destructors) correct. + #define NITRO_NRT_library_import __declspec(dllimport) + + #else + // https://stackoverflow.com/a/2164853/8877 + #define NITRO_NRT_library_export /* do nothing and hope for the best? */ + #define NITRO_NRT_library_import /* do nothing and hope for the best? */ + #pragma warning Unknown dynamic link import semantics. + #endif +#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_NRT_EXPORTS +// symbol defined on the command line. This symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// NITRO_NRT_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +#ifdef NITRO_NRT_EXPORTS + #define NITRO_NRT_API NITRO_NRT_library_export +#else + // Either building a static library (no NITRO_NRT_EXPORTS) or + // importing (not building) a shared library. + + // We need to know whether we're consuming (importing) a DLL or static LIB + // The default is a static LIB as that's what existing code/builds expect. + #ifdef NITRO_NRT_DLL_ + // Actually, it seems that the linker is able to figure this out from the .LIB, so + // there doesn't seem to be a need for __declspec(dllimport). Clients don't + // need to #define NITRO_NRT_DLL_ ... ? Well, almost ... it looks + // like __declspec(dllimport) is needed to get virtual "inline"s (e.g., + // destructors) correct. + #define NITRO_NRT_API NITRO_NRT_library_import + #else + #define NITRO_NRT_API /* "importing" a static LIB */ + #endif +#endif + +#if defined(_MSC_VER) +#pragma warning(disable: 4251) // '...' : class '...' needs to have dll-interface to be used by clients of struct '...' +#endif diff --git a/modules/c/nrt/include/nrt/Types.h b/modules/c/nrt/include/nrt/Types.h index 5788684fa5..58a2a2420d 100644 --- a/modules/c/nrt/include/nrt/Types.h +++ b/modules/c/nrt/include/nrt/Types.h @@ -159,9 +159,13 @@ typedef int nrt_CreationFlags; #define NRT_SUCCESS (1) #define NRT_FAILURE (0) -#define NRT_TRUE (1) -#define NRT_FALSE (0) - +#ifdef __cplusplus + #define NRT_TRUE (true) + #define NRT_FALSE (false) +#else + #define NRT_TRUE (1) + #define NRT_FALSE (0) +#endif #if defined(__cplusplus) && !defined(SWIGPYTHON) // "enum class" for C++ w/o SWIG diff --git a/modules/c/nrt/include/nrt/Utils.h b/modules/c/nrt/include/nrt/Utils.h index 773b34b8cf..caa7fa7fea 100644 --- a/modules/c/nrt/include/nrt/Utils.h +++ b/modules/c/nrt/include/nrt/Utils.h @@ -144,7 +144,7 @@ NRTAPI(NRT_BOOL) nrt_Utils_parseGeographicString(const char *dms, int *degrees, * with 7 elements to hand in to this function, otherwise you will * have memory corruption. */ -NRTPROT(void) nrt_Utils_geographicLatToCharArray(int degrees, int minutes, +NRTAPI(void) nrt_Utils_geographicLatToCharArray(int degrees, int minutes, double seconds, char *buffer7); NRTAPI(NRT_BOOL) nrt_Utils_isGeographicLat(int degrees, int minutes, double seconds); @@ -153,7 +153,7 @@ NRTAPI(NRT_BOOL) nrt_Utils_isGeographicLat(int degrees, int minutes, double seco * with 7 elements to hand in to this function, otherwise you will * have memory corruption. */ -NRTPROT(void) nrt_Utils_geographicLonToCharArray(int degrees, int minutes, +NRTAPI(void) nrt_Utils_geographicLonToCharArray(int degrees, int minutes, double seconds, char *buffer8); NRTAPI(NRT_BOOL) nrt_Utils_isGeographicLon(int degrees, int minutes, double seconds); @@ -162,23 +162,23 @@ NRTAPI(NRT_BOOL) nrt_Utils_isGeographicLon(int degrees, int minutes, double seco * with 7 elements to hand in to this function, otherwise you will * have memory corruption. */ -NRTPROT(void) nrt_Utils_decimalLatToCharArray(double decimal, char *buffer7); +NRTAPI(void) nrt_Utils_decimalLatToCharArray(double decimal, char *buffer7); /*! * Turn the decimal value into a string +-ddd.ddd. You must have a buffer * with 7 elements to hand in to this function, otherwise you will * have memory corruption. */ -NRTPROT(void) nrt_Utils_decimalLonToCharArray(double decimal, char *buffer8); +NRTAPI(void) nrt_Utils_decimalLonToCharArray(double decimal, char *buffer8); -NRTPROT(void) nrt_Utils_decimalLatToGeoCharArray(double decimal, char *buffer7); +NRTAPI(void) nrt_Utils_decimalLatToGeoCharArray(double decimal, char *buffer7); /*! * Turn the decimal value into a string +-ddd.ddd. You must have a buffer * with 7 elements to hand in to this function, otherwise you will * have memory corruption. */ -NRTPROT(void) nrt_Utils_decimalLonToGeoCharArray(double decimal, char *buffer8); +NRTAPI(void) nrt_Utils_decimalLonToGeoCharArray(double decimal, char *buffer8); /*! * Convert the corners type to a string. If for some reason, the type @@ -198,14 +198,14 @@ NRTAPI(char) nrt_Utils_cornersTypeAsCoordRep(nrt_CornersType type); NRTAPI(void) nrt_Utils_byteSwap(uint8_t* value, size_t size); NRTAPI(void) nrt_strcpy_s(char* dest, size_t sz, const char* src); -NRTAPI(void) nrt_strncpy_s(char* dest, size_t dest_sz, const char* src, size_t src_chars); +NRTPROT(void) nrt_strncpy_s(char* dest, size_t dest_sz, const char* src, size_t src_chars); NRTAPI(void) nrt_strcat_s(char* dest, size_t sz, const char* src); NRTAPI(char*) nrt_strdup(const char* src); -NRTAPI(size_t) nrt_strlen(const char* src); // aka strlen() -NRTAPI(uint32_t) nrt_strlen32(const char* src); -NRTAPI(uint16_t) nrt_strlen16(const char* src); -NRTAPI(uint8_t) nrt_strlen8(const char* src); +NRTPROT(size_t) nrt_strlen(const char* src); // aka strlen() +NRTPROT(uint32_t) nrt_strlen32(const char* src); +NRTPROT(uint16_t) nrt_strlen16(const char* src); +NRTPROT(uint8_t) nrt_strlen8(const char* src); NRT_CXX_ENDGUARD #endif diff --git a/modules/c/nrt/source/Utils.c b/modules/c/nrt/source/Utils.c index a538c4ae54..5d5340d0e8 100644 --- a/modules/c/nrt/source/Utils.c +++ b/modules/c/nrt/source/Utils.c @@ -744,7 +744,7 @@ NRTAPI(void) nrt_Utils_byteSwap(uint8_t *value, size_t size) } } -NRTAPI(void) nrt_strcpy_s(char* dest, size_t sz, const char* src) +NRTPROT(void) nrt_strcpy_s(char* dest, size_t sz, const char* src) { assert(sz > 0); #ifdef _MSC_VER // str*_s() is in C11 @@ -754,7 +754,7 @@ NRTAPI(void) nrt_strcpy_s(char* dest, size_t sz, const char* src) #endif } -NRTAPI(void) nrt_strncpy_s(char* dest, size_t dest_sz, const char* src, size_t src_chars) +NRTPROT(void) nrt_strncpy_s(char* dest, size_t dest_sz, const char* src, size_t src_chars) { assert(dest_sz > 0); #ifdef _MSC_VER // str*_s() is in C11 @@ -764,7 +764,7 @@ NRTAPI(void) nrt_strncpy_s(char* dest, size_t dest_sz, const char* src, size_t s #endif } -NRTAPI(void) nrt_strcat_s(char* dest, size_t sz, const char* src) +NRTPROT(void) nrt_strcat_s(char* dest, size_t sz, const char* src) { assert(sz > 0); #ifdef _MSC_VER // str*_s() is in C11 @@ -774,7 +774,7 @@ NRTAPI(void) nrt_strcat_s(char* dest, size_t sz, const char* src) #endif } -NRTAPI(char*) nrt_strdup(const char* src) +NRTPROT(char*) nrt_strdup(const char* src) { if (src != NULL) { @@ -790,19 +790,19 @@ NRTAPI(char*) nrt_strdup(const char* src) return NULL; } -NRTAPI(size_t) nrt_strlen(const char* src) +NRTPROT(size_t) nrt_strlen(const char* src) { return strlen(src); } -NRTAPI(uint32_t) nrt_strlen32(const char* src) +NRTPROT(uint32_t) nrt_strlen32(const char* src) { return (uint32_t) strlen(src); } -NRTAPI(uint16_t) nrt_strlen16(const char* src) +NRTPROT(uint16_t) nrt_strlen16(const char* src) { return (uint16_t)strlen(src); } -NRTAPI(uint8_t) nrt_strlen8(const char* src) +NRTPROT(uint8_t) nrt_strlen8(const char* src) { return (uint8_t)strlen(src); } diff --git a/modules/c/pch.h b/modules/c/pch.h index ca4079d2da..04f052c4f2 100644 --- a/modules/c/pch.h +++ b/modules/c/pch.h @@ -2,6 +2,9 @@ // We're building in Visual Studio ... used to control where we get a little bit of config info #define NITRO_PCH 1 +#ifndef CODA_OSS_LIBRARY_SHARED +#define CODA_OSS_LIBRARY_SHARED 1 +#endif // TODO: get rid of these someday? ... from Visual Studio code-analysis #pragma warning(disable: 6385) // Reading invalid data from '...': the readable size is '...' bytes, but '...' bytes may be read. @@ -27,12 +30,15 @@ #if defined(_WIN32) #undef BIGENDIAN #include +#pragma comment(lib, "Ws2_32") #else #include #endif #include #include +#pragma comment(lib, "openjpeg") +#pragma comment(lib, "jpeg") #pragma warning(pop) diff --git a/nitro.sln b/nitro.sln index 0f6fc7c9d7..3992b85bdc 100644 --- a/nitro.sln +++ b/nitro.sln @@ -16,8 +16,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nitf-c", "modules\c\nitf-c. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nitf-c++", "modules\c++\nitf-c++.vcxproj", "{8F357A19-799E-4971-850E-3F28485C130B}" ProjectSection(ProjectDependencies) = postProject - {C787537A-0CAC-4D6D-A6D6-A66765A06753} = {C787537A-0CAC-4D6D-A6D6-A66765A06753} {A676EDF3-F231-47C8-A6E6-0FE50B50B71B} = {A676EDF3-F231-47C8-A6E6-0FE50B50B71B} + {C787537A-0CAC-4D6D-A6D6-A66765A06753} = {C787537A-0CAC-4D6D-A6D6-A66765A06753} EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "c-nitf-shared", "c-nitf-shared", "{27A2685A-E869-42A2-956D-92994F60C536}" @@ -40,8 +40,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coda-oss", "externals\coda-oss\modules\c++\coda-oss.vcxproj", "{9997E895-5161-4DDF-8F3F-099894CB2F21}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XML_DATA_CONTENT", "modules\c\nitf\XML_DATA_CONTENT.vcxproj", "{78849481-D356-4CC7-B182-31C21F857ED1}" + ProjectSection(ProjectDependencies) = postProject + {53F9F908-C678-4DEE-9309-E71C1D03A45F} = {53F9F908-C678-4DEE-9309-E71C1D03A45F} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TEST_DES", "modules\c\nitf\TEST_DES.vcxproj", "{53F9F908-C678-4DEE-9309-E71C1D03A45F}" EndProject @@ -79,10 +80,6 @@ Global {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Debug|x64.Build.0 = Debug|x64 {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Release|x64.ActiveCfg = Release|x64 {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Release|x64.Build.0 = Release|x64 - {78849481-D356-4CC7-B182-31C21F857ED1}.Debug|x64.ActiveCfg = Debug|x64 - {78849481-D356-4CC7-B182-31C21F857ED1}.Debug|x64.Build.0 = Debug|x64 - {78849481-D356-4CC7-B182-31C21F857ED1}.Release|x64.ActiveCfg = Release|x64 - {78849481-D356-4CC7-B182-31C21F857ED1}.Release|x64.Build.0 = Release|x64 {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Debug|x64.ActiveCfg = Debug|x64 {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Debug|x64.Build.0 = Debug|x64 {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Release|x64.ActiveCfg = Release|x64 @@ -96,7 +93,6 @@ Global {C787537A-0CAC-4D6D-A6D6-A66765A06753} = {27A2685A-E869-42A2-956D-92994F60C536} {A45CB073-25A7-411D-A7E7-589BCC8AF547} = {5C5727E7-0CFF-42B4-8F5A-D31B3BC81F21} {9997E895-5161-4DDF-8F3F-099894CB2F21} = {7D26D571-0014-4C50-BF86-612E743E64B6} - {78849481-D356-4CC7-B182-31C21F857ED1} = {27A2685A-E869-42A2-956D-92994F60C536} {53F9F908-C678-4DEE-9309-E71C1D03A45F} = {27A2685A-E869-42A2-956D-92994F60C536} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution