diff --git a/.gitignore b/.gitignore index 40e9a3fa..42b9133f 100644 --- a/.gitignore +++ b/.gitignore @@ -79,6 +79,9 @@ !/OpenXLSX/external/* !/OpenXLSX/headers !/OpenXLSX/headers/* +!/OpenXLSX/module.modulemap +!/OpenXLSX/swiftpm +!/OpenXLSX/swiftpm/* !/OpenXLSX/OpenXLSXConfig.cmake !/OpenXLSX/OpenXLSX.hpp !/OpenXLSX/sources @@ -103,3 +106,5 @@ !/Tests/catch/*.hpp !/Tests/CMakeLists.txt !/Tests/*.cpp + +!/Package.swift diff --git a/OpenXLSX/CMakeLists.txt b/OpenXLSX/CMakeLists.txt index 1c1b4354..f10cbbf8 100644 --- a/OpenXLSX/CMakeLists.txt +++ b/OpenXLSX/CMakeLists.txt @@ -185,6 +185,7 @@ if ("${OPENXLSX_LIBRARY_TYPE}" STREQUAL "SHARED") endif() +target_compile_definitions(OpenXLSX PUBLIC OPENXLSX_CMAKE) if (OPENXLSX_ENABLE_NOWIDE) target_compile_definitions(OpenXLSX PRIVATE ENABLE_NOWIDE) diff --git a/OpenXLSX/external/zippy/zippy.hpp b/OpenXLSX/external/zippy/zippy.hpp index 0278b2a7..973a303a 100644 --- a/OpenXLSX/external/zippy/zippy.hpp +++ b/OpenXLSX/external/zippy/zippy.hpp @@ -633,11 +633,16 @@ namespace ns_miniz #endif #pragma once +} // namespace ns_miniz + #include #include #include #include +namespace ns_miniz +{ + /* ------------------- Types and macros */ typedef unsigned char mz_uint8; @@ -4657,8 +4662,20 @@ namespace ns_miniz # define MZ_FILE void* # else +# ifdef __cplusplus + } +# endif +} // namespace ns_miniz + # include +namespace ns_miniz +{ +# ifdef __cplusplus + extern "C" + { +# endif + # if defined(_MSC_VER) || defined(__MINGW64__) static FILE* mz_fopen(const char* pFilename, const char* pMode) { @@ -4738,8 +4755,20 @@ namespace ns_miniz # elif defined(__APPLE__) # ifndef MINIZ_NO_TIME +# ifdef __cplusplus + } +# endif +} // namespace ns_miniz + # include +namespace ns_miniz +{ +# ifdef __cplusplus + extern "C" + { +# endif + # endif # define MZ_FOPEN(f, m) FILESYSTEM_NAMESPACE::fopen(f, m) diff --git a/OpenXLSX/headers/IZipArchive.hpp b/OpenXLSX/headers/IZipArchive.hpp index 4ca1ff3d..02b77943 100644 --- a/OpenXLSX/headers/IZipArchive.hpp +++ b/OpenXLSX/headers/IZipArchive.hpp @@ -53,7 +53,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #endif // _MSC_VER // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include #include diff --git a/OpenXLSX/headers/XLCell.hpp b/OpenXLSX/headers/XLCell.hpp index 7e82588a..8e6b869c 100644 --- a/OpenXLSX/headers/XLCell.hpp +++ b/OpenXLSX/headers/XLCell.hpp @@ -57,7 +57,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLCellReference.hpp" #include "XLCellValue.hpp" #include "XLFormula.hpp" diff --git a/OpenXLSX/headers/XLCellIterator.hpp b/OpenXLSX/headers/XLCellIterator.hpp index 767f9808..e3b4dd2c 100644 --- a/OpenXLSX/headers/XLCellIterator.hpp +++ b/OpenXLSX/headers/XLCellIterator.hpp @@ -54,7 +54,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLCell.hpp" #include "XLCellReference.hpp" #include "XLIterator.hpp" diff --git a/OpenXLSX/headers/XLCellRange.hpp b/OpenXLSX/headers/XLCellRange.hpp index c2c17674..fca438ce 100644 --- a/OpenXLSX/headers/XLCellRange.hpp +++ b/OpenXLSX/headers/XLCellRange.hpp @@ -56,7 +56,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLCell.hpp" #include "XLCellIterator.hpp" #include "XLCellReference.hpp" diff --git a/OpenXLSX/headers/XLCellReference.hpp b/OpenXLSX/headers/XLCellReference.hpp index ab16a032..385ce371 100644 --- a/OpenXLSX/headers/XLCellReference.hpp +++ b/OpenXLSX/headers/XLCellReference.hpp @@ -58,7 +58,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" namespace OpenXLSX { diff --git a/OpenXLSX/headers/XLCellValue.hpp b/OpenXLSX/headers/XLCellValue.hpp index bbe7c3fe..a0d1d202 100644 --- a/OpenXLSX/headers/XLCellValue.hpp +++ b/OpenXLSX/headers/XLCellValue.hpp @@ -60,7 +60,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLDateTime.hpp" #include "XLException.hpp" #include "XLXmlParser.hpp" diff --git a/OpenXLSX/headers/XLColor.hpp b/OpenXLSX/headers/XLColor.hpp index 888c603f..9e660884 100644 --- a/OpenXLSX/headers/XLColor.hpp +++ b/OpenXLSX/headers/XLColor.hpp @@ -57,7 +57,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" namespace OpenXLSX { diff --git a/OpenXLSX/headers/XLColumn.hpp b/OpenXLSX/headers/XLColumn.hpp index 158e2938..a121f846 100644 --- a/OpenXLSX/headers/XLColumn.hpp +++ b/OpenXLSX/headers/XLColumn.hpp @@ -56,7 +56,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLStyles.hpp" // XLStyleIndex #include "XLXmlParser.hpp" diff --git a/OpenXLSX/headers/XLComments.hpp b/OpenXLSX/headers/XLComments.hpp index 61efd237..b6e1765a 100644 --- a/OpenXLSX/headers/XLComments.hpp +++ b/OpenXLSX/headers/XLComments.hpp @@ -53,7 +53,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. // #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" // #include "XLCell.hpp" // #include "XLCellReference.hpp" // #include "XLColor.hpp" diff --git a/OpenXLSX/headers/XLContentTypes.hpp b/OpenXLSX/headers/XLContentTypes.hpp index cbe420b8..cc2c907e 100644 --- a/OpenXLSX/headers/XLContentTypes.hpp +++ b/OpenXLSX/headers/XLContentTypes.hpp @@ -59,7 +59,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLXmlFile.hpp" #include "XLXmlParser.hpp" diff --git a/OpenXLSX/headers/XLDateTime.hpp b/OpenXLSX/headers/XLDateTime.hpp index 27dc3ece..a7b3705f 100644 --- a/OpenXLSX/headers/XLDateTime.hpp +++ b/OpenXLSX/headers/XLDateTime.hpp @@ -56,7 +56,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLException.hpp" // ========== CLASS AND ENUM TYPE DEFINITIONS ========== // diff --git a/OpenXLSX/headers/XLDocument.hpp b/OpenXLSX/headers/XLDocument.hpp index 8136416d..c4260c94 100644 --- a/OpenXLSX/headers/XLDocument.hpp +++ b/OpenXLSX/headers/XLDocument.hpp @@ -59,7 +59,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. // ===== OpenXLSX Includes ===== // #include "IZipArchive.hpp" -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLCommandQuery.hpp" #include "XLContentTypes.hpp" #include "XLProperties.hpp" diff --git a/OpenXLSX/headers/XLException.hpp b/OpenXLSX/headers/XLException.hpp index 2987e56c..d350c4ca 100644 --- a/OpenXLSX/headers/XLException.hpp +++ b/OpenXLSX/headers/XLException.hpp @@ -57,7 +57,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // std::string - Issue #278 should be resolved by this // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" namespace OpenXLSX { diff --git a/OpenXLSX/headers/XLFormula.hpp b/OpenXLSX/headers/XLFormula.hpp index aea05233..d8463096 100644 --- a/OpenXLSX/headers/XLFormula.hpp +++ b/OpenXLSX/headers/XLFormula.hpp @@ -58,7 +58,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLXmlParser.hpp" // ========== CLASS AND ENUM TYPE DEFINITIONS ========== // diff --git a/OpenXLSX/headers/XLMergeCells.hpp b/OpenXLSX/headers/XLMergeCells.hpp index fc201e51..6dcc83b7 100644 --- a/OpenXLSX/headers/XLMergeCells.hpp +++ b/OpenXLSX/headers/XLMergeCells.hpp @@ -59,7 +59,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLCellReference.hpp" #include "XLXmlParser.hpp" // XMLNode, pugi node types diff --git a/OpenXLSX/headers/XLProperties.hpp b/OpenXLSX/headers/XLProperties.hpp index d0afa785..a6272c20 100644 --- a/OpenXLSX/headers/XLProperties.hpp +++ b/OpenXLSX/headers/XLProperties.hpp @@ -56,7 +56,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLXmlFile.hpp" namespace OpenXLSX diff --git a/OpenXLSX/headers/XLRelationships.hpp b/OpenXLSX/headers/XLRelationships.hpp index 5e998d5e..034adef4 100644 --- a/OpenXLSX/headers/XLRelationships.hpp +++ b/OpenXLSX/headers/XLRelationships.hpp @@ -58,7 +58,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLXmlFile.hpp" #include "XLXmlParser.hpp" diff --git a/OpenXLSX/headers/XLRow.hpp b/OpenXLSX/headers/XLRow.hpp index 057bfb5a..10fb9305 100644 --- a/OpenXLSX/headers/XLRow.hpp +++ b/OpenXLSX/headers/XLRow.hpp @@ -53,7 +53,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #endif // _MSC_VER // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLRowData.hpp" // ========== CLASS AND ENUM TYPE DEFINITIONS ========== // diff --git a/OpenXLSX/headers/XLRowData.hpp b/OpenXLSX/headers/XLRowData.hpp index c7f7d129..a7a9698a 100644 --- a/OpenXLSX/headers/XLRowData.hpp +++ b/OpenXLSX/headers/XLRowData.hpp @@ -19,7 +19,7 @@ #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLCell.hpp" #include "XLConstants.hpp" #include "XLException.hpp" diff --git a/OpenXLSX/headers/XLSharedStrings.hpp b/OpenXLSX/headers/XLSharedStrings.hpp index b84b2d94..b7b457b2 100644 --- a/OpenXLSX/headers/XLSharedStrings.hpp +++ b/OpenXLSX/headers/XLSharedStrings.hpp @@ -58,7 +58,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLXmlFile.hpp" namespace OpenXLSX diff --git a/OpenXLSX/headers/XLSheet.hpp b/OpenXLSX/headers/XLSheet.hpp index 47c07453..620d5b16 100644 --- a/OpenXLSX/headers/XLSheet.hpp +++ b/OpenXLSX/headers/XLSheet.hpp @@ -59,7 +59,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLCell.hpp" #include "XLCellReference.hpp" #include "XLColor.hpp" diff --git a/OpenXLSX/headers/XLStyles.hpp b/OpenXLSX/headers/XLStyles.hpp index ad803b72..5c9cc5a9 100644 --- a/OpenXLSX/headers/XLStyles.hpp +++ b/OpenXLSX/headers/XLStyles.hpp @@ -58,7 +58,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLColor.hpp" #include "XLXmlFile.hpp" #include "XLXmlParser.hpp" diff --git a/OpenXLSX/headers/XLWorkbook.hpp b/OpenXLSX/headers/XLWorkbook.hpp index 700601b1..9a7403e9 100644 --- a/OpenXLSX/headers/XLWorkbook.hpp +++ b/OpenXLSX/headers/XLWorkbook.hpp @@ -57,7 +57,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLXmlFile.hpp" namespace OpenXLSX diff --git a/OpenXLSX/headers/XLXmlData.hpp b/OpenXLSX/headers/XLXmlData.hpp index 95877389..4ff62db5 100644 --- a/OpenXLSX/headers/XLXmlData.hpp +++ b/OpenXLSX/headers/XLXmlData.hpp @@ -57,7 +57,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #include // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLContentTypes.hpp" #include "XLXmlParser.hpp" diff --git a/OpenXLSX/headers/XLXmlFile.hpp b/OpenXLSX/headers/XLXmlFile.hpp index 77012a4c..b110dcc5 100644 --- a/OpenXLSX/headers/XLXmlFile.hpp +++ b/OpenXLSX/headers/XLXmlFile.hpp @@ -53,7 +53,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #endif // _MSC_VER // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" #include "XLXmlParser.hpp" namespace OpenXLSX diff --git a/OpenXLSX/headers/XLXmlParser.hpp b/OpenXLSX/headers/XLXmlParser.hpp index b10dba27..6c81b2cc 100644 --- a/OpenXLSX/headers/XLXmlParser.hpp +++ b/OpenXLSX/headers/XLXmlParser.hpp @@ -50,7 +50,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. // ===== pugixml.hpp needed for pugi::impl::xml_memory_page_type_mask, pugi::xml_node_type, pugi::char_t, pugi::node_element, pugi::xml_node, pugi::xml_attribute, pugi::xml_document #include // not sure why the full include path is needed within the header file -#include +#include "XLException.hpp" namespace { // anonymous namespace to define constants / functions that shall not be exported from this module constexpr const int XLMaxNamespacedNameLen = 100; diff --git a/OpenXLSX/headers/XLZipArchive.hpp b/OpenXLSX/headers/XLZipArchive.hpp index fda0cec4..1e7f2ffb 100644 --- a/OpenXLSX/headers/XLZipArchive.hpp +++ b/OpenXLSX/headers/XLZipArchive.hpp @@ -53,7 +53,7 @@ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM. #endif // _MSC_VER // ===== OpenXLSX Includes ===== // -#include "OpenXLSX-Exports.hpp" +#include "include-exports-header.hpp" namespace Zippy { diff --git a/OpenXLSX/headers/include-exports-header.hpp b/OpenXLSX/headers/include-exports-header.hpp new file mode 100644 index 00000000..277d2e27 --- /dev/null +++ b/OpenXLSX/headers/include-exports-header.hpp @@ -0,0 +1,5 @@ +#ifdef OPENXLSX_CMAKE +#include "OpenXLSX-Exports.hpp" +#else +#include "swiftpm/OpenXLSX-Exports.hpp" +#endif diff --git a/OpenXLSX/module.modulemap b/OpenXLSX/module.modulemap new file mode 100644 index 00000000..e5e47681 --- /dev/null +++ b/OpenXLSX/module.modulemap @@ -0,0 +1,6 @@ +module CxxOpenXLSX { + header "OpenXLSX.hpp" + export * + requires cplusplus +} + diff --git a/OpenXLSX/swiftpm/OpenXLSX-Exports.hpp b/OpenXLSX/swiftpm/OpenXLSX-Exports.hpp new file mode 100644 index 00000000..aa562fbe --- /dev/null +++ b/OpenXLSX/swiftpm/OpenXLSX-Exports.hpp @@ -0,0 +1,42 @@ + +#ifndef OPENXLSX_EXPORT_H +#define OPENXLSX_EXPORT_H + +#ifdef OPENXLSX_STATIC_DEFINE +# define OPENXLSX_EXPORT +# define OPENXLSX_HIDDEN +#else +# ifndef OPENXLSX_EXPORT +# ifdef OpenXLSX_EXPORTS + /* We are building this library */ +# define OPENXLSX_EXPORT +# else + /* We are using this library */ +# define OPENXLSX_EXPORT +# endif +# endif + +# ifndef OPENXLSX_HIDDEN +# define OPENXLSX_HIDDEN +# endif +#endif + +#ifndef OPENXLSX_DEPRECATED +# define OPENXLSX_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef OPENXLSX_DEPRECATED_EXPORT +# define OPENXLSX_DEPRECATED_EXPORT OPENXLSX_EXPORT OPENXLSX_DEPRECATED +#endif + +#ifndef OPENXLSX_DEPRECATED_NO_EXPORT +# define OPENXLSX_DEPRECATED_NO_EXPORT OPENXLSX_HIDDEN OPENXLSX_DEPRECATED +#endif + +#if 0 /* DEFINE_NO_DEPRECATED */ +# ifndef OPENXLSX_NO_DEPRECATED +# define OPENXLSX_NO_DEPRECATED +# endif +#endif + +#endif /* OPENXLSX_EXPORT_H */ diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..37a12dd2 --- /dev/null +++ b/Package.swift @@ -0,0 +1,49 @@ +// swift-tools-version: 6.0 +import PackageDescription + +let package = Package( + name: "OpenXLSX", + products: [ + .library(name: "CxxOpenXLSX", targets: ["CxxOpenXLSX"]), + ], + targets: [ + .target( + name: "CxxOpenXLSX", + path: "OpenXLSX", + sources: [ + "sources/XLCell.cpp", + "sources/XLCellIterator.cpp", + "sources/XLCellRange.cpp", + "sources/XLCellReference.cpp", + "sources/XLCellValue.cpp", + "sources/XLColor.cpp", + "sources/XLColumn.cpp", + "sources/XLComments.cpp", + "sources/XLContentTypes.cpp", + "sources/XLDateTime.cpp", + "sources/XLDocument.cpp", + "sources/XLFormula.cpp", + "sources/XLMergeCells.cpp", + "sources/XLProperties.cpp", + "sources/XLRelationships.cpp", + "sources/XLRow.cpp", + "sources/XLRowData.cpp", + "sources/XLSharedStrings.cpp", + "sources/XLSheet.cpp", + "sources/XLStyles.cpp", + "sources/XLWorkbook.cpp", + "sources/XLXmlData.cpp", + "sources/XLXmlFile.cpp", + "sources/XLXmlParser.cpp", + "sources/XLZipArchive.cpp", + ], + publicHeadersPath: ".", + cxxSettings: [ + .headerSearchPath("headers"), + .headerSearchPath("external/pugixml"), + .headerSearchPath("external/zippy"), + ] + ), + ], + cxxLanguageStandard: .cxx17 +)