diff --git a/Utilities/ITK/Utilities/itksys/Base64.h b/Utilities/ITK/Utilities/itksys/Base64.h new file mode 100755 index 0000000000000000000000000000000000000000..f101d79d3c44144d60e09e98446af40489ca13f1 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/Base64.h @@ -0,0 +1,118 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: Base64.h.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_Base64_h +#define itksys_Base64_h + +#include <itksys/Configure.h> + +/* Redefine all public interface symbol names to be in the proper + namespace. These macros are used internally to kwsys only, and are + not visible to user code. Use kwsysHeaderDump.pl to reproduce + these macros after making changes to the interface. */ +#if !defined(KWSYS_NAMESPACE) +# define kwsys_ns(x) itksys##x +# define kwsysEXPORT itksys_EXPORT +#endif +#define kwsysBase64 kwsys_ns(Base64) +#define kwsysBase64_Decode kwsys_ns(Base64_Decode) +#define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3) +#define kwsysBase64_Encode kwsys_ns(Base64_Encode) +#define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1) +#define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2) +#define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3) + +#if defined(__cplusplus) +extern "C" +{ +#endif + +/** + * Encode 3 bytes into a 4 byte string. + */ +kwsysEXPORT void kwsysBase64_Encode3(const unsigned char *src, + unsigned char *dest); + +/** + * Encode 2 bytes into a 4 byte string. + */ +kwsysEXPORT void kwsysBase64_Encode2(const unsigned char *src, + unsigned char *dest); + +/** + * Encode 1 bytes into a 4 byte string. + */ +kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src, + unsigned char *dest); + +/** + * Encode 'length' bytes from the input buffer and store the encoded + * stream into the output buffer. Return the length of the encoded + * buffer (output). Note that the output buffer must be allocated by + * the caller (length * 1.5 should be a safe estimate). If 'mark_end' + * is true than an extra set of 4 bytes is added to the end of the + * stream if the input is a multiple of 3 bytes. These bytes are + * invalid chars and therefore they will stop the decoder thus + * enabling the caller to decode a stream without actually knowing how + * much data to expect (if the input is not a multiple of 3 bytes then + * the extra padding needed to complete the encode 4 bytes will stop + * the decoding anyway). + */ +kwsysEXPORT unsigned long kwsysBase64_Encode(const unsigned char *input, + unsigned long length, + unsigned char *output, + int mark_end); + +/** + * Decode 4 bytes into a 3 byte string. Returns the number of bytes + * actually decoded. + */ +kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src, + unsigned char *dest); + +/** + * Decode bytes from the input buffer and store the decoded stream + * into the output buffer until 'length' bytes have been decoded. + * Return the real length of the decoded stream (which should be equal + * to 'length'). Note that the output buffer must be allocated by the + * caller. If 'max_input_length' is not null, then it specifies the + * number of encoded bytes that should be at most read from the input + * buffer. In that case the 'length' parameter is ignored. This + * enables the caller to decode a stream without actually knowing how + * much decoded data to expect (of course, the buffer must be large + * enough). + */ +kwsysEXPORT unsigned long kwsysBase64_Decode(const unsigned char *input, + unsigned long length, + unsigned char *output, + unsigned long max_input_length); + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +/* If we are building a kwsys .c or .cxx file, let it use these macros. + Otherwise, undefine them to keep the namespace clean. */ +#if !defined(KWSYS_NAMESPACE) +# undef kwsys_ns +# undef kwsysEXPORT +# undef kwsysBase64 +# undef kwsysBase64_Decode +# undef kwsysBase64_Decode3 +# undef kwsysBase64_Encode +# undef kwsysBase64_Encode1 +# undef kwsysBase64_Encode2 +# undef kwsysBase64_Encode3 +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/CommandLineArguments.hxx b/Utilities/ITK/Utilities/itksys/CommandLineArguments.hxx new file mode 100755 index 0000000000000000000000000000000000000000..e1cc681fa51c79b79d2688dd5d917cf9cd03fafb --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/CommandLineArguments.hxx @@ -0,0 +1,227 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: CommandLineArguments.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_CommandLineArguments_hxx +#define itksys_CommandLineArguments_hxx + +#include <itksys/Configure.h> +#include <itksys/Configure.hxx> + +#include <itksys/stl/string> + +/* Define this macro temporarily to keep the code readable. */ +#if !defined (KWSYS_NAMESPACE) && !itksys_NAME_IS_KWSYS +# define kwsys_stl itksys_stl +#endif + +namespace itksys +{ + +class CommandLineArgumentsInternal; + +/** \class CommandLineArguments + * \brief Command line arguments processing code. + * + * Find specified arguments with optional options and execute specified methods + * or set given variables. + * + * The two interfaces it knows are callback based and variable based. For + * callback based, you have to register callback for particular argument using + * AddCallback method. When that argument is passed, the callback will be + * called with argument, value, and call data. For boolean (NO_ARGUMENT) + * arguments, the value is "1". If the callback returns 0 the argument parsing + * will stop with an error. + * + * For the variable interface you associate variable with each argument. When + * the argument is specified, the variable is set to the specified value casted + * to the apropriate type. For boolean (NO_ARGUMENT), the value is "1". + * + * Both interfaces can be used at the same time. + * + * Possible argument types are: + * NO_ARGUMENT - The argument takes no value : --A + * CONCAT_ARGUMENT - The argument takes value after no space : --Aval + * SPACE_ARGUMENT - The argument takes value after space : --A val + * EQUAL_ARGUMENT - The argument takes value after equal : --A=val + * + * Example use: + * + * kwsys::CommandLineArguments arg; + * arg.Initialize(argc, argv); + * typedef kwsys::CommandLineArguments argT; + * arg.AddArgument("--something", argT::EQUAL_ARGUMENT, &some_variable, + * "This is help string for --something"); + * if ( !arg.Parse() ) + * { + * kwsys_ios::cerr << "Problem parsing arguments" << kwsys_ios::endl; + * res = 1; + * } + * + */ + +class itksys_EXPORT CommandLineArguments +{ +public: + CommandLineArguments(); + ~CommandLineArguments(); + + /** + * Various argument types. + */ + enum ArgumentTypeEnum { + NO_ARGUMENT, + CONCAT_ARGUMENT, + SPACE_ARGUMENT, + EQUAL_ARGUMENT + }; + + /** + * Various variable types. When using the variable interface, this specifies + * what type the variable is. + */ + enum VariableTypeEnum { + NO_VARIABLE_TYPE = 0, // The variable is not specified + INT_TYPE, // The variable is integer (int) + BOOL_TYPE, // The vairable is boolean (bool) + DOUBLE_TYPE, // The variable is float (double) + STRING_TYPE, // The variable is string (char*) + STL_STRING_TYPE // The variable is string (char*) + }; + + /** + * Prototypes for callbacks for callback interface. + */ + typedef int(*CallbackType)(const char* argument, const char* value, + void* call_data); + typedef int(*ErrorCallbackType)(const char* argument, void* client_data); + + /** + * Initialize internal data structures. This should be called before parsing. + */ + void Initialize(int argc, const char* const argv[]); + void Initialize(int argc, char* argv[]); + + /** + * Initialize internal data structure and pass arguments one by one. This is + * convenience method for use from scripting languages where argc and argv + * are not available. + */ + void Initialize(); + void ProcessArgument(const char* arg); + + /** + * This method will parse arguments and call apropriate methods. + */ + int Parse(); + + /** + * This method will add a callback for a specific argument. The arguments to + * it are argument, argument type, callback method, and call data. The + * argument help specifies the help string used with this option. The + * callback and call_data can be skipped. + */ + void AddCallback(const char* argument, ArgumentTypeEnum type, + CallbackType callback, void* call_data, const char* help); + + /** + * Add handler for argument which is going to set the variable to the + * specified value. If the argument is specified, the option is casted to the + * apropriate type. + */ + void AddArgument(const char* argument, ArgumentTypeEnum type, bool* variable, + const char* help); + void AddArgument(const char* argument, ArgumentTypeEnum type, int* variable, + const char* help); + void AddArgument(const char* argument, ArgumentTypeEnum type, + double* variable, const char* help); + void AddArgument(const char* argument, ArgumentTypeEnum type, + char** variable, const char* help); + void AddArgument(const char* argument, ArgumentTypeEnum type, + kwsys_stl::string* variable, const char* help); + + /** + * Add handler for boolean argument. The argument does not take any option + * and if it is specified, the value of the variable is true/1, otherwise it + * is false/0. + */ + void AddBooleanArgument(const char* argument, bool* variable, const char* + help); + void AddBooleanArgument(const char* argument, int* variable, const char* + help); + + /** + * Set the callbacks for error handling. + */ + void SetClientData(void* client_data); + void SetUnknownArgumentCallback(ErrorCallbackType callback); + + /** + * Get remaining arguments. It allocates space for argv, so you have to call + * delete[] on it. + */ + void GetRemainingArguments(int* argc, char*** argv); + void DeleteRemainingArguments(int argc, char*** argv); + + /** + * Return string containing help. If the argument is specified, only return + * help for that argument. + */ + const char* GetHelp() { return this->Help.c_str(); } + const char* GetHelp(const char* arg); + + /** + * Get / Set the help line length. This length is used when generating the + * help page. Default length is 80. + */ + void SetLineLength(unsigned int); + unsigned int GetLineLength(); + + /** + * Get the executable name (argv0). This is only available when using + * Initialize with argc/argv. + */ + const char* GetArgv0(); + + /** + * Get index of the last argument parsed. This is the last argument that was + * parsed ok in the original argc/argv list. + */ + unsigned int GetLastArgument(); + +protected: + void GenerateHelp(); + + //! This is internal method that registers variable with argument + void AddArgument(const char* argument, ArgumentTypeEnum type, + VariableTypeEnum vtype, void* variable, const char* help); + + typedef CommandLineArgumentsInternal Internal; + Internal* Internals; + kwsys_stl::string Help; + + unsigned int LineLength; +}; + +} // namespace itksys + +/* Undefine temporary macro. */ +#if !defined (KWSYS_NAMESPACE) && !itksys_NAME_IS_KWSYS +# undef kwsys_stl +#endif + +#endif + + + + + diff --git a/Utilities/ITK/Utilities/itksys/Configure.h b/Utilities/ITK/Utilities/itksys/Configure.h new file mode 100755 index 0000000000000000000000000000000000000000..3ca1ead828b44b9985e6eea16b53d917f6d66620 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/Configure.h @@ -0,0 +1,70 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: Configure.h.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_Configure_h +#define itksys_Configure_h + +/* If we are building a kwsys .c or .cxx file, let it use the kwsys + namespace. When not building a kwsys source file these macros are + temporarily defined inside the headers that use them. */ +#if defined(KWSYS_NAMESPACE) +# define kwsys_ns(x) itksys##x +# define kwsysEXPORT itksys_EXPORT +#endif + +/* Setup the export macro. */ +#if defined(_WIN32) && 0 +# if defined(itksys_EXPORTS) +# define itksys_EXPORT __declspec(dllexport) +# else +# define itksys_EXPORT __declspec(dllimport) +# endif +#else +# define itksys_EXPORT +#endif + +/* Enable warnings that are off by default but are useful. */ +#if !defined(itksys_NO_WARNING_ENABLE) +# if defined(_MSC_VER) +# pragma warning ( default : 4263 ) /* no override, call convention differs */ +# endif +#endif + +/* Disable warnings that are on by default but occur in valid code. */ +#if !defined(itksys_NO_WARNING_DISABLE) +# if defined(_MSC_VER) +# pragma warning (disable: 4097) /* typedef is synonym for class */ +# pragma warning (disable: 4127) /* conditional expression is constant */ +# pragma warning (disable: 4244) /* possible loss in conversion */ +# pragma warning (disable: 4251) /* missing DLL-interface */ +# pragma warning (disable: 4305) /* truncation from type1 to type2 */ +# pragma warning (disable: 4309) /* truncation of constant value */ +# pragma warning (disable: 4514) /* unreferenced inline function */ +# pragma warning (disable: 4706) /* assignment in conditional expression */ +# pragma warning (disable: 4710) /* function not inlined */ +# pragma warning (disable: 4786) /* identifier truncated in debug info */ +# endif +#endif + +/* MSVC 6.0 in release mode will warn about code it produces with its + optimizer. Disable the warnings specifically for this + configuration. Real warnings will be revealed by a debug build or + by other compilers. */ +#if !defined(itksys_NO_WARNING_DISABLE_BOGUS) +# if defined(_MSC_VER) && (_MSC_VER < 1300) && defined(NDEBUG) +# pragma warning ( disable : 4701 ) /* Variable may be used uninitialized. */ +# pragma warning ( disable : 4702 ) /* Unreachable code. */ +# endif +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/Configure.hxx b/Utilities/ITK/Utilities/itksys/Configure.hxx new file mode 100755 index 0000000000000000000000000000000000000000..225c5f089acf3b93668281eb251628e8449cb15a --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/Configure.hxx @@ -0,0 +1,168 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: Configure.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_Configure_hxx +#define itksys_Configure_hxx + +/* Include C configuration. */ +#include <itksys/Configure.h> + +/* Whether kwsys namespace is "kwsys". */ +#define itksys_NAME_IS_KWSYS 0 + +/* Whether ANSI C++ stream headers are to be used. */ +#define itksys_IOS_USE_ANSI 1 + +/* Whether ANSI C++ streams are in std namespace. */ +#define itksys_IOS_HAVE_STD 1 + +/* Whether ANSI C++ <sstream> header is to be used. */ +#define itksys_IOS_USE_SSTREAM 1 + +/* Whether old C++ <strstream.h> header is to be used. */ +#define itksys_IOS_USE_STRSTREAM_H 0 + +/* Whether old C++ <strstrea.h> header is to be used. */ +#define itksys_IOS_USE_STRSTREA_H 0 + +/* Whether STL is in std namespace. */ +#define itksys_STL_HAVE_STD 1 + +/* Whether the STL string has operator<< for ostream. */ +#define itksys_STL_STRING_HAVE_OSTREAM 1 + +/* Whether the STL string has operator>> for istream. */ +#define itksys_STL_STRING_HAVE_ISTREAM 1 + +/* Whether the STL string has operator!= for char*. */ +#define itksys_STL_STRING_HAVE_NEQ_CHAR 1 + +/* Define the stl namespace macro. */ +#if itksys_STL_HAVE_STD +# define itksys_stl std +#else +# define itksys_stl +#endif + +/* Define the ios namespace macro. */ +#if itksys_IOS_HAVE_STD +# define itksys_ios_namespace std +#else +# define itksys_ios_namespace +#endif +#if itksys_IOS_USE_SSTREAM +# define itksys_ios itksys_ios_namespace +#else +# define itksys_ios itksys_ios +#endif + +/* Whether the cstddef header is available. */ +#define itksys_CXX_HAS_CSTDDEF 1 + +/* Whether the compiler supports null template arguments. */ +#define itksys_CXX_HAS_NULL_TEMPLATE_ARGS 1 + +/* Define the null template arguments macro. */ +#if itksys_CXX_HAS_NULL_TEMPLATE_ARGS +# define itksys_CXX_NULL_TEMPLATE_ARGS <> +#else +# define itksys_CXX_NULL_TEMPLATE_ARGS +#endif + +/* Whether the compiler supports member templates. */ +#define itksys_CXX_HAS_MEMBER_TEMPLATES 1 + +/* Whether the compiler supports argument dependent lookup. */ +#define itksys_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP 1 + +/* Whether the compiler supports standard full specialization syntax. */ +#define itksys_CXX_HAS_FULL_SPECIALIZATION 1 + +/* Define the specialization definition macro. */ +#if itksys_CXX_HAS_FULL_SPECIALIZATION +# define itksys_CXX_DEFINE_SPECIALIZATION template <> +#else +# define itksys_CXX_DEFINE_SPECIALIZATION +#endif + +/* Define typename keyword macro for use in declarations. */ +#if defined(_MSC_VER) && _MSC_VER < 1300 +# define itksys_CXX_DECL_TYPENAME +#else +# define itksys_CXX_DECL_TYPENAME typename +#endif + +/* Whether the stl has iterator_traits. */ +#define itksys_STL_HAS_ITERATOR_TRAITS 1 + +/* Whether the stl has iterator_category. */ +#define itksys_STL_HAS_ITERATOR_CATEGORY 0 + +/* Whether the stl has __iterator_category. */ +#define itksys_STL_HAS___ITERATOR_CATEGORY 0 + +/* Whether the stl allocator is the standard template. */ +#define itksys_STL_HAS_ALLOCATOR_TEMPLATE 1 + +/* Whether the stl allocator is not a template. */ +#define itksys_STL_HAS_ALLOCATOR_NONTEMPLATE 0 + +/* Whether the stl allocator has rebind. */ +#define itksys_STL_HAS_ALLOCATOR_REBIND 1 + +/* Whether the stl allocator has a size argument for max_size. */ +#define itksys_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0 + +/* Whether the stl containers support allocator objects. */ +#define itksys_STL_HAS_ALLOCATOR_OBJECTS 1 + +/* Whether struct stat has the st_mtim member for high resolution times. */ +#define itksys_STAT_HAS_ST_MTIM 1 + +/* If building a C++ file in kwsys itself, give the source file + access to the macros without a configured namespace. */ +#if defined(KWSYS_NAMESPACE) +# if !itksys_NAME_IS_KWSYS +# define kwsys_stl itksys_stl +# define kwsys_ios itksys_ios +# define kwsys itksys +# endif +# define KWSYS_NAME_IS_KWSYS itksys_NAME_IS_KWSYS +# define KWSYS_STL_HAVE_STD itksys_STL_HAVE_STD +# define KWSYS_IOS_HAVE_STD itksys_IOS_HAVE_STD +# define KWSYS_IOS_USE_ANSI itksys_IOS_USE_ANSI +# define KWSYS_IOS_USE_SSTREAM itksys_IOS_USE_SSTREAM +# define KWSYS_IOS_USE_STRSTREAM_H itksys_IOS_USE_STRSTREAM_H +# define KWSYS_IOS_USE_STRSTREA_H itksys_IOS_USE_STRSTREA_H +# define KWSYS_STAT_HAS_ST_MTIM itksys_STAT_HAS_ST_MTIM +# define KWSYS_CXX_HAS_CSTDDEF itksys_CXX_HAS_CSTDDEF +# define KWSYS_STL_STRING_HAVE_OSTREAM itksys_STL_STRING_HAVE_OSTREAM +# define KWSYS_STL_STRING_HAVE_ISTREAM itksys_STL_STRING_HAVE_ISTREAM +# define KWSYS_STL_STRING_HAVE_NEQ_CHAR itksys_STL_STRING_HAVE_NEQ_CHAR +# define KWSYS_CXX_NULL_TEMPLATE_ARGS itksys_CXX_NULL_TEMPLATE_ARGS +# define KWSYS_CXX_HAS_MEMBER_TEMPLATES itksys_CXX_HAS_MEMBER_TEMPLATES +# define KWSYS_CXX_HAS_FULL_SPECIALIZATION itksys_CXX_HAS_FULL_SPECIALIZATION +# define KWSYS_CXX_DEFINE_SPECIALIZATION itksys_CXX_DEFINE_SPECIALIZATION +# define KWSYS_CXX_DECL_TYPENAME itksys_CXX_DECL_TYPENAME +# define KWSYS_STL_HAS_ALLOCATOR_REBIND itksys_STL_HAS_ALLOCATOR_REBIND +# define KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT itksys_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT +# define KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP itksys_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP +# define KWSYS_STL_HAS_ITERATOR_TRAITS itksys_STL_HAS_ITERATOR_TRAITS +# define KWSYS_STL_HAS_ITERATOR_CATEGORY itksys_STL_HAS_ITERATOR_CATEGORY +# define KWSYS_STL_HAS___ITERATOR_CATEGORY itksys_STL_HAS___ITERATOR_CATEGORY +# define KWSYS_STL_HAS_ALLOCATOR_TEMPLATE itksys_STL_HAS_ALLOCATOR_TEMPLATE +# define KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE itksys_STL_HAS_ALLOCATOR_NONTEMPLATE +# define KWSYS_STL_HAS_ALLOCATOR_OBJECTS itksys_STL_HAS_ALLOCATOR_OBJECTS +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/Directory.hxx b/Utilities/ITK/Utilities/itksys/Directory.hxx new file mode 100755 index 0000000000000000000000000000000000000000..284e72a8134a4dd0ba1bb0f82c23f9b4211f90d3 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/Directory.hxx @@ -0,0 +1,74 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: Directory.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_Directory_hxx +#define itksys_Directory_hxx + +#include <itksys/Configure.h> + +namespace itksys +{ + +class DirectoryInternals; + +/** \class Directory + * \brief Portable directory/filename traversal. + * + * Directory provides a portable way of finding the names of the files + * in a system directory. + * + * Directory currently works with Windows and Unix operating systems. + */ +class itksys_EXPORT Directory +{ +public: + Directory(); + ~Directory(); + + /** + * Load the specified directory and load the names of the files + * in that directory. 0 is returned if the directory can not be + * opened, 1 if it is opened. + */ + bool Load(const char*); + + /** + * Return the number of files in the current directory. + */ + unsigned long GetNumberOfFiles() const; + + /** + * Return the file at the given index, the indexing is 0 based + */ + const char* GetFile(unsigned long) const; + + /** + * Return the path to Open'ed directory + */ + const char* GetPath() const; + +protected: + /** + * Clear the internal structure. Used internally at beginning of Load(...) to clear + * the cache. + */ + void Clear(); + +private: + // Private implementation details. + DirectoryInternals* Internal; +}; // End Class: Directory + +} // namespace itksys + +#endif diff --git a/Utilities/ITK/Utilities/itksys/FundamentalType.h b/Utilities/ITK/Utilities/itksys/FundamentalType.h new file mode 100755 index 0000000000000000000000000000000000000000..5c174d0a3cb0360fefa9f7656b8f20f8f04b1ae0 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/FundamentalType.h @@ -0,0 +1,143 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: FundamentalType.h.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_FundamentalType_h +#define itksys_FundamentalType_h + +#include <itksys/Configure.h> + +/* Redefine all public interface symbol names to be in the proper + namespace. These macros are used internally to kwsys only, and are + not visible to user code. Use kwsysHeaderDump.pl to reproduce + these macros after making changes to the interface. */ +#if !defined(KWSYS_NAMESPACE) +# define kwsys_ns(x) itksys##x +# define kwsysEXPORT itksys_EXPORT +#endif +#define kwsysFundamentalType kwsys_ns(FundamentalType) +#define kwsysFundamentalType_Int8 kwsys_ns(FundamentalType_Int8) +#define kwsysFundamentalType_UInt8 kwsys_ns(FundamentalType_UInt8) +#define kwsysFundamentalType_Int16 kwsys_ns(FundamentalType_Int16) +#define kwsysFundamentalType_UInt16 kwsys_ns(FundamentalType_UInt16) +#define kwsysFundamentalType_Int32 kwsys_ns(FundamentalType_Int32) +#define kwsysFundamentalType_UInt32 kwsys_ns(FundamentalType_UInt32) +#define kwsysFundamentalType_Int64 kwsys_ns(FundamentalType_Int64) +#define kwsysFundamentalType_UInt64 kwsys_ns(FundamentalType_UInt64) + +/* The size of fundamental types. Types that do not exist have size 0. */ +#define itksys_SIZEOF_CHAR 1 +#define itksys_SIZEOF_SHORT 2 +#define itksys_SIZEOF_INT 4 +#define itksys_SIZEOF_LONG 4 +#define itksys_SIZEOF_LONG_LONG 8 +#define itksys_SIZEOF___INT64 0 + +/* Whether types "long long" and "__int64" are enabled. If a type is + enabled then it is a unique fundamental type. */ +#define itksys_USE_LONG_LONG 1 +#define itksys_USE___INT64 0 + +/* Whether type "char" is signed (it may be signed or unsigned). */ +#define itksys_CHAR_IS_SIGNED 1 + +#if defined(__cplusplus) +extern "C" +{ +#endif + +/* Select an 8-bit integer type. */ +#if itksys_SIZEOF_CHAR == 1 +typedef signed char kwsysFundamentalType_Int8; +typedef unsigned char kwsysFundamentalType_UInt8; +#else +# error "No native data type can represent an 8-bit integer." +#endif + +/* Select a 16-bit integer type. */ +#if itksys_SIZEOF_SHORT == 2 +typedef short kwsysFundamentalType_Int16; +typedef unsigned short kwsysFundamentalType_UInt16; +#elif itksys_SIZEOF_INT == 2 +typedef int kwsysFundamentalType_Int16; +typedef unsigned int kwsysFundamentalType_UInt16; +#else +# error "No native data type can represent a 16-bit integer." +#endif + +/* Select a 32-bit integer type. */ +#if itksys_SIZEOF_INT == 4 +typedef int kwsysFundamentalType_Int32; +typedef unsigned int kwsysFundamentalType_UInt32; +#elif itksys_SIZEOF_LONG == 4 +typedef long kwsysFundamentalType_Int32; +typedef unsigned long kwsysFundamentalType_UInt32; +#else +# error "No native data type can represent a 32-bit integer." +#endif + +/* Select a 64-bit integer type. */ +#if itksys_SIZEOF_LONG == 8 +typedef signed long kwsysFundamentalType_Int64; +typedef unsigned long kwsysFundamentalType_UInt64; +/* Whether UInt64 can be converted to double. */ +# define itksys_CAN_CONVERT_UI64_TO_DOUBLE 1 +#elif itksys_USE_LONG_LONG && itksys_SIZEOF_LONG_LONG == 8 +typedef signed long long kwsysFundamentalType_Int64; +typedef unsigned long long kwsysFundamentalType_UInt64; +/* Whether UInt64 can be converted to double. */ +# define itksys_CAN_CONVERT_UI64_TO_DOUBLE 1 +#elif itksys_USE___INT64 && itksys_SIZEOF___INT64 == 8 +typedef signed __int64 kwsysFundamentalType_Int64; +typedef unsigned __int64 kwsysFundamentalType_UInt64; +/* Whether UInt64 can be converted to double. */ +# define itksys_CAN_CONVERT_UI64_TO_DOUBLE 1 +#else +# error "No native data type can represent a 64-bit integer." +#endif + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +/* If we are building a kwsys .c or .cxx file, let it use these macros. + Otherwise, undefine them to keep the namespace clean. */ +#if !defined(KWSYS_NAMESPACE) +# undef kwsys_ns +# undef kwsysEXPORT +# undef kwsysFundamentalType +# undef kwsysFundamentalType_Int8 +# undef kwsysFundamentalType_UInt8 +# undef kwsysFundamentalType_Int16 +# undef kwsysFundamentalType_UInt16 +# undef kwsysFundamentalType_Int32 +# undef kwsysFundamentalType_UInt32 +# undef kwsysFundamentalType_Int64 +# undef kwsysFundamentalType_UInt64 +#endif + +/* If building a C or C++ file in kwsys itself, give the source file + access to the configured macros without a configured namespace. */ +#if defined(KWSYS_NAMESPACE) +# define KWSYS_SIZEOF_CHAR itksys_SIZEOF_CHAR +# define KWSYS_SIZEOF_SHORT itksys_SIZEOF_SHORT +# define KWSYS_SIZEOF_INT itksys_SIZEOF_INT +# define KWSYS_SIZEOF_LONG itksys_SIZEOF_LONG +# define KWSYS_SIZEOF_LONG_LONG itksys_SIZEOF_LONG_LONG +# define KWSYS_SIZEOF___INT64 itksys_SIZEOF___INT64 +# define KWSYS_USE_LONG_LONG itksys_USE_LONG_LONG +# define KWSYS_USE___INT64 itksys_USE___INT64 +# define KWSYS_CHAR_IS_SIGNED itksys_CHAR_IS_SIGNED +# define KWSYS_CAN_CONVERT_UI64_TO_DOUBLE itksys_CAN_CONVERT_UI64_TO_DOUBLE +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/RegularExpression.hxx b/Utilities/ITK/Utilities/itksys/RegularExpression.hxx new file mode 100755 index 0000000000000000000000000000000000000000..f5a84b8497bd5a9be7ec113fe681a6769c68eca8 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/RegularExpression.hxx @@ -0,0 +1,392 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: RegularExpression.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +// Original Copyright notice: +// Copyright (C) 1991 Texas Instruments Incorporated. +// +// Permission is granted to any individual or institution to use, copy, modify, +// and distribute this software, provided that this complete copyright and +// permission notice is maintained, intact, in all copies and supporting +// documentation. +// +// Texas Instruments Incorporated provides this software "as is" without +// express or implied warranty. +// +// Created: MNF 06/13/89 Initial Design and Implementation +// Updated: LGO 08/09/89 Inherit from Generic +// Updated: MBN 09/07/89 Added conditional exception handling +// Updated: MBN 12/15/89 Sprinkled "const" qualifiers all over the place! +// Updated: DLS 03/22/91 New lite version +// + +#ifndef itksys_RegularExpression_hxx +#define itksys_RegularExpression_hxx + +#include <itksys/Configure.h> +#include <itksys/Configure.hxx> + +#include <itksys/stl/string> + +/* Define this macro temporarily to keep the code readable. */ +#if !defined (KWSYS_NAMESPACE) && !itksys_NAME_IS_KWSYS +# define kwsys_stl itksys_stl +#endif + +namespace itksys +{ + +/** \class RegularExpression + * \brief Implements pattern matching with regular expressions. + * + * This is the header file for the regular expression class. An object of + * this class contains a regular expression, in a special "compiled" format. + * This compiled format consists of several slots all kept as the objects + * private data. The RegularExpression class provides a convenient way to + * represent regular expressions. It makes it easy to search for the same + * regular expression in many different strings without having to compile a + * string to regular expression format more than necessary. + * + * This class implements pattern matching via regular expressions. + * A regular expression allows a programmer to specify complex + * patterns that can be searched for and matched against the + * character string of a string object. In its simplest form, a + * regular expression is a sequence of characters used to + * search for exact character matches. However, many times the + * exact sequence to be found is not known, or only a match at + * the beginning or end of a string is desired. The RegularExpression regu- + * lar expression class implements regular expression pattern + * matching as is found and implemented in many UNIX commands + * and utilities. + * + * Example: The perl code + * + * $filename =~ m"([a-z]+)\.cc"; + * print $1; + * + * Is written as follows in C++ + * + * RegularExpression re("([a-z]+)\\.cc"); + * re.find(filename); + * cerr << re.match(1); + * + * + * The regular expression class provides a convenient mechanism + * for specifying and manipulating regular expressions. The + * regular expression object allows specification of such pat- + * terns by using the following regular expression metacharac- + * ters: + * + * ^ Matches at beginning of a line + * + * $ Matches at end of a line + * + * . Matches any single character + * + * [ ] Matches any character(s) inside the brackets + * + * [^ ] Matches any character(s) not inside the brackets + * + * - Matches any character in range on either side of a dash + * + * * Matches preceding pattern zero or more times + * + * + Matches preceding pattern one or more times + * + * ? Matches preceding pattern zero or once only + * + * () Saves a matched expression and uses it in a later match + * + * Note that more than one of these metacharacters can be used + * in a single regular expression in order to create complex + * search patterns. For example, the pattern [^ab1-9] says to + * match any character sequence that does not begin with the + * characters "ab" followed by numbers in the series one + * through nine. + * + * There are three constructors for RegularExpression. One just creates an + * empty RegularExpression object. Another creates a RegularExpression + * object and initializes it with a regular expression that is given in the + * form of a char*. The third takes a reference to a RegularExpression + * object as an argument and creates an object initialized with the + * information from the given RegularExpression object. + * + * The find member function finds the first occurence of the regualr + * expression of that object in the string given to find as an argument. Find + * returns a boolean, and if true, mutates the private data appropriately. + * Find sets pointers to the beginning and end of the thing last found, they + * are pointers into the actual string that was searched. The start and end + * member functions return indicies into the searched string that correspond + * to the beginning and end pointers respectively. The compile member + * function takes a char* and puts the compiled version of the char* argument + * into the object's private data fields. The == and != operators only check + * the to see if the compiled regular expression is the same, and the + * deep_equal functions also checks to see if the start and end pointers are + * the same. The is_valid function returns false if program is set to NULL, + * (i.e. there is no valid compiled exression). The set_invalid function sets + * the program to NULL (Warning: this deletes the compiled expression). The + * following examples may help clarify regular expression usage: + * + * * The regular expression "^hello" matches a "hello" only at the + * beginning of a line. It would match "hello there" but not "hi, + * hello there". + * + * * The regular expression "long$" matches a "long" only at the end + * of a line. It would match "so long\0", but not "long ago". + * + * * The regular expression "t..t..g" will match anything that has a + * "t" then any two characters, another "t", any two characters and + * then a "g". It will match "testing", or "test again" but would + * not match "toasting" + * + * * The regular expression "[1-9ab]" matches any number one through + * nine, and the characters "a" and "b". It would match "hello 1" + * or "begin", but would not match "no-match". + * + * * The regular expression "[^1-9ab]" matches any character that is + * not a number one through nine, or an "a" or "b". It would NOT + * match "hello 1" or "begin", but would match "no-match". + * + * * The regular expression "br* " matches something that begins with + * a "b", is followed by zero or more "r"s, and ends in a space. It + * would match "brrrrr ", and "b ", but would not match "brrh ". + * + * * The regular expression "br+ " matches something that begins with + * a "b", is followed by one or more "r"s, and ends in a space. It + * would match "brrrrr ", and "br ", but would not match "b " or + * "brrh ". + * + * * The regular expression "br? " matches something that begins with + * a "b", is followed by zero or one "r"s, and ends in a space. It + * would match "br ", and "b ", but would not match "brrrr " or + * "brrh ". + * + * * The regular expression "(..p)b" matches something ending with pb + * and beginning with whatever the two characters before the first p + * encounterd in the line were. It would find "repb" in "rep drepa + * qrepb". The regular expression "(..p)a" would find "repa qrepb" + * in "rep drepa qrepb" + * + * * The regular expression "d(..p)" matches something ending with p, + * beginning with d, and having two characters in between that are + * the same as the two characters before the first p encounterd in + * the line. It would match "drepa qrepb" in "rep drepa qrepb". + * + */ +class itksys_EXPORT RegularExpression +{ +public: + /** + * Instantiate RegularExpression with program=NULL. + */ + inline RegularExpression (); + + /** + * Instantiate RegularExpression with compiled char*. + */ + inline RegularExpression (char const*); + + /** + * Instantiate RegularExpression as a copy of another regular expression. + */ + RegularExpression (RegularExpression const&); + + /** + * Destructor. + */ + inline ~RegularExpression(); + + /** + * Compile a regular expression into internal code + * for later pattern matching. + */ + bool compile (char const*); + + /** + * Matches the regular expression to the given string. + * Returns true if found, and sets start and end indexes accordingly. + */ + bool find (char const*); + + /** + * Matches the regular expression to the given std string. + * Returns true if found, and sets start and end indexes accordingly. + */ + bool find (kwsys_stl::string const&); + + /** + * Index to start of first find. + */ + inline kwsys_stl::string::size_type start() const; + + /** + * Index to end of first find. + */ + inline kwsys_stl::string::size_type end() const; + + /** + * Returns true if two regular expressions have the same + * compiled program for pattern matching. + */ + bool operator== (RegularExpression const&) const; + + /** + * Returns true if two regular expressions have different + * compiled program for pattern matching. + */ + inline bool operator!= (RegularExpression const&) const; + + /** + * Returns true if have the same compiled regular expressions + * and the same start and end pointers. + */ + bool deep_equal (RegularExpression const&) const; + + /** + * True if the compiled regexp is valid. + */ + inline bool is_valid() const; + + /** + * Marks the regular expression as invalid. + */ + inline void set_invalid(); + + /** + * Destructor. + */ + // awf added + kwsys_stl::string::size_type start(int n) const; + kwsys_stl::string::size_type end(int n) const; + kwsys_stl::string match(int n) const; + + enum { NSUBEXP = 10 }; +private: + const char* startp[NSUBEXP]; + const char* endp[NSUBEXP]; + char regstart; // Internal use only + char reganch; // Internal use only + const char* regmust; // Internal use only + unsigned long regmlen; // Internal use only + char* program; + int progsize; + const char* searchstring; +}; + +/** + * Create an empty regular expression. + */ +inline RegularExpression::RegularExpression () +{ + this->program = 0; +} + +/** + * Creates a regular expression from string s, and + * compiles s. + */ +inline RegularExpression::RegularExpression (const char* s) +{ + this->program = 0; + if ( s ) + { + this->compile(s); + } +} + +/** + * Destroys and frees space allocated for the regular expression. + */ +inline RegularExpression::~RegularExpression () +{ +//#ifndef WIN32 + delete [] this->program; +//#endif +} + +/** + * Set the start position for the regular expression. + */ +inline kwsys_stl::string::size_type RegularExpression::start () const +{ + return(this->startp[0] - searchstring); +} + + +/** + * Returns the start/end index of the last item found. + */ +inline kwsys_stl::string::size_type RegularExpression::end () const +{ + return(this->endp[0] - searchstring); +} + +/** + * Returns true if two regular expressions have different + * compiled program for pattern matching. + */ +inline bool RegularExpression::operator!= (const RegularExpression& r) const +{ + return(!(*this == r)); +} + +/** + * Returns true if a valid regular expression is compiled + * and ready for pattern matching. + */ +inline bool RegularExpression::is_valid () const +{ + return (this->program != 0); +} + + +inline void RegularExpression::set_invalid () +{ +//#ifndef WIN32 + delete [] this->program; +//#endif + this->program = 0; +} + +/** + * Return start index of nth submatch. start(0) is the start of the full match. + */ +inline kwsys_stl::string::size_type RegularExpression::start(int n) const +{ + return this->startp[n] - searchstring; +} + + +/** + * Return end index of nth submatch. end(0) is the end of the full match. + */ +inline kwsys_stl::string::size_type RegularExpression::end(int n) const +{ + return this->endp[n] - searchstring; +} + +/** + * Return nth submatch as a string. + */ +inline kwsys_stl::string RegularExpression::match(int n) const +{ + return kwsys_stl::string(this->startp[n], this->endp[n] - this->startp[n]); +} + +} // namespace itksys + +/* Undefine temporary macro. */ +#if !defined (KWSYS_NAMESPACE) && !itksys_NAME_IS_KWSYS +# undef kwsys_stl +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/SharedForward.h b/Utilities/ITK/Utilities/itksys/SharedForward.h new file mode 100755 index 0000000000000000000000000000000000000000..d392a7b3a42b17837a0c2a669d0eec423df1a7eb --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/SharedForward.h @@ -0,0 +1,672 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: SharedForward.h.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_SharedForward_h +#define itksys_SharedForward_h + +/* + This header is used to create a forwarding executable sets up the + shared library search path and replaces itself with a real + executable. This is useful when creating installations on UNIX with + shared libraries that will run from any install directory. Typical + usage: + + #define itksys_SHARED_FORWARD_DIR_BUILD "/path/to/foo-build/bin" + #define itksys_SHARED_FORWARD_PATH_BUILD "." + #define itksys_SHARED_FORWARD_PATH_INSTALL "../lib/foo-1.2" + #define itksys_SHARED_FORWARD_EXE_BUILD "foo-real" + #define itksys_SHARED_FORWARD_EXE_INSTALL "../lib/foo-1.2/foo-real" + #define itksys_SHARED_FORWARD_OPTION_PRINT "--print" + #define itksys_SHARED_FORWARD_OPTION_LDD "--ldd" + #if defined(CMAKE_INTDIR) + # define itksys_SHARED_FORWARD_CONFIG_NAME CMAKE_INTDIR + #endif + #include <itksys/SharedForward.h> + int main(int argc, char** argv) + { + return itksys_shared_forward_to_real(argc, argv); + } + */ + +/*--------------------------------------------------------------------------*/ +/* Configuration for this executable. Specify search and executable + paths relative to the forwarding executable location or as full + paths. Include no trailing slash. */ + +/* Full path to the directory in which this executable is built. Do + not include a trailing slash. */ +#if !defined(itksys_SHARED_FORWARD_DIR_BUILD) +# error "Must define itksys_SHARED_FORWARD_DIR_BUILD" +#endif +#if !defined(KWSYS_SHARED_FORWARD_DIR_BUILD) +# define KWSYS_SHARED_FORWARD_DIR_BUILD itksys_SHARED_FORWARD_DIR_BUILD +#endif + +/* Library search path for build tree. */ +#if !defined(itksys_SHARED_FORWARD_PATH_BUILD) +# error "Must define itksys_SHARED_FORWARD_PATH_BUILD" +#endif +#if !defined(KWSYS_SHARED_FORWARD_PATH_BUILD) +# define KWSYS_SHARED_FORWARD_PATH_BUILD itksys_SHARED_FORWARD_PATH_BUILD +#endif + +/* Library search path for install tree. */ +#if !defined(itksys_SHARED_FORWARD_PATH_INSTALL) +# error "Must define itksys_SHARED_FORWARD_PATH_INSTALL" +#endif +#if !defined(KWSYS_SHARED_FORWARD_PATH_INSTALL) +# define KWSYS_SHARED_FORWARD_PATH_INSTALL itksys_SHARED_FORWARD_PATH_INSTALL +#endif + +/* The real executable to which to forward in the build tree. */ +#if !defined(itksys_SHARED_FORWARD_EXE_BUILD) +# error "Must define itksys_SHARED_FORWARD_EXE_BUILD" +#endif +#if !defined(KWSYS_SHARED_FORWARD_EXE_BUILD) +# define KWSYS_SHARED_FORWARD_EXE_BUILD itksys_SHARED_FORWARD_EXE_BUILD +#endif + +/* The real executable to which to forward in the install tree. */ +#if !defined(itksys_SHARED_FORWARD_EXE_INSTALL) +# error "Must define itksys_SHARED_FORWARD_EXE_INSTALL" +#endif +#if !defined(KWSYS_SHARED_FORWARD_EXE_INSTALL) +# define KWSYS_SHARED_FORWARD_EXE_INSTALL itksys_SHARED_FORWARD_EXE_INSTALL +#endif + +/* The configuration name with which this executable was built (Debug/Release). */ +#if defined(itksys_SHARED_FORWARD_CONFIG_NAME) +# define KWSYS_SHARED_FORWARD_CONFIG_NAME itksys_SHARED_FORWARD_CONFIG_NAME +#else +# undef KWSYS_SHARED_FORWARD_CONFIG_NAME +#endif + +/* Create command line option to print environment setting and exit. */ +#if defined(itksys_SHARED_FORWARD_OPTION_PRINT) +# if !defined(KWSYS_SHARED_FORWARD_OPTION_PRINT) +# define KWSYS_SHARED_FORWARD_OPTION_PRINT itksys_SHARED_FORWARD_OPTION_PRINT +# endif +#else +# undef KWSYS_SHARED_FORWARD_OPTION_PRINT +#endif + +/* Create command line option to run ldd or equivalent. */ +#if defined(itksys_SHARED_FORWARD_OPTION_LDD) +# if !defined(KWSYS_SHARED_FORWARD_OPTION_LDD) +# define KWSYS_SHARED_FORWARD_OPTION_LDD itksys_SHARED_FORWARD_OPTION_LDD +# endif +#else +# undef KWSYS_SHARED_FORWARD_OPTION_LDD +#endif + +/*--------------------------------------------------------------------------*/ +/* Include needed system headers. */ + +#include <limits.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <stdio.h> + +#if defined(_WIN32) && !defined(__CYGWIN__) +# include <io.h> +# include <windows.h> +# include <process.h> +#else +# include <unistd.h> +#endif + +/*--------------------------------------------------------------------------*/ +/* Configuration for this platform. */ + +/* The path separator for this platform. */ +#if defined(_WIN32) && !defined(__CYGWIN__) +# define KWSYS_SHARED_FORWARD_PATH_SEP ';' +# define KWSYS_SHARED_FORWARD_PATH_SLASH '\\' +#else +# define KWSYS_SHARED_FORWARD_PATH_SEP ':' +# define KWSYS_SHARED_FORWARD_PATH_SLASH '/' +#endif +static const char kwsys_shared_forward_path_sep[2] = {KWSYS_SHARED_FORWARD_PATH_SEP, 0}; +static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PATH_SLASH, 0}; + +/* The maximum length of a file name. */ +#if defined(PATH_MAX) +# define KWSYS_SHARED_FORWARD_MAXPATH PATH_MAX +#elif defined(MAXPATHLEN) +# define KWSYS_SHARED_FORWARD_MAXPATH MAXPATHLEN +#else +# define KWSYS_SHARED_FORWARD_MAXPATH 16384 +#endif + +/* Select the environment variable holding the shared library runtime + search path for this platform and build configuration. Also select + ldd command equivalent. */ + +/* Linux */ +#if defined(__linux) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +#endif + +/* FreeBSD */ +#if defined(__FreeBSD__) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +#endif + +/* OSX */ +#if defined(__APPLE__) +# define KWSYS_SHARED_FORWARD_LDD "otool", "-L" +# define KWSYS_SHARED_FORWARD_LDD_N 2 +# define KWSYS_SHARED_FORWARD_LDPATH "DYLD_LIBRARY_PATH" +#endif + +/* AIX */ +#if defined(_AIX) +# define KWSYS_SHARED_FORWARD_LDD "dump", "-H" +# define KWSYS_SHARED_FORWARD_LDD_N 2 +# define KWSYS_SHARED_FORWARD_LDPATH "LIBPATH" +#endif + +/* SUN */ +#if defined(__sparc) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# include <sys/isa_defs.h> +# if defined(_ILP32) +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# elif defined(_LP64) +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH_64" +# endif +#endif + +/* HP-UX */ +#if defined(__hpux) +# define KWSYS_SHARED_FORWARD_LDD "chatr" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# if defined(__LP64__) +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# else +# define KWSYS_SHARED_FORWARD_LDPATH "SHLIB_PATH" +# endif +#endif + +/* SGI MIPS */ +#if defined(__sgi) && defined(_MIPS_SIM) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# if _MIPS_SIM == _ABIO32 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# elif _MIPS_SIM == _ABIN32 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARYN32_PATH" +# elif _MIPS_SIM == _ABI64 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY64_PATH" +# endif +#endif + +/* Windows */ +#if defined(_WIN32) +# if defined(__CYGWIN__) +# define KWSYS_SHARED_FORWARD_LDD "cygcheck" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# endif +# define KWSYS_SHARED_FORWARD_LDPATH "PATH" +#endif + +/* Guess on this unknown system. */ +#if !defined(KWSYS_SHARED_FORWARD_LDPATH) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +#endif + +/*--------------------------------------------------------------------------*/ +/* Function to convert a logical or relative path to a physical full path. */ +static int kwsys_shared_forward_realpath(const char* in_path, char* out_path) +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + /* Implementation for Windows. */ + DWORD n = GetFullPathName(in_path, KWSYS_SHARED_FORWARD_MAXPATH, + out_path, 0); + return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH; +#else + /* Implementation for UNIX. */ + return realpath(in_path, out_path) != 0; +#endif +} + +/*--------------------------------------------------------------------------*/ +/* Function to report a system error message. */ +static void kwsys_shared_forward_strerror(char* message) +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + /* Implementation for Windows. */ + DWORD original = GetLastError(); + DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, 0, original, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + message, KWSYS_SHARED_FORWARD_MAXPATH, 0); + if(length < 1 || length > KWSYS_SHARED_FORWARD_MAXPATH) + { + /* FormatMessage failed. Use a default message. */ + _snprintf(message, KWSYS_SHARED_FORWARD_MAXPATH, + "Error 0x%X (FormatMessage failed with error 0x%X)", + original, GetLastError()); + } +#else + /* Implementation for UNIX. */ + strcpy(message, strerror(errno)); +#endif +} + +/*--------------------------------------------------------------------------*/ +/* Functions to execute a child process. */ +static void kwsys_shared_forward_execv(const char* cmd, char* const argv[]) +{ +#if defined(_MSC_VER) + _execv(cmd, argv); +#else + execv(cmd, argv); +#endif +} +static void kwsys_shared_forward_execvp(const char* cmd, char* const argv[]) +{ +#if defined(_MSC_VER) + _execvp(cmd, argv); +#else + execvp(cmd, argv); +#endif +} + +/*--------------------------------------------------------------------------*/ +/* Function to get the directory containing the given file or directory. */ +static void kwsys_shared_forward_dirname(const char* begin, char* result) +{ + /* Find the location of the last slash. */ + int last_slash_index = -1; + const char* end = begin + strlen(begin); + for(;begin <= end && last_slash_index < 0; --end) + { + if(*end == '/' || *end == '\\') + { + last_slash_index = end-begin; + } + } + + /* Handle each case of the index of the last slash. */ + if(last_slash_index < 0) + { + /* No slashes. */ + strcpy(result, "."); + } + else if(last_slash_index == 0) + { + /* Only one leading slash. */ + strcpy(result, kwsys_shared_forward_path_slash); + } +#if defined(_WIN32) + else if(last_slash_index == 2 && begin[1] == ':') + { + /* Only one leading drive letter and slash. */ + strncpy(result, begin, last_slash_index); + result[last_slash_index] = KWSYS_SHARED_FORWARD_PATH_SLASH; + result[last_slash_index+1] = 0; + } +#endif + else + { + /* A non-leading slash. */ + strncpy(result, begin, last_slash_index); + result[last_slash_index] = 0; + } +} + +/*--------------------------------------------------------------------------*/ +/* Function to check if a file exists and is executable. */ +static int kwsys_shared_forward_is_executable(const char* f) +{ +#if defined(_MSC_VER) +# define KWSYS_SHARED_FORWARD_ACCESS _access +#else +# define KWSYS_SHARED_FORWARD_ACCESS access +#endif +#if defined(X_OK) +# define KWSYS_SHARED_FORWARD_ACCESS_OK X_OK +#else +# define KWSYS_SHARED_FORWARD_ACCESS_OK 04 +#endif + if(KWSYS_SHARED_FORWARD_ACCESS(f, KWSYS_SHARED_FORWARD_ACCESS_OK) == 0) + { + return 1; + } + else + { + return 0; + } +} + +/*--------------------------------------------------------------------------*/ +/* Function to locate the executable currently running. */ +static int kwsys_shared_forward_self_path(const char* argv0, char* result) +{ + /* Check whether argv0 has a slash. */ + int has_slash = 0; + const char* p = argv0; + for(;*p && !has_slash; ++p) + { + if(*p == '/' || *p == '\\') + { + has_slash = 1; + } + } + + if(has_slash) + { + /* There is a slash. Use the dirname of the given location. */ + kwsys_shared_forward_dirname(argv0, result); + return 1; + } + else + { + /* There is no slash. Search the PATH for the executable. */ + const char* path = getenv("PATH"); + const char* begin = path; + const char* end = begin + (begin?strlen(begin):0); + const char* first = begin; + while(first != end) + { + /* Store the end of this path entry. */ + const char* last; + + /* Skip all path separators. */ + for(;*first && *first == KWSYS_SHARED_FORWARD_PATH_SEP; ++first); + + /* Find the next separator. */ + for(last = first;*last && *last != KWSYS_SHARED_FORWARD_PATH_SEP; ++last); + + /* If we got a non-empty directory, look for the executable there. */ + if(first < last) + { + /* Determine the length without trailing slash. */ + int length = last-first; + if(*(last-1) == '/' || *(last-1) == '\\') + { + --length; + } + + /* Construct the name of the executable in this location. */ + strncpy(result, first, length); + result[length] = KWSYS_SHARED_FORWARD_PATH_SLASH; + strcpy(result+(length)+1, argv0); + + /* Check if it exists and is executable. */ + if(kwsys_shared_forward_is_executable(result)) + { + /* Found it. */ + result[length] = 0; + return 1; + } + } + + /* Move to the next directory in the path. */ + first = last; + } + } + + /* We could not find the executable. */ + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Function to convert a specified path to a full path. If it is not + already full, it is taken relative to the self path. */ +static int kwsys_shared_forward_fullpath(const char* self_path, + const char* in_path, + char* result, + const char* desc) +{ + /* Check the specified path type. */ + if(in_path[0] == '/') + { + /* Already a full path. */ + strcpy(result, in_path); + } +#if defined(_WIN32) + else if(in_path[0] && in_path[1] == ':') + { + /* Already a full path. */ + strcpy(result, in_path); + } +#endif + else + { + /* Relative to self path. */ + char temp_path[KWSYS_SHARED_FORWARD_MAXPATH]; + strcpy(temp_path, self_path); + strcat(temp_path, kwsys_shared_forward_path_slash); + strcat(temp_path, in_path); + if(!kwsys_shared_forward_realpath(temp_path, result)) + { + if(desc) + { + char msgbuf[KWSYS_SHARED_FORWARD_MAXPATH]; + kwsys_shared_forward_strerror(msgbuf); + fprintf(stderr, "Error converting %s \"%s\" to real path: %s\n", + desc, temp_path, msgbuf); + } + return 0; + } + } + return 1; +} + +/*--------------------------------------------------------------------------*/ +/* Function to compute the library search path and executable name + based on the self path. */ +static int kwsys_shared_forward_get_settings(const char* self_path, + char* ldpath, char* exe) +{ + /* Possible search paths. */ + static const char* search_path_build[] = {KWSYS_SHARED_FORWARD_PATH_BUILD, 0}; + static const char* search_path_install[] = {KWSYS_SHARED_FORWARD_PATH_INSTALL, 0}; + + /* Chosen paths. */ + const char** search_path; + const char* exe_path; + + /* Get the real name of the build and self paths. */ +#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) + char build_path[] = KWSYS_SHARED_FORWARD_DIR_BUILD "/" KWSYS_SHARED_FORWARD_CONFIG_NAME; + char self_path_logical[KWSYS_SHARED_FORWARD_MAXPATH]; +#else + char build_path[] = KWSYS_SHARED_FORWARD_DIR_BUILD; + const char* self_path_logical = self_path; +#endif + char build_path_real[KWSYS_SHARED_FORWARD_MAXPATH]; + char self_path_real[KWSYS_SHARED_FORWARD_MAXPATH]; + if(!kwsys_shared_forward_realpath(self_path, self_path_real)) + { + char msgbuf[KWSYS_SHARED_FORWARD_MAXPATH]; + kwsys_shared_forward_strerror(msgbuf); + fprintf(stderr, "Error converting self path \"%s\" to real path: %s\n", + self_path, msgbuf); + return 0; + } + + /* Check whether we are running in the build tree or an install tree. */ + if(kwsys_shared_forward_realpath(build_path, build_path_real) && + strcmp(self_path_real, build_path_real) == 0) + { + /* Running in build tree. Use the build path and exe. */ + search_path = search_path_build; +#if defined(_WIN32) + exe_path = KWSYS_SHARED_FORWARD_EXE_BUILD ".exe"; +#else + exe_path = KWSYS_SHARED_FORWARD_EXE_BUILD; +#endif + +#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) + /* Remove the configuration directory from self_path. */ + kwsys_shared_forward_dirname(self_path, self_path_logical); +#endif + } + else + { + /* Running in install tree. Use the install path and exe. */ + search_path = search_path_install; +#if defined(_WIN32) + exe_path = KWSYS_SHARED_FORWARD_EXE_INSTALL ".exe"; +#else + exe_path = KWSYS_SHARED_FORWARD_EXE_INSTALL; +#endif + +#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) + /* Use the original self path directory. */ + strcpy(self_path_logical, self_path); +#endif + } + + /* Construct the runtime search path. */ + { + const char** dir; + for(dir = search_path; *dir; ++dir) + { + /* Add seperator between path components. */ + if(dir != search_path) + { + strcat(ldpath, kwsys_shared_forward_path_sep); + } + + /* Add this path component. */ + if(!kwsys_shared_forward_fullpath(self_path_logical, *dir, + ldpath+strlen(ldpath), + "runtime path entry")) + { + return 0; + } + } + } + + /* Construct the executable location. */ + if(!kwsys_shared_forward_fullpath(self_path_logical, exe_path, exe, + "executable file")) + { + return 0; + } + return 1; +} + +/*--------------------------------------------------------------------------*/ +/* Function to print why execution of a command line failed. */ +static void kwsys_shared_forward_print_failure(char** argv) +{ + char msg[KWSYS_SHARED_FORWARD_MAXPATH]; + char** arg = argv; + kwsys_shared_forward_strerror(msg); + fprintf(stderr, "Error running"); + for(; *arg; ++arg) + { + fprintf(stderr, " \"%s\"", *arg); + } + fprintf(stderr, ": %s\n", msg); +} + +/* Static storage space to store the updated environment variable. */ +static char kwsys_shared_forward_ldpath[KWSYS_SHARED_FORWARD_MAXPATH*16] = KWSYS_SHARED_FORWARD_LDPATH "="; + +/*--------------------------------------------------------------------------*/ +/* Main driver function to be called from main. */ +static int itksys_shared_forward_to_real(int argc, char** argv) +{ + /* Get the directory containing this executable. */ + char self_path[KWSYS_SHARED_FORWARD_MAXPATH]; + if(kwsys_shared_forward_self_path(argv[0], self_path)) + { + /* Found this executable. Use it to get the library directory. */ + char exe[KWSYS_SHARED_FORWARD_MAXPATH]; + if(kwsys_shared_forward_get_settings(self_path, + kwsys_shared_forward_ldpath, exe)) + { + /* Append the old runtime search path. */ + const char* old_ldpath = getenv(KWSYS_SHARED_FORWARD_LDPATH); + if(old_ldpath) + { + strcat(kwsys_shared_forward_ldpath, kwsys_shared_forward_path_sep); + strcat(kwsys_shared_forward_ldpath, old_ldpath); + } + + /* Store the environment variable. */ + putenv(kwsys_shared_forward_ldpath); + +#if defined(KWSYS_SHARED_FORWARD_OPTION_PRINT) + /* Look for the print command line option. */ + if(argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_PRINT) == 0) + { + fprintf(stdout, "%s\n", kwsys_shared_forward_ldpath); + fprintf(stdout, "%s\n", exe); + return 0; + } +#endif + +#if defined(KWSYS_SHARED_FORWARD_OPTION_LDD) + /* Look for the ldd command line option. */ + if(argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_LDD) == 0) + { +# if defined(KWSYS_SHARED_FORWARD_LDD) + /* Use the named ldd-like executable and arguments. */ + char* ldd_argv[] = {KWSYS_SHARED_FORWARD_LDD, 0, 0}; + ldd_argv[KWSYS_SHARED_FORWARD_LDD_N] = exe; + kwsys_shared_forward_execvp(ldd_argv[0], ldd_argv); + + /* Report why execution failed. */ + kwsys_shared_forward_print_failure(ldd_argv); + return 1; +# else + /* We have no ldd-like executable available on this platform. */ + fprintf(stderr, "No ldd-like tool is known to this executable.\n"); + return 1; +# endif + } +#endif + + /* Replace this process with the real executable. */ + argv[0] = exe; + kwsys_shared_forward_execv(argv[0], argv); + + /* Report why execution failed. */ + kwsys_shared_forward_print_failure(argv); + } + else + { + /* Could not convert self path to the library directory. */ + } + } + else + { + /* Could not find this executable. */ + fprintf(stderr, "Error locating executable \"%s\".\n", argv[0]); + } + + /* Avoid unused argument warning. */ + (void)argc; + + /* Exit with failure. */ + return 1; +} + +#else +# error "itksys/SharedForward.h should be included only once." +#endif diff --git a/Utilities/ITK/Utilities/itksys/String.hxx b/Utilities/ITK/Utilities/itksys/String.hxx new file mode 100755 index 0000000000000000000000000000000000000000..a4a13a88d3fa9cd68ca1b7625c5b5d8fdd250aaf --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/String.hxx @@ -0,0 +1,59 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: String.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_String_hxx +#define itksys_String_hxx + +#include <itksys/stl/string> + +namespace itksys +{ + +/** \class String + * \brief Short-name version of the STL basic_string class template. + * + * The standard library "std::string" type is actually a typedef for + * "std::basic_string<..long argument list..>". This string class is + * simply a subclass of this type with the same interface so that the + * name is shorter in debugging symbols and error messages. + */ +class itksys_EXPORT String: public itksys_stl::string +{ + /** The original string type. */ + typedef itksys_stl::string stl_string; + +public: + + /** String member types. */ + typedef stl_string::value_type value_type; + typedef stl_string::pointer pointer; + typedef stl_string::reference reference; + typedef stl_string::const_reference const_reference; + typedef stl_string::size_type size_type; + typedef stl_string::difference_type difference_type; + typedef stl_string::iterator iterator; + typedef stl_string::const_iterator const_iterator; + typedef stl_string::reverse_iterator reverse_iterator; + typedef stl_string::const_reverse_iterator const_reverse_iterator; + + /** String constructors. */ + String(): stl_string() {} + String(const value_type* s): stl_string(s) {} + String(const value_type* s, size_type n): stl_string(s, n) {} + String(const stl_string& s, size_type pos=0, size_type n=npos): + stl_string(s, pos, n) {} +}; // End Class: String + +} // namespace itksys + +#endif diff --git a/Utilities/ITK/Utilities/itksys/SystemTools.hxx b/Utilities/ITK/Utilities/itksys/SystemTools.hxx new file mode 100755 index 0000000000000000000000000000000000000000..14fad38453cbb56bd5895c65f6a8a9e344d2b99d --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/SystemTools.hxx @@ -0,0 +1,781 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: SystemTools.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_SystemTools_hxx +#define itksys_SystemTools_hxx + +#include <itksys/ios/iosfwd> +#include <itksys/stl/string> +#include <itksys/stl/vector> +#include <itksys/stl/map> + +#include <itksys/Configure.h> +#include <itksys/String.hxx> + +#include <sys/types.h> + +// Required for va_list +#include <stdarg.h> +#if itksys_STL_HAVE_STD && !defined(va_list) +// Some compilers move va_list into the std:: namespace and there is no way to +// tell that this has been done. Playing with things being included before or +// after stdarg.h does not solve things because we do not have control over +// what the user does. This hack solves this problem by moving va_list to our +// own namespace that is local for kwsys. +namespace std {} // Required for platforms that do not have std:: +namespace itksys_VA_LIST +{ + using namespace std; + typedef va_list hack_va_list; +} +namespace itksys +{ + typedef itksys_VA_LIST::hack_va_list va_list; +} +#endif // va_list + +#if defined( _MSC_VER ) +typedef unsigned short mode_t; +#endif + +/* Define these macros temporarily to keep the code readable. */ +#if !defined (KWSYS_NAMESPACE) && !itksys_NAME_IS_KWSYS +# define kwsys_stl itksys_stl +# define kwsys_ios itksys_ios +#endif + +namespace itksys +{ + +class SystemToolsTranslationMap; +/** \class SystemToolsManager + * \brief Use to make sure SystemTools is initialized before it is used + * and is the last static object destroyed + */ +class itksys_EXPORT SystemToolsManager +{ +public: + SystemToolsManager(); + ~SystemToolsManager(); +}; + +// This instance will show up in any translation unit that uses +// SystemTools. It will make sure SystemTools is initialized +// before it is used and is the last static object destroyed. +static SystemToolsManager SystemToolsManagerInstance; + +/** \class SystemTools + * \brief A collection of useful platform-independent system functions. + */ +class itksys_EXPORT SystemTools +{ +public: + + /** ----------------------------------------------------------------- + * String Manipulation Routines + * ----------------------------------------------------------------- + */ + + /** + * Replace symbols in str that are not valid in C identifiers as + * defined by the 1999 standard, ie. anything except [A-Za-z0-9_]. + * They are replaced with `_' and if the first character is a digit + * then an underscore is prepended. Note that this can produce + * identifiers that the standard reserves (_[A-Z].* and __.*). + */ + static kwsys_stl::string MakeCindentifier(const char* s); + + /** + * Replace replace all occurences of the string in the source string. + */ + static void ReplaceString(kwsys_stl::string& source, + const char* replace, + const char* with); + + /** + * Return a capitalized string (i.e the first letter is uppercased, + * all other are lowercased). + */ + static kwsys_stl::string Capitalized(const kwsys_stl::string&); + + /** + * Return a 'capitalized words' string (i.e the first letter of each word + * is uppercased all other are left untouched though). + */ + static kwsys_stl::string CapitalizedWords(const kwsys_stl::string&); + + /** + * Return a 'uncapitalized words' string (i.e the first letter of each word + * is lowercased all other are left untouched though). + */ + static kwsys_stl::string UnCapitalizedWords(const kwsys_stl::string&); + + /** + * Return a lower case string + */ + static kwsys_stl::string LowerCase(const kwsys_stl::string&); + + /** + * Return a lower case string + */ + static kwsys_stl::string UpperCase(const kwsys_stl::string&); + + /** + * Count char in string + */ + static size_t CountChar(const char* str, char c); + + /** + * Remove some characters from a string. + * Return a pointer to the new resulting string (allocated with 'new') + */ + static char* RemoveChars(const char* str, const char *toremove); + + /** + * Remove remove all but 0->9, A->F characters from a string. + * Return a pointer to the new resulting string (allocated with 'new') + */ + static char* RemoveCharsButUpperHex(const char* str); + + /** + * Replace some characters by another character in a string (in-place) + * Return a pointer to string + */ + static char* ReplaceChars(char* str, const char *toreplace,char replacement); + + /** + * Returns true if str1 starts (respectively ends) with str2 + */ + static bool StringStartsWith(const char* str1, const char* str2); + static bool StringEndsWith(const char* str1, const char* str2); + + /** + * Returns a pointer to the last occurence of str2 in str1 + */ + static const char* FindLastString(const char* str1, const char* str2); + + /** + * Make a duplicate of the string similar to the strdup C function + * but use new to create the 'new' string, so one can use + * 'delete' to remove it. Returns 0 if the input is empty. + */ + static char* DuplicateString(const char* str); + + /** + * Return the string cropped to a given length by removing chars in the + * center of the string and replacing them with an ellipsis (...) + */ + static kwsys_stl::string CropString(const kwsys_stl::string&,size_t max_len); + + /** split a path by separator into an array of strings, default is /. + If isPath is true then the string is treated like a path and if + s starts with a / then the first element of the returned array will + be /, so /foo/bar will be [/, foo, bar] + */ + static kwsys_stl::vector<String> SplitString(const char* s, char separator = '/', + bool isPath = false); + /** + * Perform a case-independent string comparison + */ + static int Strucmp(const char *s1, const char *s2); + + /** + * Convert a string in __DATE__ or __TIMESTAMP__ format into a time_t. + * Return false on error, true on success + */ + static bool ConvertDateMacroString(const char *str, time_t *tmt); + static bool ConvertTimeStampMacroString(const char *str, time_t *tmt); + + /** + * Split a string on its newlines into multiple lines + * Return false only if the last line stored had no newline + */ + static bool Split(const char* s, kwsys_stl::vector<kwsys_stl::string>& l); + static bool Split(const char* s, kwsys_stl::vector<kwsys_stl::string>& l, char separator); + + /** + * Return string with space added between capitalized words + * (i.e. EatMyShorts becomes Eat My Shorts ) + */ + static kwsys_stl::string AddSpaceBetweenCapitalizedWords( + const kwsys_stl::string&); + + /** + * Append two or more strings and produce new one. + * Programmer must 'delete []' the resulting string, which was allocated + * with 'new'. + * Return 0 if inputs are empty or there was an error + */ + static char* AppendStrings( + const char* str1, const char* str2); + static char* AppendStrings( + const char* str1, const char* str2, const char* str3); + + /** + * Estimate the length of the string that will be produced + * from printing the given format string and arguments. The + * returned length will always be at least as large as the string + * that will result from printing. + * WARNING: since va_arg is called to iterate of the argument list, + * you will not be able to use this 'ap' anymore from the beginning. + * It's up to you to call va_end though. + */ + static int EstimateFormatLength(const char *format, va_list ap); + + /** + * Escape specific characters in 'str'. + */ + static kwsys_stl::string EscapeChars( + const char *str, const char *chars_to_escape, char escape_char = '\\'); + + /** ----------------------------------------------------------------- + * Filename Manipulation Routines + * ----------------------------------------------------------------- + */ + + /** + * Replace Windows file system slashes with Unix-style slashes. + */ + static void ConvertToUnixSlashes(kwsys_stl::string& path); + + /** + * For windows this calls ConvertToWindowsOutputPath and for unix + * it calls ConvertToUnixOutputPath + */ + static kwsys_stl::string ConvertToOutputPath(const char*); + + /** + * Return true if a file exists in the current directory + */ + static bool FileExists(const char* filename); + + /** + * Return file length + */ + static unsigned long FileLength(const char *filename); + + /** + * Compare file modification times. + * Return true for successful comparison and false for error. + * When true is returned, result has -1, 0, +1 for + * f1 older, same, or newer than f2. + */ + static bool FileTimeCompare(const char* f1, const char* f2, + int* result); + + /** + * Get the file extension (including ".") needed for an executable + * on the current platform ("" for unix, ".exe" for Windows). + */ + static const char* GetExecutableExtension(); + + /** + * Given a path that exists on a windows machine, return the + * actuall case of the path as it was created. If the file + * does not exist path is returned unchanged. This does nothing + * on unix but return path. + */ + static kwsys_stl::string GetActualCaseForPath(const char* path); + + /** + * Given the path to a program executable, get the directory part of + * the path with the file stripped off. If there is no directory + * part, the empty string is returned. + */ + static kwsys_stl::string GetProgramPath(const char*); + static bool SplitProgramPath(const char* in_name, + kwsys_stl::string& dir, + kwsys_stl::string& file, + bool errorReport = true); + + /** + * Given argv[0] for a unix program find the full path to a running + * executable. argv0 can be null for windows WinMain programs + * in this case GetModuleFileName will be used to find the path + * to the running executable. If argv0 is not a full path, + * then this will try to find the full path. If the path is not + * found false is returned, if found true is returned. An error + * message of the attempted paths is stored in errorMsg. + * exeName is the name of the executable. + * buildDir is a possibly null path to the build directory. + * installPrefix is a possibly null pointer to the install directory. + */ + static bool FindProgramPath(const char* argv0, + kwsys_stl::string& pathOut, + kwsys_stl::string& errorMsg, + const char* exeName = 0, + const char* buildDir = 0, + const char* installPrefix = 0); + + /** + * Given a path to a file or directory, convert it to a full path. + * This collapses away relative paths relative to the cwd argument + * (which defaults to the current working directory). The full path + * is returned. + */ + static kwsys_stl::string CollapseFullPath(const char* in_relative); + static kwsys_stl::string CollapseFullPath(const char* in_relative, + const char* in_base); + + /** + * Split a path name into its basic components. The first component + * is one of the following roots: + * "/" = UNIX + * "c:/" = Windows full path (can be any drive letter) + * "c:" = Windows drive-letter relative path (can be any drive letter) + * "//" = Network path + * "" = Relative path + * The remaining components form the path. If there is a trailing + * slash then the last component is the empty string. The + * components can be recombined as "c[0]c[1]/c[2]/.../c[n]" to + * produce the original path. + */ + static void SplitPath(const char* p, + kwsys_stl::vector<kwsys_stl::string>& components); + + /** + * Join components of a path name into a single string. See + * SplitPath for the format of the components. + */ + static kwsys_stl::string JoinPath( + const kwsys_stl::vector<kwsys_stl::string>& components); + + /** + * Compare a path or components of a path. + */ + static bool ComparePath(const char* c1, const char* c2); + + + /** + * Return path of a full filename (no trailing slashes) + */ + static kwsys_stl::string GetFilenamePath(const kwsys_stl::string&); + + /** + * Return file name of a full filename (i.e. file name without path) + */ + static kwsys_stl::string GetFilenameName(const kwsys_stl::string&); + + /** + * Split a program from its arguments and handle spaces in the paths + */ + static void SplitProgramFromArgs( + const char* path, + kwsys_stl::string& program, kwsys_stl::string& args); + + /** + * Return longest file extension of a full filename (dot included) + */ + static kwsys_stl::string GetFilenameExtension(const kwsys_stl::string&); + + /** + * Return shortest file extension of a full filename (dot included) + */ + static kwsys_stl::string GetFilenameLastExtension( + const kwsys_stl::string& filename); + + /** + * Return file name without extension of a full filename + */ + static kwsys_stl::string GetFilenameWithoutExtension( + const kwsys_stl::string&); + + /** + * Return file name without its last (shortest) extension + */ + static kwsys_stl::string GetFilenameWithoutLastExtension( + const kwsys_stl::string&); + + /** + * Return whether the path represents a full path (not relative) + */ + static bool FileIsFullPath(const char*); + + /** + * For windows return the short path for the given path, + * Unix just a pass through + */ + static bool GetShortPath(const char* path, kwsys_stl::string& result); + + /** + * Read line from file. Make sure to get everything. Due to a buggy stream + * library on the HP and another on Mac OSX, we need this very carefully + * written version of getline. Returns true if any data were read before the + * end-of-file was reached. If the has_newline argument is specified, it will + * be true when the line read had a newline character. + */ + static bool GetLineFromStream(kwsys_ios::istream& istr, + kwsys_stl::string& line, + bool* has_newline=0); + + /** + * Get the parent directory of the directory or file + */ + static kwsys_stl::string GetParentDirectory(const char* fileOrDir); + + /** + * Check if the given file or directory is in subdirectory of dir + */ + static bool IsSubDirectory(const char* fileOrDir, const char* dir); + + /** + * Convert the path to a string that can be used in a unix makefile. + * double slashes are removed, and spaces are escaped. + */ + static kwsys_stl::string ConvertToUnixOutputPath(const char*); + + /** ----------------------------------------------------------------- + * File Manipulation Routines + * ----------------------------------------------------------------- + */ + + /** + * Make a new directory if it is not there. This function + * can make a full path even if none of the directories existed + * prior to calling this function. + */ + static bool MakeDirectory(const char* path); + + /** + * Copy the source file to the destination file only + * if the two files differ. + */ + static bool CopyFileIfDifferent(const char* source, + const char* destination); + + /** + * Compare the contents of two files. Return true if different + */ + static bool FilesDiffer(const char* source, const char* destination); + + /** + * Return true if the two files are the same file + */ + static bool SameFile(const char* file1, const char* file2); + + /** + * Copy a file + */ + static bool CopyFileAlways(const char* source, const char* destination); + + /** + * Copy content directory to another directory with all files and + * subdirectories + */ + static bool CopyADirectory(const char* source, const char* destination); + + /** + * Remove a file + */ + static bool RemoveFile(const char* source); + + /** + * Remove a directory + */ + static bool RemoveADirectory(const char* source); + + /** + * Get the maximum full file path length + */ + static size_t GetMaximumFilePathLength(); + + /** + * Find a file in the system PATH, with optional extra paths + */ + static kwsys_stl::string FindFile( + const char* name, + const kwsys_stl::vector<kwsys_stl::string>& path = + kwsys_stl::vector<kwsys_stl::string>()); + + /** + * Find an executable in the system PATH, with optional extra paths + */ + static kwsys_stl::string FindProgram( + const char* name, + const kwsys_stl::vector<kwsys_stl::string>& path = + kwsys_stl::vector<kwsys_stl::string>(), + bool no_system_path = false); + static kwsys_stl::string FindProgram( + const kwsys_stl::vector<kwsys_stl::string>& names, + const kwsys_stl::vector<kwsys_stl::string>& path = + kwsys_stl::vector<kwsys_stl::string>(), + bool no_system_path = false); + + /** + * Find a library in the system PATH, with optional extra paths + */ + static kwsys_stl::string FindLibrary( + const char* name, + const kwsys_stl::vector<kwsys_stl::string>& path); + + /** + * Return true if the file is a directory + */ + static bool FileIsDirectory(const char* name); + + /** + * Return true if the file is a symlink + */ + static bool FileIsSymlink(const char* name); + + /** + * Return true if the file has a given signature (first set of bytes) + */ + static bool FileHasSignature( + const char* filename, const char *signature, long offset = 0); + + /** + * Attempt to detect and return the type of a file. + * Up to 'length' bytes are read from the file, if more than 'percent_bin' % + * of the bytes are non-textual elements, the file is considered binary, + * otherwise textual. Textual elements are bytes in the ASCII [0x20, 0x7E] + * range, but also \n, \r, \t. + * The algorithm is simplistic, and should probably check for usual file + * extensions, 'magic' signature, unicode, etc. + */ + enum FileTypeEnum + { + FileTypeUnknown, + FileTypeBinary, + FileTypeText + }; + static SystemTools::FileTypeEnum DetectFileType( + const char* filename, + unsigned long length = 256, + double percent_bin = 0.05); + + /** + * Try to locate the file 'filename' in the directory 'dir'. + * If 'filename' is a fully qualified filename, the basename of the file is + * used to check for its existence in 'dir'. + * If 'dir' is not a directory, GetFilenamePath() is called on 'dir' to + * get its directory first (thus, you can pass a filename as 'dir', as + * a convenience). + * 'filename_found' is assigned the fully qualified name/path of the file + * if it is found (not touched otherwise). + * If 'try_filename_dirs' is true, try to find the file using the + * components of its path, i.e. if we are looking for c:/foo/bar/bill.txt, + * first look for bill.txt in 'dir', then in 'dir'/bar, then in 'dir'/foo/bar + * etc. + * Return true if the file was found, false otherwise. + */ + static bool LocateFileInDir(const char *filename, + const char *dir, + kwsys_stl::string& filename_found, + int try_filename_dirs = 0); + + /** + * Check if the given file exists in one of the parent directory of the + * given file or directory and if it does, return the name of the file. + * Toplevel specifies the top-most directory to where it will look. + */ + static kwsys_stl::string FileExistsInParentDirectories(const char* fname, + const char* directory, const char* toplevel); + + /** compute the relative path from local to remote. local must + be a directory. remote can be a file or a directory. + Both remote and local must be full paths. Basically, if + you are in directory local and you want to access the file in remote + what is the relative path to do that. For example: + /a/b/c/d to /a/b/c1/d1 -> ../../c1/d1 + from /usr/src to /usr/src/test/blah/foo.cpp -> test/blah/foo.cpp + */ + static kwsys_stl::string RelativePath(const char* local, const char* remote); + + /** + * Return file's modified time + */ + static long int ModifiedTime(const char* filename); + + /** + * Return file's creation time (Win32: works only for NTFS, not FAT) + */ + static long int CreationTime(const char* filename); + + /** + * Get and set permissions of the file. + */ + static bool GetPermissions(const char* file, mode_t& mode); + static bool SetPermissions(const char* file, mode_t mode); + + /** ----------------------------------------------------------------- + * Time Manipulation Routines + * ----------------------------------------------------------------- + */ + + /** + * Get current time as a double. On certain platforms this will + * return higher resolution than seconds: + * (1) gettimeofday() -- resolution in microseconds + * (2) ftime() -- resolution in milliseconds + * (3) time() -- resolution in seconds + */ + static double GetTime(); + + /** + * Get current date/time + */ + static kwsys_stl::string GetCurrentDateTime(const char* format); + + /** ----------------------------------------------------------------- + * Registry Manipulation Routines + * ----------------------------------------------------------------- + */ + + /** + * Read a registry value + */ + static bool ReadRegistryValue(const char *key, kwsys_stl::string &value); + + /** + * Write a registry value + */ + static bool WriteRegistryValue(const char *key, const char *value); + + /** + * Delete a registry value + */ + static bool DeleteRegistryValue(const char *key); + + /** ----------------------------------------------------------------- + * Environment Manipulation Routines + * ----------------------------------------------------------------- + */ + + /** + * Add the paths from the environment variable PATH to the + * string vector passed in. If env is set then the value + * of env will be used instead of PATH. + */ + static void GetPath(kwsys_stl::vector<kwsys_stl::string>& path, + const char* env=0); + + /** + * Read an environment variable + */ + static const char* GetEnv(const char* key); + static bool GetEnv(const char* key, kwsys_stl::string& result); + + /** + * Get current working directory CWD + */ + static kwsys_stl::string GetCurrentWorkingDirectory(bool collapse =true); + + /** + * Change directory the the directory specified + */ + static int ChangeDirectory(const char* dir); + + /** + * Get the result of strerror(errno) + */ + static kwsys_stl::string GetLastSystemError(); + + /** + * When building DEBUG with MSVC, this enables a hook that prevents + * error dialogs from popping up if the program is being run from + * DART. + */ + static void EnableMSVCDebugHook(); + + /** + * Get the width of the terminal window. The code may or may not work, so + * make sure you have some resonable defaults prepared if the code returns + * some bogus size. + */ + static int GetTerminalWidth(); + + /** + * Add an entry in the path translation table. + */ + static void AddTranslationPath(const char * dir, const char * refdir); + + /** + * If dir is different after CollapseFullPath is called, + * Then insert it into the path translation table + */ + static void AddKeepPath(const char* dir); + + /** + * Update path by going through the Path Translation table; + */ + static void CheckTranslationPath(kwsys_stl::string & path); + + /** + * Delay the execution for a specified amount of time specified + * in miliseconds + */ + static void Delay(unsigned int msec); + + /** + * Get the operating system name and version + * This is implemented for Win32 only for the moment + */ + static kwsys_stl::string GetOperatingSystemNameAndVersion(); + + /** + * Convert windows-style arguments given as a command-line string + * into more traditional argc/argv arguments. + * Note that argv[0] will be assigned the executable name using + * the ::GetModuleFileName function. + */ + static void ConvertWindowsCommandLineToUnixArguments( + const char *cmd_line, int *argc, char ***argv); + +protected: + // these two functions can be called from ConvertToOutputPath + + /** + * Convert the path to string that can be used in a windows project or + * makefile. Double slashes are removed if they are not at the start of + * the string, the slashes are converted to windows style backslashes, and + * if there are spaces in the string it is double quoted. + */ + static kwsys_stl::string ConvertToWindowsOutputPath(const char*); + +private: + /** + * Allocate the std::map that serve as the Path Translation table. + */ + static void ClassInitialize(); + + /** + * Deallocate the std::map that serve as the Path Translation table. + */ + static void ClassFinalize(); + + /** + * This method prevents warning on SGI + */ + SystemToolsManager* GetSystemToolsManager() + { + return &SystemToolsManagerInstance; + } + + /** + * Path translation table from dir to refdir + * Each time 'dir' will be found it will be replace by 'refdir' + */ + static SystemToolsTranslationMap *TranslationMap; + friend class SystemToolsManager; +}; + +} // namespace itksys + +/* Undefine temporary macros. */ +#if !defined (KWSYS_NAMESPACE) && !itksys_NAME_IS_KWSYS +# undef kwsys_stl +# undef kwsys_ios +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/cstddef b/Utilities/ITK/Utilities/itksys/cstddef new file mode 100755 index 0000000000000000000000000000000000000000..9574eab99d5e7978f8423664d000c1090f4dc4fd --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/cstddef @@ -0,0 +1,37 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_cstddef.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_cstddef +#define itksys_cstddef + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* Include the real header. */ +#if itksys_CXX_HAS_CSTDDEF +# include <cstddef> +#else +# include <stddef.h> +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/hash_fun.hxx b/Utilities/ITK/Utilities/itksys/hash_fun.hxx new file mode 100755 index 0000000000000000000000000000000000000000..205331ac0b43ee9aacbef4cf6f0cd91141a134ff --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/hash_fun.hxx @@ -0,0 +1,117 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: hash_fun.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ +#ifndef itksys_hash_fun_hxx +#define itksys_hash_fun_hxx + +#include <itksys/Configure.hxx> + +#include <itksys/cstddef> // size_t + +namespace itksys +{ + +template <class _Key> struct hash { }; + +inline size_t _stl_hash_string(const char* __s) +{ + unsigned long __h = 0; + for ( ; *__s; ++__s) + __h = 5*__h + *__s; + + return size_t(__h); +} + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<char*> { + size_t operator()(const char* __s) const { return _stl_hash_string(__s); } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<const char*> { + size_t operator()(const char* __s) const { return _stl_hash_string(__s); } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<char> { + size_t operator()(char __x) const { return __x; } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<unsigned char> { + size_t operator()(unsigned char __x) const { return __x; } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<signed char> { + size_t operator()(unsigned char __x) const { return __x; } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<short> { + size_t operator()(short __x) const { return __x; } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<unsigned short> { + size_t operator()(unsigned short __x) const { return __x; } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<int> { + size_t operator()(int __x) const { return __x; } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<unsigned int> { + size_t operator()(unsigned int __x) const { return __x; } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<long> { + size_t operator()(long __x) const { return __x; } +}; + +itksys_CXX_DEFINE_SPECIALIZATION +struct hash<unsigned long> { + size_t operator()(unsigned long __x) const { return __x; } +}; + +} // namespace itksys + +#endif diff --git a/Utilities/ITK/Utilities/itksys/hash_map.hxx b/Utilities/ITK/Utilities/itksys/hash_map.hxx new file mode 100755 index 0000000000000000000000000000000000000000..dae38dce361655765d1eb348de91236911588d25 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/hash_map.hxx @@ -0,0 +1,463 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: hash_map.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ +#ifndef itksys_hash_map_hxx +#define itksys_hash_map_hxx + +#include <itksys/hashtable.hxx> +#include <itksys/hash_fun.hxx> +#include <itksys/stl/functional> // equal_to + +#if defined(_MSC_VER) +# pragma warning (push) +# pragma warning (disable:4284) +# pragma warning (disable:4786) +#endif + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +# pragma set woff 1174 +# pragma set woff 1375 +#endif + +namespace itksys +{ + +// select1st is an extension: it is not part of the standard. +template <class T1, class T2> +struct hash_select1st: + public itksys_stl::unary_function<itksys_stl::pair<T1, T2>, T1> +{ + const T1& operator()(const itksys_stl::pair<T1, T2>& __x) const + { return __x.first; } +}; + +// Forward declaration of equality operator; needed for friend declaration. + +template <class _Key, class _Tp, + class _HashFcn = hash<_Key>, + class _EqualKey = itksys_stl::equal_to<_Key>, + class _Alloc = itksys_HASH_DEFAULT_ALLOCATOR(char) > +class hash_map; + +template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> +inline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&, + const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&); + +template <class _Key, class _Tp, class _HashFcn, class _EqualKey, + class _Alloc> +class hash_map +{ +private: + typedef hashtable<itksys_stl::pair<const _Key,_Tp>,_Key,_HashFcn, + hash_select1st<const _Key,_Tp>,_EqualKey,_Alloc> _Ht; + _Ht _M_ht; + +public: + typedef typename _Ht::key_type key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_funct() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +public: + hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + explicit hash_map(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + hash_map(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class _InputIterator> + hash_map(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template <class _InputIterator> + hash_map(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template <class _InputIterator> + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template <class _InputIterator> + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + +#else + hash_map(const value_type* __f, const value_type* __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const value_type* __f, const value_type* __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + hash_map(const_iterator __f, const_iterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const_iterator __f, const_iterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#endif + +public: + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); } + + friend bool operator==itksys_CXX_NULL_TEMPLATE_ARGS(const hash_map&, + const hash_map&); + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + +public: + itksys_stl::pair<iterator,bool> insert(const value_type& __obj) + { return _M_ht.insert_unique(__obj); } +#if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class _InputIterator> + void insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_unique(__f,__l); } +#else + void insert(const value_type* __f, const value_type* __l) { + _M_ht.insert_unique(__f,__l); + } + void insert(const_iterator __f, const_iterator __l) + { _M_ht.insert_unique(__f, __l); } +#endif + itksys_stl::pair<iterator,bool> insert_noresize(const value_type& __obj) + { return _M_ht.insert_unique_noresize(__obj); } + + iterator find(const key_type& __key) { return _M_ht.find(__key); } + const_iterator find(const key_type& __key) const + { return _M_ht.find(__key); } + + _Tp& operator[](const key_type& __key) { + return _M_ht.find_or_insert(value_type(__key, _Tp())).second; + } + + size_type count(const key_type& __key) const { return _M_ht.count(__key); } + + itksys_stl::pair<iterator, iterator> equal_range(const key_type& __key) + { return _M_ht.equal_range(__key); } + itksys_stl::pair<const_iterator, const_iterator> + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(iterator __it) { _M_ht.erase(__it); } + void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + + void resize(size_type __hint) { _M_ht.resize(__hint); } + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } +}; + +template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> +inline bool +operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, + const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) +{ + return __hm1._M_ht == __hm2._M_ht; +} + +template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> +inline bool +operator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, + const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) { + return !(__hm1 == __hm2); +} + +template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> +inline void +swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, + hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) +{ + __hm1.swap(__hm2); +} + +// Forward declaration of equality operator; needed for friend declaration. + +template <class _Key, class _Tp, + class _HashFcn = hash<_Key>, + class _EqualKey = itksys_stl::equal_to<_Key>, + class _Alloc = itksys_HASH_DEFAULT_ALLOCATOR(char) > +class hash_multimap; + +template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> +inline bool +operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, + const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2); + +template <class _Key, class _Tp, class _HashFcn, class _EqualKey, + class _Alloc> +class hash_multimap +{ +private: + typedef hashtable<itksys_stl::pair<const _Key, _Tp>, _Key, _HashFcn, + hash_select1st<const _Key, _Tp>, _EqualKey, _Alloc> + _Ht; + _Ht _M_ht; + +public: + typedef typename _Ht::key_type key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_funct() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +public: + hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + explicit hash_multimap(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + hash_multimap(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class _InputIterator> + hash_multimap(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template <class _InputIterator> + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template <class _InputIterator> + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template <class _InputIterator> + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + +#else + hash_multimap(const value_type* __f, const value_type* __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const value_type* __f, const value_type* __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + hash_multimap(const_iterator __f, const_iterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const_iterator __f, const_iterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#endif + +public: + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); } + + friend bool operator==itksys_CXX_NULL_TEMPLATE_ARGS(const hash_multimap&, + const hash_multimap&); + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + +public: + iterator insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } +#if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class _InputIterator> + void insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_equal(__f,__l); } +#else + void insert(const value_type* __f, const value_type* __l) { + _M_ht.insert_equal(__f,__l); + } + void insert(const_iterator __f, const_iterator __l) + { _M_ht.insert_equal(__f, __l); } +#endif + iterator insert_noresize(const value_type& __obj) + { return _M_ht.insert_equal_noresize(__obj); } + + iterator find(const key_type& __key) { return _M_ht.find(__key); } + const_iterator find(const key_type& __key) const + { return _M_ht.find(__key); } + + size_type count(const key_type& __key) const { return _M_ht.count(__key); } + + itksys_stl::pair<iterator, iterator> equal_range(const key_type& __key) + { return _M_ht.equal_range(__key); } + itksys_stl::pair<const_iterator, const_iterator> + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(iterator __it) { _M_ht.erase(__it); } + void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + +public: + void resize(size_type __hint) { _M_ht.resize(__hint); } + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } +}; + +template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> +inline bool +operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, + const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) +{ + return __hm1._M_ht == __hm2._M_ht; +} + +template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> +inline bool +operator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, + const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) { + return !(__hm1 == __hm2); +} + +template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> +inline void +swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, + hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) +{ + __hm1.swap(__hm2); +} + +} // namespace itksys + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +# pragma reset woff 1174 +# pragma reset woff 1375 +#endif + +#if defined(_MSC_VER) +# pragma warning (pop) +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/hash_set.hxx b/Utilities/ITK/Utilities/itksys/hash_set.hxx new file mode 100755 index 0000000000000000000000000000000000000000..28fa16bfc3447fa240606c2fd38c5600dcfe7c6d --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/hash_set.hxx @@ -0,0 +1,447 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: hash_set.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ +#ifndef itksys_hash_set_hxx +#define itksys_hash_set_hxx + +#include <itksys/hashtable.hxx> +#include <itksys/hash_fun.hxx> +#include <itksys/stl/functional> // equal_to + +#if defined(_MSC_VER) +# pragma warning (push) +# pragma warning (disable:4284) +# pragma warning (disable:4786) +#endif + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +# pragma set woff 1174 +# pragma set woff 1375 +#endif + +namespace itksys +{ + +// identity is an extension: it is not part of the standard. +template <class _Tp> +struct _Identity : public itksys_stl::unary_function<_Tp,_Tp> +{ + const _Tp& operator()(const _Tp& __x) const { return __x; } +}; + +// Forward declaration of equality operator; needed for friend declaration. + +template <class _Value, + class _HashFcn = hash<_Value>, + class _EqualKey = itksys_stl::equal_to<_Value>, + class _Alloc = itksys_HASH_DEFAULT_ALLOCATOR(char) > +class hash_set; + +template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> +inline bool +operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, + const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2); + +template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> +class hash_set +{ +private: + typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, + _EqualKey, _Alloc> _Ht; + _Ht _M_ht; + +public: + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::const_pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::const_reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::const_iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_funct() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +public: + hash_set() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + explicit hash_set(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + hash_set(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class _InputIterator> + hash_set(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template <class _InputIterator> + hash_set(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template <class _InputIterator> + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template <class _InputIterator> + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#else + + hash_set(const value_type* __f, const value_type* __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const value_type* __f, const value_type* __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + hash_set(const_iterator __f, const_iterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const_iterator __f, const_iterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#endif + +public: + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); } + + friend bool operator==itksys_CXX_NULL_TEMPLATE_ARGS(const hash_set&, + const hash_set&); + + iterator begin() const { return _M_ht.begin(); } + iterator end() const { return _M_ht.end(); } + +public: + itksys_stl::pair<iterator, bool> insert(const value_type& __obj) + { + typedef typename _Ht::iterator _Ht_iterator; + itksys_stl::pair<_Ht_iterator, bool> __p = _M_ht.insert_unique(__obj); + return itksys_stl::pair<iterator,bool>(__p.first, __p.second); + } +#if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class _InputIterator> + void insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_unique(__f,__l); } +#else + void insert(const value_type* __f, const value_type* __l) { + _M_ht.insert_unique(__f,__l); + } + void insert(const_iterator __f, const_iterator __l) + {_M_ht.insert_unique(__f, __l); } +#endif + itksys_stl::pair<iterator, bool> insert_noresize(const value_type& __obj) + { + typedef typename _Ht::iterator _Ht_iterator; + itksys_stl::pair<_Ht_iterator, bool> __p = + _M_ht.insert_unique_noresize(__obj); + return itksys_stl::pair<iterator, bool>(__p.first, __p.second); + } + + iterator find(const key_type& __key) const { return _M_ht.find(__key); } + + size_type count(const key_type& __key) const { return _M_ht.count(__key); } + + itksys_stl::pair<iterator, iterator> equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(iterator __it) { _M_ht.erase(__it); } + void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + +public: + void resize(size_type __hint) { _M_ht.resize(__hint); } + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } +}; + +template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> +inline bool +operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, + const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) +{ + return __hs1._M_ht == __hs2._M_ht; +} + +template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> +inline bool +operator!=(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, + const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) { + return !(__hs1 == __hs2); +} + +template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> +inline void +swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, + hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) +{ + __hs1.swap(__hs2); +} + +template <class _Value, + class _HashFcn = hash<_Value>, + class _EqualKey = itksys_stl::equal_to<_Value>, + class _Alloc = itksys_HASH_DEFAULT_ALLOCATOR(char) > +class hash_multiset; + +template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> +inline bool +operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, + const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2); + + +template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> +class hash_multiset +{ +private: + typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, + _EqualKey, _Alloc> _Ht; + _Ht _M_ht; + +public: + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::const_pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::const_reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::const_iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_funct() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +public: + hash_multiset() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + explicit hash_multiset(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + hash_multiset(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class _InputIterator> + hash_multiset(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template <class _InputIterator> + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template <class _InputIterator> + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template <class _InputIterator> + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#else + + hash_multiset(const value_type* __f, const value_type* __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const value_type* __f, const value_type* __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + hash_multiset(const_iterator __f, const_iterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const_iterator __f, const_iterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#endif + +public: + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); } + + friend bool operator==itksys_CXX_NULL_TEMPLATE_ARGS(const hash_multiset&, + const hash_multiset&); + + iterator begin() const { return _M_ht.begin(); } + iterator end() const { return _M_ht.end(); } + +public: + iterator insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } +#if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class _InputIterator> + void insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_equal(__f,__l); } +#else + void insert(const value_type* __f, const value_type* __l) { + _M_ht.insert_equal(__f,__l); + } + void insert(const_iterator __f, const_iterator __l) + { _M_ht.insert_equal(__f, __l); } +#endif + iterator insert_noresize(const value_type& __obj) + { return _M_ht.insert_equal_noresize(__obj); } + + iterator find(const key_type& __key) const { return _M_ht.find(__key); } + + size_type count(const key_type& __key) const { return _M_ht.count(__key); } + + itksys_stl::pair<iterator, iterator> equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(iterator __it) { _M_ht.erase(__it); } + void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + +public: + void resize(size_type __hint) { _M_ht.resize(__hint); } + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } +}; + +template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> +inline bool +operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, + const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) +{ + return __hs1._M_ht == __hs2._M_ht; +} + +template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> +inline bool +operator!=(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, + const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) { + return !(__hs1 == __hs2); +} + +template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> +inline void +swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, + hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) { + __hs1.swap(__hs2); +} + +} // namespace itksys + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +# pragma reset woff 1174 +# pragma reset woff 1375 +#endif + +#if defined(_MSC_VER) +# pragma warning (pop) +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/hashtable.hxx b/Utilities/ITK/Utilities/itksys/hashtable.hxx new file mode 100755 index 0000000000000000000000000000000000000000..1c6a61fcd65b30029ca74257d667be440237776c --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/hashtable.hxx @@ -0,0 +1,1258 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: hashtable.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ +#ifndef itksys_hashtable_hxx +#define itksys_hashtable_hxx + +#include <itksys/Configure.hxx> + +#include <itksys/cstddef> // size_t +#include <itksys/stl/algorithm> // lower_bound +#include <itksys/stl/functional> // unary_function +#include <itksys/stl/iterator> // iterator_traits +#include <itksys/stl/memory> // allocator +#include <itksys/stl/utility> // pair +#include <itksys/stl/vector> // vector + +#if defined(_MSC_VER) +# pragma warning (push) +# pragma warning (disable:4284) +# pragma warning (disable:4786) +#endif + +#if itksys_STL_HAS_ALLOCATOR_TEMPLATE +# define itksys_HASH_DEFAULT_ALLOCATOR(T) itksys_stl::allocator< T > +#elif itksys_STL_HAS_ALLOCATOR_NONTEMPLATE +# define itksys_HASH_DEFAULT_ALLOCATOR(T) itksys_stl::allocator +#else +# define itksys_HASH_DEFAULT_ALLOCATOR(T) itksys_stl::alloc +#endif + +#if itksys_STL_HAS_ALLOCATOR_OBJECTS +# define itksys_HASH_BUCKETS_INIT(__a) _M_buckets(__a) +# define itksys_HASH_BUCKETS_GET_ALLOCATOR(__b) , __b.get_allocator() +#else +# define itksys_HASH_BUCKETS_INIT(__a) _M_buckets() +# define itksys_HASH_BUCKETS_GET_ALLOCATOR(__b) +#endif + +namespace itksys +{ + +//---------------------------------------------------------------------------- +// Define an allocator adaptor for platforms that do not provide an +// allocator with the rebind member. +#if !itksys_STL_HAS_ALLOCATOR_REBIND + +// Utility functions to convert item counts. +inline size_t hash_sizeof(void*) { return sizeof(char); } +inline size_t hash_sizeof(const void*) { return sizeof(char); } +template <class TPtr> inline size_t hash_sizeof(TPtr p) { return sizeof(*p); } +template <class POut, class PIn, class TSize> +inline TSize hash_allocator_n(POut out, PIn in, TSize n) +{ + return n*(hash_sizeof(out)/hash_sizeof(in) + + (hash_sizeof(out)%hash_sizeof(in)>0)); +} + +// Define an allocation method to use the native allocator with +// the proper signature. The following signatures of the allocate +// method are used on various STL implementations: +// pointer allocate(size_type, const void* hint) +// pointer allocate(size_type) +// static pointer allocate(size_type, const void* hint) +// static pointer allocate(size_type) +// Where pointer might be a real type or void*. +// This set of overloads decodes the signature for a particular STL. +// The extra three int/long arguments will favor certain signatures +// over others in the case that multiple are present to avoid +// ambiguity errors. +template <class TAlloc, class PIn, class TSize, class THint, class POut> +inline void hash_allocate(TAlloc* a, PIn (TAlloc::*allocate)(TSize, THint), + TSize n_out, const void* hint, POut& out, + int, int, int) +{ + TSize n_in = hash_allocator_n(POut(), PIn(), n_out); + void* vout = (a->*allocate)(n_in, const_cast<THint>(hint)); + out = static_cast<POut>(vout); +} + +template <class TAlloc, class PIn, class TSize, class POut> +inline void hash_allocate(TAlloc* a, PIn (TAlloc::*allocate)(TSize), + TSize n_out, const void*, POut& out, + int, int, long) +{ + TSize n_in = hash_allocator_n(POut(), PIn(), n_out); + void* vout = (a->*allocate)(n_in); + out = static_cast<POut>(vout); +} + +template <class PIn, class TSize, class THint, class POut> +inline void hash_allocate(void*, PIn (*allocate)(TSize, THint), + TSize n_out, const void* hint, POut& out, + int, long, long) +{ + TSize n_in = hash_allocator_n(POut(), PIn(), n_out); + void* vout = allocate(n_in, const_cast<THint>(hint)); + out = static_cast<POut>(vout); +} + +template <class PIn, class TSize, class POut> +inline void hash_allocate(void*, PIn (*allocate)(TSize), + TSize n_out, const void*, POut& out, + long, long, long) +{ + TSize n_in = hash_allocator_n(POut(), PIn(), n_out); + void* vout = allocate(n_in); + out = static_cast<POut>(vout); +} + +// Define a deallocation method to use the native allocator with +// the proper signature. The following signatures of the deallocate +// method are used on various STL implementations: +// void deallocate(pointer, size_type) +// void deallocate(pointer) +// static void deallocate(pointer, size_type) +// static void deallocate(pointer) +// Where pointer might be a real type or void*. +// This set of overloads decodes the signature for a particular STL. +// The extra three int/long arguments will favor certain signatures +// over others in the case that multiple are present to avoid +// ambiguity errors. +template <class TAlloc, class PIn, class TSize, class PInReal, class POut> +inline void hash_deallocate(TAlloc* a, void (TAlloc::*deallocate)(PIn, TSize), + PInReal, POut p, TSize n_out, int, int, int) +{ + TSize n_in = hash_allocator_n(POut(), PInReal(), n_out); + void* vout = p; + (a->*deallocate)(static_cast<PIn>(vout), n_in); +} + +template <class TAlloc, class PIn, class TSize, class PInReal, class POut> +inline void hash_deallocate(TAlloc* a, void (TAlloc::*deallocate)(PIn), + PInReal, POut p, TSize, int, int, long) +{ + void* vout = p; + (a->*deallocate)(static_cast<PIn>(vout)); +} + +template <class PIn, class TSize, class PInReal, class POut> +inline void hash_deallocate(void*, void (*deallocate)(PIn, TSize), + PInReal, POut p, TSize n_out, int, long, long) +{ + TSize n_in = hash_allocator_n(POut(), PInReal(), n_out); + void* vout = p; + deallocate(static_cast<PIn>(vout), n_in); +} + +template <class PIn, class TSize, class PInReal, class POut> +inline void hash_deallocate(void*, void (*deallocate)(PIn), + PInReal, POut p, TSize, long, long, long) +{ + void* vout = p; + deallocate(static_cast<PIn>(vout)); +} + +// Use the same four overloads as hash_allocate to decode the type +// really used for allocation. This is passed as PInReal to the +// deallocate functions so that hash_allocator_n has the proper size. +template <class TAlloc, class PIn, class TSize, class THint> +inline PIn hash_allocate_type(PIn (TAlloc::*)(TSize, THint), + int, int, int) { return 0; } +template <class TAlloc, class PIn, class TSize> +inline PIn hash_allocate_type(PIn (TAlloc::*)(TSize), + int, int, long) { return 0; } +template <class PIn, class TSize, class THint> +inline PIn hash_allocate_type(PIn (*)(TSize, THint), + int, long, long) { return 0; } +template <class PIn, class TSize> +inline PIn hash_allocate_type(PIn (*)(TSize), + long, long, long) { return 0; } + +// Define the comparison operators in terms of a base type to avoid +// needing templated versions. +class hash_allocator_base {}; +bool operator==(const hash_allocator_base&, + const hash_allocator_base&) throw() { return true; } +bool operator!=(const hash_allocator_base&, + const hash_allocator_base&) throw() { return false; } + +// Define the allocator template. +template <class T, class Alloc> +class hash_allocator: public hash_allocator_base +{ +private: + // Store the real allocator privately. + typedef Alloc alloc_type; + alloc_type alloc_; + +public: + // Standard allocator interface. + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T value_type; + + hash_allocator() throw(): alloc_() {} + hash_allocator(const hash_allocator_base&) throw() : alloc_() {} + hash_allocator(const hash_allocator& a) throw() : alloc_(a.alloc_) {} + hash_allocator(const alloc_type& a) throw() : alloc_(a) {} + ~hash_allocator() throw() {} +# if itksys_CXX_HAS_MEMBER_TEMPLATES + template <class U> + struct rebind { typedef hash_allocator<U, alloc_type> other; }; +# endif + pointer address(reference x) const { return &x; } + const_pointer address(const_reference x) const { return &x; } + typedef void* void_pointer; + typedef const void* const_void_pointer; + pointer allocate(size_type n=1, const_void_pointer hint = 0) + { + if(n) + { + pointer p; + hash_allocate(&alloc_, &alloc_type::allocate, n, hint, p, 1, 1, 1); + return p; + } + else + { + return 0; + } + } + void deallocate(pointer p, size_type n=1) + { + if(n) + { + hash_deallocate(&alloc_, &alloc_type::deallocate, + hash_allocate_type(&alloc_type::allocate, 1, 1, 1), + p, n, 1, 1, 1); + } + } +#if itksys_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT + size_type max_size(size_type s) const throw() + { + return alloc_.max_size(s); + } +#else + size_type max_size() const throw() + { + size_type n = alloc_.max_size() / sizeof(value_type); + return n>0? n:1; + } +#endif + void construct(pointer p, const value_type& val) { new (p) value_type(val); } + void destroy(pointer p) { (void)p; p->~value_type(); } +}; +#endif + +template <class _Val> +struct _Hashtable_node +{ + _Hashtable_node* _M_next; + _Val _M_val; +}; + +template <class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, + class _Alloc = itksys_HASH_DEFAULT_ALLOCATOR(char) > +class hashtable; + +template <class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> +struct _Hashtable_iterator; + +template <class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> +struct _Hashtable_const_iterator; + +template <class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> +struct _Hashtable_iterator { + typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> + _Hashtable; + typedef _Hashtable_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + const_iterator; + typedef _Hashtable_node<_Val> _Node; + + typedef itksys_stl::forward_iterator_tag iterator_category; + typedef _Val value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef _Val& reference; + typedef _Val* pointer; + + _Node* _M_cur; + _Hashtable* _M_ht; + + _Hashtable_iterator(_Node* __n, _Hashtable* __tab) + : _M_cur(__n), _M_ht(__tab) {} + _Hashtable_iterator() {} + reference operator*() const { return _M_cur->_M_val; } + pointer operator->() const { return &(operator*()); } + iterator& operator++(); + iterator operator++(int); + bool operator==(const iterator& __it) const + { return _M_cur == __it._M_cur; } + bool operator!=(const iterator& __it) const + { return _M_cur != __it._M_cur; } +}; + + +template <class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> +struct _Hashtable_const_iterator { + typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> + _Hashtable; + typedef _Hashtable_iterator<_Val,_Key,_HashFcn, + _ExtractKey,_EqualKey,_Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + const_iterator; + typedef _Hashtable_node<_Val> _Node; + + typedef itksys_stl::forward_iterator_tag iterator_category; + typedef _Val value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef const _Val& reference; + typedef const _Val* pointer; + + const _Node* _M_cur; + const _Hashtable* _M_ht; + + _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) + : _M_cur(__n), _M_ht(__tab) {} + _Hashtable_const_iterator() {} + _Hashtable_const_iterator(const iterator& __it) + : _M_cur(__it._M_cur), _M_ht(__it._M_ht) {} + reference operator*() const { return _M_cur->_M_val; } + pointer operator->() const { return &(operator*()); } + const_iterator& operator++(); + const_iterator operator++(int); + bool operator==(const const_iterator& __it) const + { return _M_cur == __it._M_cur; } + bool operator!=(const const_iterator& __it) const + { return _M_cur != __it._M_cur; } +}; + +// Note: assumes long is at least 32 bits. +enum { _stl_num_primes = 31 }; + +static const unsigned long _stl_prime_list[_stl_num_primes] = +{ + 5ul, 11ul, 23ul, + 53ul, 97ul, 193ul, 389ul, 769ul, + 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, + 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, + 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, + 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, + 1610612741ul, 3221225473ul, 4294967291ul +}; + +inline unsigned long _stl_next_prime(unsigned long __n) +{ + const unsigned long* __first = _stl_prime_list; + const unsigned long* __last = _stl_prime_list + (int)_stl_num_primes; + const unsigned long* pos = itksys_stl::lower_bound(__first, __last, __n); + return pos == __last ? *(__last - 1) : *pos; +} + +// Forward declaration of operator==. + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +class hashtable; + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, + const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2); + +// Hashtables handle allocators a bit differently than other containers +// do. If we're using standard-conforming allocators, then a hashtable +// unconditionally has a member variable to hold its allocator, even if +// it so happens that all instances of the allocator type are identical. +// This is because, for hashtables, this extra storage is negligible. +// Additionally, a base class wouldn't serve any other purposes; it +// wouldn't, for example, simplify the exception-handling code. + +template <class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> +class hashtable { +public: + typedef _Key key_type; + typedef _Val value_type; + typedef _HashFcn hasher; + typedef _EqualKey key_equal; + + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + hasher hash_funct() const { return _M_hash; } + key_equal key_eq() const { return _M_equals; } + +private: + typedef _Hashtable_node<_Val> _Node; + +#if itksys_STL_HAS_ALLOCATOR_REBIND +public: + typedef typename _Alloc::template rebind<_Val>::other allocator_type; + allocator_type get_allocator() const { return _M_node_allocator; } +private: + typedef typename _Alloc::template rebind<_Node>::other _M_node_allocator_type; + typedef typename _Alloc::template rebind<_Node*>::other _M_node_ptr_allocator_type; + typedef itksys_stl::vector<_Node*,_M_node_ptr_allocator_type> _M_buckets_type; +#else +public: + typedef hash_allocator<_Val, _Alloc> allocator_type; + allocator_type get_allocator() const { return allocator_type(); } +private: + typedef hash_allocator<_Node, _Alloc> _M_node_allocator_type; +# if itksys_STL_HAS_ALLOCATOR_OBJECTS + typedef hash_allocator<_Node*, _Alloc> _M_node_ptr_allocator_type; +# else + typedef _Alloc _M_node_ptr_allocator_type; +# endif + typedef itksys_stl::vector<_Node*,_M_node_ptr_allocator_type> _M_buckets_type; +#endif + +private: + _M_node_allocator_type _M_node_allocator; + hasher _M_hash; + key_equal _M_equals; + _ExtractKey _M_get_key; + _M_buckets_type _M_buckets; + size_type _M_num_elements; + + _Node* _M_get_node() { return _M_node_allocator.allocate(1); } + void _M_put_node(_Node* __p) { _M_node_allocator.deallocate(__p, 1); } + +public: + typedef _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey, + _Alloc> + const_iterator; + + friend struct + _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>; + friend struct + _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>; + +public: + hashtable(size_type __n, + const _HashFcn& __hf, + const _EqualKey& __eql, + const _ExtractKey& __ext, + const allocator_type& __a = allocator_type()) + : _M_node_allocator(__a), + _M_hash(__hf), + _M_equals(__eql), + _M_get_key(__ext), + itksys_HASH_BUCKETS_INIT(__a), + _M_num_elements(0) + { + _M_initialize_buckets(__n); + } + + hashtable(size_type __n, + const _HashFcn& __hf, + const _EqualKey& __eql, + const allocator_type& __a = allocator_type()) + : _M_node_allocator(__a), + _M_hash(__hf), + _M_equals(__eql), + _M_get_key(_ExtractKey()), + itksys_HASH_BUCKETS_INIT(__a), + _M_num_elements(0) + { + _M_initialize_buckets(__n); + } + + hashtable(const hashtable& __ht) + : _M_node_allocator(__ht.get_allocator()), + _M_hash(__ht._M_hash), + _M_equals(__ht._M_equals), + _M_get_key(__ht._M_get_key), + itksys_HASH_BUCKETS_INIT(__ht.get_allocator()), + _M_num_elements(0) + { + _M_copy_from(__ht); + } + + hashtable& operator= (const hashtable& __ht) + { + if (&__ht != this) { + clear(); + _M_hash = __ht._M_hash; + _M_equals = __ht._M_equals; + _M_get_key = __ht._M_get_key; + _M_copy_from(__ht); + } + return *this; + } + + ~hashtable() { clear(); } + + size_type size() const { return _M_num_elements; } + size_type max_size() const { return size_type(-1); } + bool empty() const { return size() == 0; } + + void swap(hashtable& __ht) + { + itksys_stl::swap(_M_hash, __ht._M_hash); + itksys_stl::swap(_M_equals, __ht._M_equals); + itksys_stl::swap(_M_get_key, __ht._M_get_key); + _M_buckets.swap(__ht._M_buckets); + itksys_stl::swap(_M_num_elements, __ht._M_num_elements); + } + + iterator begin() + { + for (size_type __n = 0; __n < _M_buckets.size(); ++__n) + if (_M_buckets[__n]) + return iterator(_M_buckets[__n], this); + return end(); + } + + iterator end() { return iterator(0, this); } + + const_iterator begin() const + { + for (size_type __n = 0; __n < _M_buckets.size(); ++__n) + if (_M_buckets[__n]) + return const_iterator(_M_buckets[__n], this); + return end(); + } + + const_iterator end() const { return const_iterator(0, this); } + + friend bool operator==itksys_CXX_NULL_TEMPLATE_ARGS(const hashtable&, + const hashtable&); + +public: + + size_type bucket_count() const { return _M_buckets.size(); } + + size_type max_bucket_count() const + { return _stl_prime_list[(int)_stl_num_primes - 1]; } + + size_type elems_in_bucket(size_type __bucket) const + { + size_type __result = 0; + for (_Node* __cur = _M_buckets[__bucket]; __cur; __cur = __cur->_M_next) + __result += 1; + return __result; + } + + itksys_stl::pair<iterator, bool> insert_unique(const value_type& __obj) + { + resize(_M_num_elements + 1); + return insert_unique_noresize(__obj); + } + + iterator insert_equal(const value_type& __obj) + { + resize(_M_num_elements + 1); + return insert_equal_noresize(__obj); + } + + itksys_stl::pair<iterator, bool> insert_unique_noresize(const value_type& __obj); + iterator insert_equal_noresize(const value_type& __obj); + +#if itksys_STL_HAS_ITERATOR_TRAITS +# define itksys_HASH_ITERATOR_CATEGORY(T,I) \ + typename itksys_stl::iterator_traits< T >::iterator_category() +#elif itksys_STL_HAS_ITERATOR_CATEGORY +# define itksys_HASH_ITERATOR_CATEGORY(T,I) \ + itksys_stl::iterator_category( I ) +#elif itksys_STL_HAS___ITERATOR_CATEGORY +# define itksys_HASH_ITERATOR_CATEGORY(T,I) \ + itksys_stl::__iterator_category( I ) +#endif + +#if itksys_CXX_HAS_MEMBER_TEMPLATES && defined(itksys_HASH_ITERATOR_CATEGORY) + template <class _InputIterator> + void insert_unique(_InputIterator __f, _InputIterator __l) + { + insert_unique(__f, __l, + itksys_HASH_ITERATOR_CATEGORY(_InputIterator, __f)); + } + + template <class _InputIterator> + void insert_equal(_InputIterator __f, _InputIterator __l) + { + insert_equal(__f, __l, + itksys_HASH_ITERATOR_CATEGORY(_InputIterator, __f)); + } + + template <class _InputIterator> + void insert_unique(_InputIterator __f, _InputIterator __l, + itksys_stl::input_iterator_tag) + { + for ( ; __f != __l; ++__f) + insert_unique(*__f); + } + + template <class _InputIterator> + void insert_equal(_InputIterator __f, _InputIterator __l, + itksys_stl::input_iterator_tag) + { + for ( ; __f != __l; ++__f) + insert_equal(*__f); + } + + template <class _ForwardIterator> + void insert_unique(_ForwardIterator __f, _ForwardIterator __l, + itksys_stl::forward_iterator_tag) + { + size_type __n = 0; + itksys_stl::distance(__f, __l, __n); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + template <class _ForwardIterator> + void insert_equal(_ForwardIterator __f, _ForwardIterator __l, + itksys_stl::forward_iterator_tag) + { + size_type __n = 0; + itksys_stl::distance(__f, __l, __n); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } + +#else + void insert_unique(const value_type* __f, const value_type* __l) + { + size_type __n = __l - __f; + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + void insert_equal(const value_type* __f, const value_type* __l) + { + size_type __n = __l - __f; + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } + + void insert_unique(const_iterator __f, const_iterator __l) + { + size_type __n = 0; + itksys_stl::distance(__f, __l, __n); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + void insert_equal(const_iterator __f, const_iterator __l) + { + size_type __n = 0; + itksys_stl::distance(__f, __l, __n); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } +#endif + + reference find_or_insert(const value_type& __obj); + + iterator find(const key_type& __key) + { + size_type __n = _M_bkt_num_key(__key); + _Node* __first; + for ( __first = _M_buckets[__n]; + __first && !_M_equals(_M_get_key(__first->_M_val), __key); + __first = __first->_M_next) + {} + return iterator(__first, this); + } + + const_iterator find(const key_type& __key) const + { + size_type __n = _M_bkt_num_key(__key); + const _Node* __first; + for ( __first = _M_buckets[__n]; + __first && !_M_equals(_M_get_key(__first->_M_val), __key); + __first = __first->_M_next) + {} + return const_iterator(__first, this); + } + + size_type count(const key_type& __key) const + { + const size_type __n = _M_bkt_num_key(__key); + size_type __result = 0; + + for (const _Node* __cur = _M_buckets[__n]; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), __key)) + ++__result; + return __result; + } + + itksys_stl::pair<iterator, iterator> + equal_range(const key_type& __key); + + itksys_stl::pair<const_iterator, const_iterator> + equal_range(const key_type& __key) const; + + size_type erase(const key_type& __key); + void erase(const iterator& __it); + void erase(iterator __first, iterator __last); + + void erase(const const_iterator& __it); + void erase(const_iterator __first, const_iterator __last); + + void resize(size_type __num_elements_hint); + void clear(); + +private: + size_type _M_next_size(size_type __n) const + { return _stl_next_prime(__n); } + + void _M_initialize_buckets(size_type __n) + { + const size_type __n_buckets = _M_next_size(__n); + _M_buckets.reserve(__n_buckets); + _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); + _M_num_elements = 0; + } + + size_type _M_bkt_num_key(const key_type& __key) const + { + return _M_bkt_num_key(__key, _M_buckets.size()); + } + + size_type _M_bkt_num(const value_type& __obj) const + { + return _M_bkt_num_key(_M_get_key(__obj)); + } + + size_type _M_bkt_num_key(const key_type& __key, size_t __n) const + { + return _M_hash(__key) % __n; + } + + size_type _M_bkt_num(const value_type& __obj, size_t __n) const + { + return _M_bkt_num_key(_M_get_key(__obj), __n); + } + + void construct(_Val* p, const _Val& v) + { + new (p) _Val(v); + } + void destroy(_Val* p) + { + (void)p; + p->~_Val(); + } + + _Node* _M_new_node(const value_type& __obj) + { + _Node* __n = _M_get_node(); + __n->_M_next = 0; + try { + construct(&__n->_M_val, __obj); + return __n; + } + catch(...) {_M_put_node(__n); throw;} + } + + void _M_delete_node(_Node* __n) + { + destroy(&__n->_M_val); + _M_put_node(__n); + } + + void _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last); + void _M_erase_bucket(const size_type __n, _Node* __last); + + void _M_copy_from(const hashtable& __ht); + +}; + +template <class _Val, class _Key, class _HF, class _ExK, class _EqK, + class _All> +_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& +_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++() +{ + const _Node* __old = _M_cur; + _M_cur = _M_cur->_M_next; + if (!_M_cur) { + size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); + while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) + _M_cur = _M_ht->_M_buckets[__bucket]; + } + return *this; +} + +template <class _Val, class _Key, class _HF, class _ExK, class _EqK, + class _All> +inline _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All> +_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int) +{ + iterator __tmp = *this; + ++*this; + return __tmp; +} + +template <class _Val, class _Key, class _HF, class _ExK, class _EqK, + class _All> +_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& +_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++() +{ + const _Node* __old = _M_cur; + _M_cur = _M_cur->_M_next; + if (!_M_cur) { + size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); + while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) + _M_cur = _M_ht->_M_buckets[__bucket]; + } + return *this; +} + +template <class _Val, class _Key, class _HF, class _ExK, class _EqK, + class _All> +inline _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All> +_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int) +{ + const_iterator __tmp = *this; + ++*this; + return __tmp; +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, + const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) +{ + typedef typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::_Node _Node; + if (__ht1._M_buckets.size() != __ht2._M_buckets.size()) + return false; + for (int __n = 0; __n < __ht1._M_buckets.size(); ++__n) { + _Node* __cur1 = __ht1._M_buckets[__n]; + _Node* __cur2 = __ht2._M_buckets[__n]; + for ( ; __cur1 && __cur2 && __cur1->_M_val == __cur2->_M_val; + __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) + {} + if (__cur1 || __cur2) + return false; + } + return true; +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +inline bool operator!=(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, + const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) { + return !(__ht1 == __ht2); +} + +template <class _Val, class _Key, class _HF, class _Extract, class _EqKey, + class _All> +inline void swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1, + hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) { + __ht1.swap(__ht2); +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +itksys_stl::pair<itksys_CXX_DECL_TYPENAME hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator, bool> +hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> + ::insert_unique_noresize(const value_type& __obj) +{ + const size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + return itksys_stl::pair<iterator, bool>(iterator(__cur, this), false); + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return itksys_stl::pair<iterator, bool>(iterator(__tmp, this), true); +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator +hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> + ::insert_equal_noresize(const value_type& __obj) +{ + const size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) { + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __cur->_M_next; + __cur->_M_next = __tmp; + ++_M_num_elements; + return iterator(__tmp, this); + } + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return iterator(__tmp, this); +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::reference +hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::find_or_insert(const value_type& __obj) +{ + resize(_M_num_elements + 1); + + size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + return __cur->_M_val; + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return __tmp->_M_val; +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +itksys_stl::pair<itksys_CXX_DECL_TYPENAME hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator, + itksys_CXX_DECL_TYPENAME hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator> +hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::equal_range(const key_type& __key) +{ + typedef itksys_stl::pair<iterator, iterator> _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (_Node* __first = _M_buckets[__n]; __first; __first = __first->_M_next) + if (_M_equals(_M_get_key(__first->_M_val), __key)) { + for (_Node* __cur = __first->_M_next; __cur; __cur = __cur->_M_next) + if (!_M_equals(_M_get_key(__cur->_M_val), __key)) + return _Pii(iterator(__first, this), iterator(__cur, this)); + for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) + if (_M_buckets[__m]) + return _Pii(iterator(__first, this), + iterator(_M_buckets[__m], this)); + return _Pii(iterator(__first, this), end()); + } + return _Pii(end(), end()); +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +itksys_stl::pair<itksys_CXX_DECL_TYPENAME hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_iterator, + itksys_CXX_DECL_TYPENAME hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_iterator> +hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> + ::equal_range(const key_type& __key) const +{ + typedef itksys_stl::pair<const_iterator, const_iterator> _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (const _Node* __first = _M_buckets[__n] ; + __first; + __first = __first->_M_next) { + if (_M_equals(_M_get_key(__first->_M_val), __key)) { + for (const _Node* __cur = __first->_M_next; + __cur; + __cur = __cur->_M_next) + if (!_M_equals(_M_get_key(__cur->_M_val), __key)) + return _Pii(const_iterator(__first, this), + const_iterator(__cur, this)); + for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) + if (_M_buckets[__m]) + return _Pii(const_iterator(__first, this), + const_iterator(_M_buckets[__m], this)); + return _Pii(const_iterator(__first, this), end()); + } + } + return _Pii(end(), end()); +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::size_type +hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const key_type& __key) +{ + const size_type __n = _M_bkt_num_key(__key); + _Node* __first = _M_buckets[__n]; + size_type __erased = 0; + + if (__first) { + _Node* __cur = __first; + _Node* __next = __cur->_M_next; + while (__next) { + if (_M_equals(_M_get_key(__next->_M_val), __key)) { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + __next = __cur->_M_next; + ++__erased; + --_M_num_elements; + } + else { + __cur = __next; + __next = __cur->_M_next; + } + } + if (_M_equals(_M_get_key(__first->_M_val), __key)) { + _M_buckets[__n] = __first->_M_next; + _M_delete_node(__first); + ++__erased; + --_M_num_elements; + } + } + return __erased; +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const iterator& __it) +{ + _Node* __p = __it._M_cur; + if (__p) { + const size_type __n = _M_bkt_num(__p->_M_val); + _Node* __cur = _M_buckets[__n]; + + if (__cur == __p) { + _M_buckets[__n] = __cur->_M_next; + _M_delete_node(__cur); + --_M_num_elements; + } + else { + _Node* __next = __cur->_M_next; + while (__next) { + if (__next == __p) { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + --_M_num_elements; + break; + } + else { + __cur = __next; + __next = __cur->_M_next; + } + } + } + } +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> + ::erase(iterator __first, iterator __last) +{ + size_type __f_bucket = __first._M_cur ? + _M_bkt_num(__first._M_cur->_M_val) : _M_buckets.size(); + size_type __l_bucket = __last._M_cur ? + _M_bkt_num(__last._M_cur->_M_val) : _M_buckets.size(); + + if (__first._M_cur == __last._M_cur) + return; + else if (__f_bucket == __l_bucket) + _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); + else { + _M_erase_bucket(__f_bucket, __first._M_cur, 0); + for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) + _M_erase_bucket(__n, 0); + if (__l_bucket != _M_buckets.size()) + _M_erase_bucket(__l_bucket, __last._M_cur); + } +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +inline void +hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const_iterator __first, + const_iterator __last) +{ + erase(iterator(const_cast<_Node*>(__first._M_cur), + const_cast<hashtable*>(__first._M_ht)), + iterator(const_cast<_Node*>(__last._M_cur), + const_cast<hashtable*>(__last._M_ht))); +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +inline void +hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const const_iterator& __it) +{ + erase(iterator(const_cast<_Node*>(__it._M_cur), + const_cast<hashtable*>(__it._M_ht))); +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> + ::resize(size_type __num_elements_hint) +{ + const size_type __old_n = _M_buckets.size(); + if (__num_elements_hint > __old_n) { + const size_type __n = _M_next_size(__num_elements_hint); + if (__n > __old_n) { + _M_buckets_type __tmp( + __n, (_Node*)(0) + itksys_HASH_BUCKETS_GET_ALLOCATOR(_M_buckets)); + try { + for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) { + _Node* __first = _M_buckets[__bucket]; + while (__first) { + size_type __new_bucket = _M_bkt_num(__first->_M_val, __n); + _M_buckets[__bucket] = __first->_M_next; + __first->_M_next = __tmp[__new_bucket]; + __tmp[__new_bucket] = __first; + __first = _M_buckets[__bucket]; + } + } + _M_buckets.swap(__tmp); + } + catch(...) { + for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) { + while (__tmp[__bucket]) { + _Node* __next = __tmp[__bucket]->_M_next; + _M_delete_node(__tmp[__bucket]); + __tmp[__bucket] = __next; + } + } + throw; + } + } + } +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> + ::_M_erase_bucket(const size_type __n, _Node* __first, _Node* __last) +{ + _Node* __cur = _M_buckets[__n]; + if (__cur == __first) + _M_erase_bucket(__n, __last); + else { + _Node* __next; + for (__next = __cur->_M_next; + __next != __first; + __cur = __next, __next = __cur->_M_next) + ; + while (__next != __last) { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + __next = __cur->_M_next; + --_M_num_elements; + } + } +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> + ::_M_erase_bucket(const size_type __n, _Node* __last) +{ + _Node* __cur = _M_buckets[__n]; + while (__cur != __last) { + _Node* __next = __cur->_M_next; + _M_delete_node(__cur); + __cur = __next; + _M_buckets[__n] = __cur; + --_M_num_elements; + } +} + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::clear() +{ + for (size_type __i = 0; __i < _M_buckets.size(); ++__i) { + _Node* __cur = _M_buckets[__i]; + while (__cur != 0) { + _Node* __next = __cur->_M_next; + _M_delete_node(__cur); + __cur = __next; + } + _M_buckets[__i] = 0; + } + _M_num_elements = 0; +} + + +template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> +void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> + ::_M_copy_from(const hashtable& __ht) +{ + _M_buckets.clear(); + _M_buckets.reserve(__ht._M_buckets.size()); + _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0); + try { + for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { + const _Node* __cur = __ht._M_buckets[__i]; + if (__cur) { + _Node* __copy = _M_new_node(__cur->_M_val); + _M_buckets[__i] = __copy; + + for (_Node* __next = __cur->_M_next; + __next; + __cur = __next, __next = __cur->_M_next) { + __copy->_M_next = _M_new_node(__next->_M_val); + __copy = __copy->_M_next; + } + } + } + _M_num_elements = __ht._M_num_elements; + } + catch(...) {clear(); throw;} +} + +} // namespace itksys + +// Normally the comparison operators should be found in the itksys +// namespace by argument dependent lookup. For compilers that do not +// support it we must bring them into the global namespace now. +#if !itksys_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP +using itksys::operator==; +using itksys::operator!=; +#endif + +#if defined(_MSC_VER) +# pragma warning (pop) +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/ios/fstream b/Utilities/ITK/Utilities/itksys/ios/fstream new file mode 100755 index 0000000000000000000000000000000000000000..d7ad977eeb1e5df10abe567a546d63497b80edad --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/ios/fstream @@ -0,0 +1,48 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_ios_fstream.h.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_ios_fstream +#define itksys_ios_fstream + +#include <itksys/Configure.hxx> + +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4995) /* Old streams are deprecated. */ +#endif + +#if itksys_IOS_USE_ANSI +# include <fstream> +#else +# include <fstream.h> +#endif + +#if !itksys_IOS_USE_SSTREAM +namespace itksys_ios +{ + using itksys_ios_namespace::ostream; + using itksys_ios_namespace::istream; + using itksys_ios_namespace::ofstream; + using itksys_ios_namespace::ifstream; + using itksys_ios_namespace::ios; + using itksys_ios_namespace::endl; + using itksys_ios_namespace::flush; +} +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/ios/iosfwd b/Utilities/ITK/Utilities/itksys/ios/iosfwd new file mode 100755 index 0000000000000000000000000000000000000000..70b4052c8556550e558468029c32f9b79dab67ea --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/ios/iosfwd @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_ios_iosfwd.h.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_ios_iosfwd +#define itksys_ios_iosfwd + +#include <itksys/Configure.hxx> + +#ifdef _MSC_VER +#pragma warning (push, 1) +#pragma warning (disable: 4702) +#endif + +#if itksys_IOS_USE_ANSI +# include <iosfwd> +#else +class fstream; +class ifstream; +class ios; +class istream; +class ofstream; +class ostream; +#endif + +#if !itksys_IOS_USE_SSTREAM +namespace itksys_ios +{ + using itksys_ios_namespace::fstream; + using itksys_ios_namespace::ifstream; + using itksys_ios_namespace::ios; + using itksys_ios_namespace::istream; + using itksys_ios_namespace::ofstream; + using itksys_ios_namespace::ostream; +} +#endif + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/ios/iostream b/Utilities/ITK/Utilities/itksys/ios/iostream new file mode 100755 index 0000000000000000000000000000000000000000..b33cec4fb43d96ed0bcd6d0186bd676b97ea58b2 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/ios/iostream @@ -0,0 +1,49 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_ios_iostream.h.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_ios_iostream +#define itksys_ios_iostream + +#include <itksys/Configure.hxx> + +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4995) /* Old streams are deprecated. */ +#endif + +#if itksys_IOS_USE_ANSI +# include <iostream> +#else +# include <iostream.h> +#endif + +#if !itksys_IOS_USE_SSTREAM +namespace itksys_ios +{ + using itksys_ios_namespace::ostream; + using itksys_ios_namespace::istream; + using itksys_ios_namespace::ios; + using itksys_ios_namespace::cout; + using itksys_ios_namespace::cerr; + using itksys_ios_namespace::cin; + using itksys_ios_namespace::endl; + using itksys_ios_namespace::flush; +} +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/ios/sstream b/Utilities/ITK/Utilities/itksys/ios/sstream new file mode 100755 index 0000000000000000000000000000000000000000..b45540b44098331b02e823e03fbff6a92ca63b90 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/ios/sstream @@ -0,0 +1,146 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_ios_sstream.h.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_ios_sstream +#define itksys_ios_sstream + +#include <itksys/Configure.hxx> + +/* Define this macro temporarily to keep the code readable. */ +#if !defined (KWSYS_NAMESPACE) && !itksys_NAME_IS_KWSYS +# define kwsys_stl itksys_stl +#endif + +#if itksys_IOS_USE_SSTREAM +# ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# endif +# include <sstream> +# ifdef _MSC_VER +# pragma warning(pop) +# endif +#else +# ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4995) /* Old streams are deprecated. */ +# endif +# if itksys_IOS_USE_ANSI +# include <strstream> +# elif itksys_IOS_USE_STRSTREAM_H +# include <strstream.h> +# elif itksys_IOS_USE_STRSTREA_H +# include <strstrea.h> +# endif +# if itksys_IOS_USE_ANSI +# include <new> // Need placement operator new. +# else +# include <new.h> // Need placement operator new. +# endif +# ifdef _MSC_VER +# pragma warning(pop) +# endif + +// Only have old std::strstream classes. Wrap them to look like new +// ostringstream and istringstream classes. + +# include <itksys/stl/string> + +namespace itksys_ios +{ +using itksys_ios_namespace::streambuf; +using itksys_ios_namespace::ostream; +using itksys_ios_namespace::istream; +using itksys_ios_namespace::istrstream; +using itksys_ios_namespace::ostrstream; +using itksys_ios_namespace::ios; +using itksys_ios_namespace::endl; +using itksys_ios_namespace::ends; +using itksys_ios_namespace::flush; + +class ostringstream_cleanup +{ +public: + ostringstream_cleanup(ostrstream& ostr): m_OStrStream(ostr) {} + ~ostringstream_cleanup() { m_OStrStream.rdbuf()->freeze(0); } + static void IgnoreUnusedVariable(const ostringstream_cleanup&) {} +protected: + ostrstream& m_OStrStream; +private: + void operator=(ostringstream_cleanup const&); +}; + +class ostringstream: public ostrstream +{ +public: + typedef ostrstream Superclass; + ostringstream() {} + ostringstream(const kwsys_stl::string& s) { *this << s.c_str(); } + kwsys_stl::string str() + { + ostringstream_cleanup cleanup(*this); + ostringstream_cleanup::IgnoreUnusedVariable(cleanup); + int pcount = this->pcount(); + const char* ptr = this->Superclass::str(); + return kwsys_stl::string(ptr?ptr:"", pcount); + } + void str(const kwsys_stl::string& s) + { + this->~ostringstream(); + new (this) ostringstream(s); + } +private: + ostringstream(const ostringstream&); + void operator=(const ostringstream&); +}; + +#if defined(_MSC_VER) +# pragma warning (push) +# pragma warning (disable: 4097) /* typedef-name used as synonym for class */ +#endif + +class istringstream: private kwsys_stl::string, public istrstream +{ +public: + typedef kwsys_stl::string StdString; + typedef istrstream IStrStream; + istringstream(): StdString(), + IStrStream(const_cast<char*>(StdString::c_str())) {} + istringstream(const kwsys_stl::string& s): + StdString(s), IStrStream(const_cast<char*>(StdString::c_str())) {} + kwsys_stl::string str() const { return *this; } + void str(const kwsys_stl::string& s) + { + this->~istringstream(); + new (this) istringstream(s); + } +private: + istringstream(const istringstream&); + void operator=(const istringstream&); +}; + +#if defined(_MSC_VER) +# pragma warning (pop) +#endif + +} // namespace itksys_ios + +#endif + +/* Undefine temporary macro. */ +#if !defined (KWSYS_NAMESPACE) && !itksys_NAME_IS_KWSYS +# undef kwsys_stl +#endif + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/algorithm b/Utilities/ITK/Utilities/itksys/stl/algorithm new file mode 100755 index 0000000000000000000000000000000000000000..29c2a872172250995687a071ae2e1d913563b6a4 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/algorithm @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_algorithm +#define itksys_stl_algorithm + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <algorithm> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/deque b/Utilities/ITK/Utilities/itksys/stl/deque new file mode 100755 index 0000000000000000000000000000000000000000..cda8ca49ff0a9818046f528b194c63a8f8ee12e8 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/deque @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_deque +#define itksys_stl_deque + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <deque> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/functional b/Utilities/ITK/Utilities/itksys/stl/functional new file mode 100755 index 0000000000000000000000000000000000000000..a4d42c1b5658de2de3ca553571734ab1ac4b4822 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/functional @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_functional +#define itksys_stl_functional + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <functional> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/iterator b/Utilities/ITK/Utilities/itksys/stl/iterator new file mode 100755 index 0000000000000000000000000000000000000000..93fd4be914b82cd36a15aef0a3a6f3b97d14ffb1 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/iterator @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_iterator +#define itksys_stl_iterator + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <iterator> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/list b/Utilities/ITK/Utilities/itksys/stl/list new file mode 100755 index 0000000000000000000000000000000000000000..2dd133b2757172bb05f3a586330206614858dc52 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/list @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_list +#define itksys_stl_list + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <list> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/map b/Utilities/ITK/Utilities/itksys/stl/map new file mode 100755 index 0000000000000000000000000000000000000000..9e189531d568e388b742b4e896ecacf2924fdba5 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/map @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_map +#define itksys_stl_map + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <map> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/memory b/Utilities/ITK/Utilities/itksys/stl/memory new file mode 100755 index 0000000000000000000000000000000000000000..9cf5736c62ed424be2aebd19980e9154b5e5b577 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/memory @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_memory +#define itksys_stl_memory + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <memory> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/numeric b/Utilities/ITK/Utilities/itksys/stl/numeric new file mode 100755 index 0000000000000000000000000000000000000000..49a2414d257924a21cbd30ccad6ffd22cfc369de --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/numeric @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_numeric +#define itksys_stl_numeric + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <numeric> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/queue b/Utilities/ITK/Utilities/itksys/stl/queue new file mode 100755 index 0000000000000000000000000000000000000000..3031a782fbfab8d3a38d4d77d50fd1e9b78cff52 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/queue @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_queue +#define itksys_stl_queue + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <queue> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/set b/Utilities/ITK/Utilities/itksys/stl/set new file mode 100755 index 0000000000000000000000000000000000000000..c5267c4b68787aa98377a5eb1b25b6138687885a --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/set @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_set +#define itksys_stl_set + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <set> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/stack b/Utilities/ITK/Utilities/itksys/stl/stack new file mode 100755 index 0000000000000000000000000000000000000000..d5e89e2a82c30ae014ca107fe82ce9096eb66f4c --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/stack @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_stack +#define itksys_stl_stack + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <stack> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/string b/Utilities/ITK/Utilities/itksys/stl/string new file mode 100755 index 0000000000000000000000000000000000000000..b295aaff34651dc2feebbec932aef2ca6d1e2e7b --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/string @@ -0,0 +1,54 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_string +#define itksys_stl_string + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <string> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#define itksys_stl_string_including_hxx +# include <itksys/stl/string.hxx> +#undef itksys_stl_string_including_hxx + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/string.hxx b/Utilities/ITK/Utilities/itksys/stl/string.hxx new file mode 100755 index 0000000000000000000000000000000000000000..b920d70cefba674516928856d067e251f3bf23fd --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/string.hxx @@ -0,0 +1,114 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl_string.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +// This header is extra code for <itksys/stl/string>. +#if !defined(itksys_stl_string_including_hxx) +# error "The header <itksys/stl/string.hxx> may be included only by <itksys/stl/string>." +#endif + +// Provide the istream operator for the stl string if it is not +// provided by the system or another copy of kwsys. Allow user code +// to block this definition by defining the macro +// itksys_STL_STRING_NO_ISTREAM +// to avoid conflicts with other libraries. User code can test for +// this definition by checking the macro +// itksys_STL_STRING_ISTREAM_DEFINED +#if !itksys_STL_STRING_HAVE_ISTREAM && !defined(itksys_STL_STRING_NO_ISTREAM) && !defined(KWSYS_STL_STRING_ISTREAM_DEFINED) +# define KWSYS_STL_STRING_ISTREAM_DEFINED +# define itksys_STL_STRING_ISTREAM_DEFINED +# include <ctype.h> // isspace +# include <itksys/ios/iostream> +inline itksys_ios::istream& +operator>>(itksys_ios::istream& is, + itksys_stl::string& s) +{ + // Keep track of the resulting state. + int state = itksys_ios::ios::goodbit; + + // Save the width setting and set it back to zero. + size_t n = static_cast<size_t>(is.width(0)); + + // Clear any old contents of the output string. + s.erase(); + + // Skip leading whitespace. + is.eatwhite(); + istream& okay = is; + + if(okay) + { + // Select a maximum possible length. + if(n == 0 || n >= s.max_size()) + { + n = s.max_size(); + } + + // Read until a space is found or the maximum length is reached. + bool success = false; + for(int c = is.peek(); (--n > 0 && c != EOF && !isspace(c)); c = is.peek()) + { + s += static_cast<char>(c); + success = true; + is.ignore(); + } + + // Set flags for resulting state. + if(is.peek() == EOF) { state |= itksys_ios::ios::eofbit; } + if(success) { state |= itksys_ios::ios::failbit; } + } + + // Set the final result state. + is.clear(state); + return is; +} +#endif + +// Provide the ostream operator for the stl string if it is not +// provided by the system or another copy of kwsys. Allow user code +// to block this definition by defining the macro +// itksys_STL_STRING_NO_OSTREAM +// to avoid conflicts with other libraries. User code can test for +// this definition by checking the macro +// itksys_STL_STRING_OSTREAM_DEFINED +#if !itksys_STL_STRING_HAVE_OSTREAM && !defined(itksys_STL_STRING_NO_OSTREAM) && !defined(KWSYS_STL_STRING_OSTREAM_DEFINED) +# define KWSYS_STL_STRING_OSTREAM_DEFINED +# define itksys_STL_STRING_OSTREAM_DEFINED +# include <itksys/ios/iostream> +inline itksys_ios::ostream& +operator<<(itksys_ios::ostream& os, + itksys_stl::string const& s) +{ + return os << s.c_str(); +} +#endif + +// Provide the operator!= for the stl string and char* if it is not +// provided by the system or another copy of kwsys. Allow user code +// to block this definition by defining the macro +// itksys_STL_STRING_NO_NEQ_CHAR +// to avoid conflicts with other libraries. User code can test for +// this definition by checking the macro +// itksys_STL_STRING_NEQ_CHAR_DEFINED +#if !itksys_STL_STRING_HAVE_NEQ_CHAR && !defined(itksys_STL_STRING_NO_NEQ_CHAR) && !defined(KWSYS_STL_STRING_NEQ_CHAR_DEFINED) +# define KWSYS_STL_STRING_NEQ_CHAR_DEFINED +# define itksys_STL_STRING_NEQ_CHAR_DEFINED +inline bool operator!=(itksys_stl::string const& s, const char* c) +{ + return !(s == c); +} +inline bool operator!=(const char* c, itksys_stl::string const& s) +{ + return !(s == c); +} +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/utility b/Utilities/ITK/Utilities/itksys/stl/utility new file mode 100755 index 0000000000000000000000000000000000000000..2ab1ff910bc3b63c1f87115f4c3a39e101a9a1d4 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/utility @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_utility +#define itksys_stl_utility + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <utility> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif diff --git a/Utilities/ITK/Utilities/itksys/stl/vector b/Utilities/ITK/Utilities/itksys/stl/vector new file mode 100755 index 0000000000000000000000000000000000000000..1d28d39cc5c514cd1aa1f48ef36566f0f14b8348 --- /dev/null +++ b/Utilities/ITK/Utilities/itksys/stl/vector @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile: kwsys_stl.hxx.in,v $ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef itksys_stl_vector +#define itksys_stl_vector + +#include <itksys/Configure.hxx> + +/* Avoid warnings in MSVC standard headers. */ +#ifdef _MSC_VER +# pragma warning (push, 1) +# pragma warning (disable: 4702) +# pragma warning (disable: 4786) +#endif + +/* The HP standard library defines the functor "times" instead of + "multiplies" as specified by C++98 20.3.2 for backward + compatibility with earlier specifications. Defining this macro + fixes this behavior. The name "times" also conflicts with the + function declared in sys/times.h on that platform, so we must do + this as a work-around anyway. */ +#if defined(__HP_aCC) && !defined(__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# define __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# define itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +/* Include the real header. */ +#include <vector> + +/* Cleanup. */ +#if defined(itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL) +# undef itksys_DEFINED___HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +# undef __HPACC_USING_MULTIPLIES_IN_FUNCTIONAL +#endif + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +#endif