diff --git a/externals/coda-oss/.clang-format b/externals/coda-oss/.clang-format index c869d381c..07fbeaf81 100644 --- a/externals/coda-oss/.clang-format +++ b/externals/coda-oss/.clang-format @@ -1,5 +1,5 @@ BasedOnStyle: Google -AccessModifierOffset: '0' +AccessModifierOffset: '-4' AlignAfterOpenBracket: Align AlignConsecutiveAssignments: 'false' AlignConsecutiveDeclarations: 'false' diff --git a/externals/coda-oss/modules/c++/sys/include/sys/Err.h b/externals/coda-oss/modules/c++/sys/include/sys/Err.h index a7765be20..93d0ab6b9 100644 --- a/externals/coda-oss/modules/c++/sys/include/sys/Err.h +++ b/externals/coda-oss/modules/c++/sys/include/sys/Err.h @@ -1,7 +1,7 @@ /* ========================================================================= - * This file is part of sys-c++ + * This file is part of sys-c++ * ========================================================================= - * + * * (C) Copyright 2004 - 2014, MDA Information Systems LLC * * sys-c++ is free software; you can redistribute it and/or modify @@ -14,8 +14,8 @@ * 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, + * You should have received a copy of the GNU Lesser General Public + * License along with this program; If not, * see . * */ @@ -25,11 +25,11 @@ #define __SYS_ERR_H__ /*! - * \file Err.h + * \file Err.h * \brief Errno like object - * + * * This object is very much like errno or the GetLastError() function - * in Win32. It doesnt do anything dazzling. It just reports the + * in Win32. It doesnt do anything dazzling. It just reports the * last error. This class is sometimes useful, because it understands * that its error id maps to a system string error, and it knows how * to obtain the error @@ -45,13 +45,13 @@ const static int __last_err__ = 0; /*! * \class Err * \brief Errno like object - * + * * This object is very much like errno or the GetLastError() function * in Win32. It doesnt do anything dazzling. It just reports the * last error. This class is sometimes useful, because it understands * that its error id maps to a system string error, and it knows how * to obtain the error. - * + * */ class Err @@ -66,7 +66,7 @@ class Err { mErrId = err.getErrID(); } - + /*! * Constructor from int error id * \param errNum The error to initialize with. Defaults to last @@ -75,7 +75,7 @@ class Err { setThis(errNum); } - + /*! * Assignment operator * \param err The err to take @@ -88,13 +88,13 @@ class Err } return *this; } - + //! Destructor virtual ~Err() {} - + /*! * This is the equivalent of strerror, done in a cross-platform - * manner, wrapped in this class. Prints this object to + * manner, wrapped in this class. Prints this object to * its error string * \return a string representation of this error * @@ -112,10 +112,10 @@ class Err mErrId = getLast(); } } - + //! Return the last error virtual int getLast() const; - + int getErrID() const { return mErrId; } protected: @@ -140,21 +140,21 @@ class SocketErr : public Err * \param err An error to initialize from * */ - SocketErr(const SocketErr& err) + SocketErr(const SocketErr& err) : + Err(err.getErrID()) { - mErrId = err.getErrID(); } - + /*! * Constructor * \param errNum An int to initialize from * - */ + */ SocketErr(int errNum = __last_err__) { setThis(errNum); } - + /*! * Assignment operator * \param err The err to take @@ -168,10 +168,10 @@ class SocketErr : public Err } return *this; } - + //! Destructor virtual ~SocketErr() {} - + //! Redefined for socket errors virtual int getLast() const; diff --git a/externals/nitro/README.md b/externals/nitro/README.md index 84b8c5832..b66ce646f 100644 --- a/externals/nitro/README.md +++ b/externals/nitro/README.md @@ -212,9 +212,16 @@ of fixing it later, which will make me eternally grateful. NITF Library Users: General Issues ---------------------------------- -If you want to use the default TRE plugins that come with the library, -NITRO already knows where they are installed, and you don't have to -do anything. - -If you want to override this behavior, you can set the -`NITF_PLUGIN_PATH` environment variable to your preferred location. +NITRO handles TREs by loading dynamic libraries at runtime. Therefore, you need +to make sure NITRO can find them. + +* If you are building from source, the location will be compiled in, and + you don't have to do anything extra. + +* If you are working from a binary release, you will have to tell + NITRO where the plugins are by setting the `NITF_PLUGIN_PATH` + enviornment variable. + This should look something like `/share/nitf/plugins`. + +* If you wish to use a custom TRE location, you can also specify that + with `NITF_PLUGIN_PATH`. diff --git a/externals/nitro/modules/c++/nitf/include/nitf/TRE.hpp b/externals/nitro/modules/c++/nitf/include/nitf/TRE.hpp index 034ff1913..f5c002c37 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/TRE.hpp +++ b/externals/nitro/modules/c++/nitf/include/nitf/TRE.hpp @@ -23,12 +23,12 @@ #ifndef __NITF_TRE_HPP__ #define __NITF_TRE_HPP__ -#include "nitf/TRE.h" -#include "nitf/System.hpp" +#include #include "nitf/Field.hpp" -#include "nitf/Pair.hpp" #include "nitf/Object.hpp" -#include +#include "nitf/Pair.hpp" +#include "nitf/System.hpp" +#include "nitf/TRE.h" /*! * \file TRE.hpp @@ -36,29 +36,30 @@ */ namespace nitf { - /*! * \class FieldIterator * \brief The C++ wrapper for the nitf_TREEnumerator */ class TREFieldIterator : public nitf::Object { -public: + public: TREFieldIterator() : mPair(NULL) { setNative(NULL); } - ~TREFieldIterator(){} + ~TREFieldIterator() + { + } //! Copy constructor - TREFieldIterator(const TREFieldIterator & x) + TREFieldIterator(const TREFieldIterator& x) { setNative(x.getNative()); } //! Assignment Operator - TREFieldIterator & operator=(const TREFieldIterator & x) + TREFieldIterator& operator=(const TREFieldIterator& x) { if (&x != this) { @@ -69,21 +70,21 @@ class TREFieldIterator : public nitf::Object } //! Set native object - TREFieldIterator(nitf_TREEnumerator * x) : mPair(NULL) + TREFieldIterator(nitf_TREEnumerator* x) : mPair(NULL) { setNative(x); getNativeOrThrow(); increment(); } - TREFieldIterator(NITF_DATA * x) + TREFieldIterator(NITF_DATA* x) { setNative((nitf_TREEnumerator*)x); getNativeOrThrow(); increment(); } - TREFieldIterator & operator=(NITF_DATA * x) + TREFieldIterator& operator=(NITF_DATA* x) { setNative((nitf_TREEnumerator*)x); getNativeOrThrow(); @@ -98,8 +99,8 @@ class TREFieldIterator : public nitf::Object */ bool operator==(const nitf::TREFieldIterator& it2) { - //need to do this double-check so that the last iteration of an iterator - //doesn't get skipped + // need to do this double-check so that the last iteration of an + // iterator doesn't get skipped if (getNative() == it2.getNative()) return mPair == it2.mPair; return false; @@ -120,11 +121,11 @@ class TREFieldIterator : public nitf::Object mPair = enumerator->next(enumerator, &error); else mPair = NULL; - setNative(enumerator); //always reset, in case it got destroyed + setNative(enumerator); // always reset, in case it got destroyed } //! Increment the iterator (postfix) - void operator++(int ) + void operator++(int) { increment(); } @@ -148,43 +149,40 @@ class TREFieldIterator : public nitf::Object nitf_TREEnumerator* enumerator = getNative(); if (enumerator && isValid()) { - const char* desc = enumerator->getFieldDescription(enumerator, - &error); + const char* desc = + enumerator->getFieldDescription(enumerator, &error); if (desc) return std::string(desc); } return ""; } -private: + private: nitf_Error error; - nitf_Pair *mPair; + nitf_Pair* mPair; }; - - /*! * \class TRE * \brief The C++ wrapper for the nitf_TRE */ DECLARE_CLASS(TRE) { -public: - -typedef nitf::TREFieldIterator Iterator; + public: + typedef nitf::TREFieldIterator Iterator; //! Copy constructor - TRE(const TRE & x); + TRE(const TRE& x); //! Assignment Operator - TRE & operator=(const TRE & x); + TRE& operator=(const TRE& x); //! Set native object TRE(nitf_TRE * x); TRE(NITF_DATA * x); - TRE & operator=(NITF_DATA * x); + TRE& operator=(NITF_DATA* x); //! Without the const char* constructors, in VS if you do something like // TRE("my_tre_tag") @@ -220,26 +218,30 @@ typedef nitf::TREFieldIterator Iterator; */ nitf::Field getField(const std::string& key); - nitf::Field operator[] (const std::string& key); + nitf::Field operator[](const std::string& key); /*! * Returns a List of Fields that match the given pattern. */ nitf::List find(const std::string& pattern); - /*! - * Sets the field with the given value. The input value - * is converted to a std::string, and the string-ized value - * is then used as the value input for the TRE field. - */ - template void setField(std::string key, T value) + /*! + * Sets the field with the given value. The input value + * is converted to a std::string, and the string-ized value + * is then used as the value input for the TRE field. + */ + template + void setField(std::string key, T value) { - std::string s = str::toString(value); - if (!nitf_TRE_setField(getNative(), - key.c_str(), - (NITF_DATA*)s.c_str(), - s.size(), - &error) ); + std::string s = str::toString(value); + if (!nitf_TRE_setField(getNative(), + key.c_str(), + (NITF_DATA*)s.c_str(), + s.size(), + &error)) + { + throw NITFException(&error); + } } /*! @@ -255,7 +257,7 @@ typedef nitf::TREFieldIterator Iterator; std::string getTag() const; //! Set the tag - void setTag(const std::string & value); + void setTag(const std::string& value); /** * Get the TRE identifier. This is NOT the tag, however it may be the @@ -265,10 +267,8 @@ typedef nitf::TREFieldIterator Iterator; */ std::string getID() const; - -private: + private: nitf_Error error; }; - } #endif diff --git a/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp index e6d2bff85..e789b4e5c 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp @@ -28,28 +28,21 @@ namespace { TEST_CASE(setFields) { - //create an ACFTA TRE + // create an ACFTA TRE nitf::TRE tre("ACFTA"); - //set a field + // set a field tre.setField("AC_MSN_ID", "fly-by"); TEST_ASSERT_EQ(tre.getField("AC_MSN_ID").toString(), std::string("fly-by ")); - //re-set the field + // re-set the field tre.setField("AC_MSN_ID", 1.2345678); TEST_ASSERT_EQ(tre.getField("AC_MSN_ID").toString(), std::string("1.2345678 ")); - //try setting an invalid tag - try - { - tre.setField("invalid-tag", "some data"); - } - catch (const except::Throwable& t) - { - TEST_ASSERT(false); - } + // try setting an invalid tag + TEST_EXCEPTION(tre.setField("invalid-tag", "some data")); } TEST_CASE(cloneTRE) @@ -60,10 +53,9 @@ TEST_CASE(cloneTRE) // try cloning the tre nitf::TRE dolly = tre.clone(); - //the two should NOT be equal -- underlying object is different + // the two should NOT be equal -- underlying object is different TEST_ASSERT(tre != dolly); - TEST_ASSERT_EQ(tre.getField("FILCMT").toString(), - std::string("fyi")); + TEST_ASSERT_EQ(tre.getField("FILCMT").toString(), std::string("fyi")); } TEST_CASE(basicIteration) diff --git a/externals/nitro/modules/c/CMakeLists.txt b/externals/nitro/modules/c/CMakeLists.txt index 67c2f9d81..e3062dd93 100644 --- a/externals/nitro/modules/c/CMakeLists.txt +++ b/externals/nitro/modules/c/CMakeLists.txt @@ -1,4 +1,4 @@ -set(NITRO_VERSION "2.8") +set(NITRO_VERSION "2.9") add_subdirectory(nrt) add_subdirectory(nitf) diff --git a/externals/nitro/modules/c/nitf/source/PluginRegistry.c b/externals/nitro/modules/c/nitf/source/PluginRegistry.c index b905c315e..7c60179cc 100644 --- a/externals/nitro/modules/c/nitf/source/PluginRegistry.c +++ b/externals/nitro/modules/c/nitf/source/PluginRegistry.c @@ -262,12 +262,24 @@ NITFPRIV(nitf_PluginRegistry*) implicitConstruct(nitf_Error* error) if (!pluginEnvVar) { /* Take the default path */ - strcpy(reg->path, NITF_DEFAULT_PLUGIN_PATH); - return reg; + if (nrt_Directory_exists(NITF_DEFAULT_PLUGIN_PATH)) + { + strncpy(reg->path, NITF_DEFAULT_PLUGIN_PATH, NITF_MAX_PATH); + return reg; + } + else + { + fprintf(stderr, + "Warning: Unable to find plugin path.\n" + "Specify plugin location by setting environment variable " + "%s, or by building the library from source\n", + NITF_PLUGIN_PATH); + return reg; + } } else { - strcpy(reg->path, pluginEnvVar); + strncpy(reg->path, pluginEnvVar, NITF_MAX_PATH); } /* * If the we have a user-defined path, they might not diff --git a/externals/nitro/modules/python/nitf/setup.py b/externals/nitro/modules/python/nitf/setup.py deleted file mode 100644 index 728997c0a..000000000 --- a/externals/nitro/modules/python/nitf/setup.py +++ /dev/null @@ -1,30 +0,0 @@ -from distutils.core import setup -from distutils.command.install import INSTALL_SCHEMES -import os, glob, sys, shutil - -files = [os.path.normpath(f).replace('\\', '/') for f in \ - glob.glob('src/python/*.dll') + \ - glob.glob('src/python/nitf/*.so') + \ - glob.glob('src/python/nitf/*.pyd')] - - -out_dir = 'build/lib/nitf' -if not os.path.exists(out_dir): - os.makedirs(out_dir) - -for f in files: - shutil.copy(f, out_dir) - - -setup( - name = 'nitro-python', - version = '2.8', - url = 'http://nitro-nitf.sourceforge.net', - author = 'tzellman', - author_email = 'tzellman@users.sourceforget.net', - description = 'Python bindings for the NITRO project', - packages = ['nitf'], - package_dir = {'':'src/python'}, - license = "LGPL", - scripts=['src/test/python/nitf_extract.py', 'src/test/python/nitf_print.py'], -) diff --git a/externals/nitro/modules/python/nitf/source/generated/nitropy_wrap.cxx b/externals/nitro/modules/python/nitf/source/generated/nitropy_wrap.cxx index 9244d6677..57426245a 100644 --- a/externals/nitro/modules/python/nitf/source/generated/nitropy_wrap.cxx +++ b/externals/nitro/modules/python/nitf/source/generated/nitropy_wrap.cxx @@ -34696,8 +34696,8 @@ SWIG_init(void) { SWIG_Python_SetConstant(d, "NITF_TRE_HASH_SIZE",SWIG_From_int(static_cast< int >(8))); SWIG_Python_SetConstant(d, "HAVE_CLOCK_GETTIME",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "HAVE_SYS_TIME_H",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "NRT_LIB_VERSION",SWIG_FromCharPtr("2.8")); - SWIG_Python_SetConstant(d, "NITF_LIB_VERSION",SWIG_FromCharPtr("2.8")); + SWIG_Python_SetConstant(d, "NRT_LIB_VERSION",SWIG_FromCharPtr("2.9")); + SWIG_Python_SetConstant(d, "NITF_LIB_VERSION",SWIG_FromCharPtr("2.9")); SWIG_Python_SetConstant(d, "NITF_COMPRESSION_HASH_SIZE",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "NITF_DECOMPRESSION_HASH_SIZE",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "NITF_PLUGIN_PATH",SWIG_FromCharPtr("NITF_PLUGIN_PATH")); diff --git a/externals/nitro/modules/wscript b/externals/nitro/modules/wscript index 596a25d71..a7a01e4c7 100644 --- a/externals/nitro/modules/wscript +++ b/externals/nitro/modules/wscript @@ -1,6 +1,6 @@ import os -VERSION = '2.8' +VERSION = '2.9' def options(opt): opt.recurse()