From 0958252e003160e7ddda984b1df020caf4072763 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Wed, 28 Feb 2024 17:03:59 +0100 Subject: [PATCH 01/12] Add scripts to generate wrapper and bindings for Linux and Windows --- .../generateWrapperAndBindingsLinux64.sh | 8 ++++++++ .../generateWrapperAndBindingsWin64.sh | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 AutomaticComponentToolkit/generateWrapperAndBindingsLinux64.sh create mode 100644 AutomaticComponentToolkit/generateWrapperAndBindingsWin64.sh diff --git a/AutomaticComponentToolkit/generateWrapperAndBindingsLinux64.sh b/AutomaticComponentToolkit/generateWrapperAndBindingsLinux64.sh new file mode 100644 index 000000000..4b9751618 --- /dev/null +++ b/AutomaticComponentToolkit/generateWrapperAndBindingsLinux64.sh @@ -0,0 +1,8 @@ +#!/bin/sh +./act.linux64 lib3mf.xml -bindings ../Autogenerated/Bindings -interfaces ../Autogenerated/Source -stubs ../Source/API -suppresslicense -suppressexamples +./act.linux64 lib3mf.xml -stubs ../Include/API -suppresslicense -suppressexamples -suppressbindings -suppressinterfaces + +# remove header form ../Source/API +find ../Source/API -name "*.hpp" -type f -delete +# remove cpp from ../Include/API +find ../Include/API -name "*.cpp" -type f -delete \ No newline at end of file diff --git a/AutomaticComponentToolkit/generateWrapperAndBindingsWin64.sh b/AutomaticComponentToolkit/generateWrapperAndBindingsWin64.sh new file mode 100644 index 000000000..8e12e4632 --- /dev/null +++ b/AutomaticComponentToolkit/generateWrapperAndBindingsWin64.sh @@ -0,0 +1,8 @@ +#!/bin/sh +./act.win64.exe lib3mf.xml -bindings ../Autogenerated/Bindings -interfaces ../Autogenerated/Source -stubs ../Source/API -suppresslicense -suppressexamples +./act.win64.exe lib3mf.xml -stubs ../Include/API -suppresslicense -suppressexamples -suppressbindings -suppressinterfaces + +# remove header form ../Source/API +find ../Source/API -name "*.hpp" -type f -delete +# remove cpp from ../Include/API +find ../Include/API -name "*.cpp" -type f -delete \ No newline at end of file From 1b9987c568236331c857fe29b89f0adb72cae664 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Wed, 28 Feb 2024 17:05:13 +0100 Subject: [PATCH 02/12] Add .vs to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a41019361..ace3d8651 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ Include/Model/COM/NMR_COMVersion.h debug .DS_Store .vscode +.vs From c7246e06510e3995aa403fa6c6609f8ba3adf185 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:20:56 +0100 Subject: [PATCH 03/12] [API] Introducing GetRequiredNameSpaces (not implemented yet) --- Autogenerated/Bindings/C/lib3mf.h | 57 ++++- Autogenerated/Bindings/C/lib3mf_types.h | 1 + .../Bindings/CDynamic/lib3mf_dynamic.cc | 50 +++++ .../Bindings/CDynamic/lib3mf_dynamic.h | 62 +++++- .../Bindings/CDynamic/lib3mf_types.h | 1 + Autogenerated/Bindings/CSharp/Lib3MF.cs | 70 ++++++ Autogenerated/Bindings/Cpp/lib3mf_abi.hpp | 57 ++++- .../Bindings/Cpp/lib3mf_implicit.hpp | 103 ++++++++- Autogenerated/Bindings/Cpp/lib3mf_types.hpp | 1 + .../Bindings/CppDynamic/lib3mf_dynamic.h | 62 +++++- .../Bindings/CppDynamic/lib3mf_dynamic.hpp | 173 ++++++++++++++- .../Bindings/CppDynamic/lib3mf_types.hpp | 1 + Autogenerated/Bindings/Go/lib3mf.go | 118 +++++++++- Autogenerated/Bindings/Go/lib3mf_dynamic.cc | 50 +++++ Autogenerated/Bindings/Go/lib3mf_dynamic.h | 62 +++++- Autogenerated/Bindings/Go/lib3mf_types.h | 1 + .../Bindings/NodeJS/lib3mf_dynamic.cc | 50 +++++ .../Bindings/NodeJS/lib3mf_dynamic.h | 62 +++++- .../Bindings/NodeJS/lib3mf_nodeaddon.cc | 1 + .../Bindings/NodeJS/lib3mf_nodewrapper.cc | 177 +++++++++++++++ .../Bindings/NodeJS/lib3mf_nodewrapper.h | 22 ++ Autogenerated/Bindings/NodeJS/lib3mf_types.h | 1 + Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas | 173 ++++++++++++++- Autogenerated/Bindings/Python/Lib3MF.py | 98 +++++++++ Autogenerated/Source/lib3mf_abi.hpp | 57 ++++- Autogenerated/Source/lib3mf_interfaces.hpp | 57 ++++- .../Source/lib3mf_interfacewrapper.cpp | 208 ++++++++++++++++++ Autogenerated/Source/lib3mf_types.hpp | 1 + AutomaticComponentToolkit/lib3mf.xml | 19 ++ Include/API/lib3mf_model.hpp | 7 +- Include/API/lib3mf_namespaceiterator.hpp | 111 ++++++++++ Source/API/lib3mf_model.cpp | 49 +++-- Source/API/lib3mf_namespaceiterator.cpp | 62 ++++++ Source/CMakeLists.txt | 1 + Tests/googletest | 2 +- 35 files changed, 1972 insertions(+), 55 deletions(-) create mode 100644 Include/API/lib3mf_namespaceiterator.hpp create mode 100644 Source/API/lib3mf_namespaceiterator.cpp diff --git a/Autogenerated/Bindings/C/lib3mf.h b/Autogenerated/Bindings/C/lib3mf.h index b287ecd36..c7405f51c 100644 --- a/Autogenerated/Bindings/C/lib3mf.h +++ b/Autogenerated/Bindings/C/lib3mf.h @@ -2047,7 +2047,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_setrelationshiptype(Lib3MF_Attach LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetofile(Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2056,7 +2056,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetofile(Lib3MF_Attachment pAt LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_readfromfile(Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads a model and from the data provided by a callback function +* Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2088,7 +2088,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_getstreamsize(Lib3MF_Attachment p LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetobuffer(Lib3MF_Attachment pAttachment, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); /** -* Reads an attachment from a memory buffer +* Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferBufferSize - Number of elements in buffer @@ -2954,6 +2954,48 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getuuid(Lib3MF_KeyStore pKeyStore, */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_setuuid(Lib3MF_KeyStore pKeyStore, const char * pUUID); +/************************************************************************************************************************* + Class definition for NameSpaceIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasNext - Iterates to the namespace in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_movenext(Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext); + +/** +* Iterates to the previous namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasPrevious - Iterates to the previous required namespace in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_moveprevious(Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious); + +/** +* Returns the required namespace the iterator points at. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of returns the namespace., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_getcurrent(Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + +/** +* Returns the number of namespaces the iterator captures. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pCount - returns the number of namspaces the iterator captures. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_count(Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount); + /************************************************************************************************************************* Class definition for Model **************************************************************************************************************************/ @@ -3528,6 +3570,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_setrandomnumbercallback(Lib3MF_Model p */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getkeystore(Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); +/** +* Gets the list of required namespaces for the model +* +* @param[in] pModel - Model instance. +* @param[out] pNameSpaceIterator - The required namespace iterator +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getrequirednamespaces(Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/C/lib3mf_types.h b/Autogenerated/Bindings/C/lib3mf_types.h index b4059ad3f..6747467de 100644 --- a/Autogenerated/Bindings/C/lib3mf_types.h +++ b/Autogenerated/Bindings/C/lib3mf_types.h @@ -237,6 +237,7 @@ typedef Lib3MFHandle Lib3MF_ContentEncryptionParams; typedef Lib3MFHandle Lib3MF_ResourceData; typedef Lib3MFHandle Lib3MF_ResourceDataGroup; typedef Lib3MFHandle Lib3MF_KeyStore; +typedef Lib3MFHandle Lib3MF_NameSpaceIterator; typedef Lib3MFHandle Lib3MF_Model; /************************************************************************************************************************* diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc index 967ef1f16..c420d8064 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc @@ -328,6 +328,10 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_KeyStore_GetResourceData = NULL; pWrapperTable->m_KeyStore_GetUUID = NULL; pWrapperTable->m_KeyStore_SetUUID = NULL; + pWrapperTable->m_NameSpaceIterator_MoveNext = NULL; + pWrapperTable->m_NameSpaceIterator_MovePrevious = NULL; + pWrapperTable->m_NameSpaceIterator_GetCurrent = NULL; + pWrapperTable->m_NameSpaceIterator_Count = NULL; pWrapperTable->m_Model_RootModelPart = NULL; pWrapperTable->m_Model_FindOrCreatePackagePart = NULL; pWrapperTable->m_Model_SetUnit = NULL; @@ -388,6 +392,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_RemoveCustomContentType = NULL; pWrapperTable->m_Model_SetRandomNumberCallback = NULL; pWrapperTable->m_Model_GetKeyStore = NULL; + pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -2981,6 +2986,42 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_KeyStore_SetUUID == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_MoveNext = (PLib3MFNameSpaceIterator_MoveNextPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_movenext"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_MoveNext = (PLib3MFNameSpaceIterator_MoveNextPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_movenext"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_MoveNext == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_MovePrevious = (PLib3MFNameSpaceIterator_MovePreviousPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_moveprevious"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_MovePrevious = (PLib3MFNameSpaceIterator_MovePreviousPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_moveprevious"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_MovePrevious == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_GetCurrent = (PLib3MFNameSpaceIterator_GetCurrentPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_getcurrent"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_GetCurrent = (PLib3MFNameSpaceIterator_GetCurrentPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_getcurrent"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_GetCurrent == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_Count = (PLib3MFNameSpaceIterator_CountPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_count"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_Count = (PLib3MFNameSpaceIterator_CountPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_count"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_Count == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Model_RootModelPart = (PLib3MFModel_RootModelPartPtr) GetProcAddress(hLibrary, "lib3mf_model_rootmodelpart"); #else // _WIN32 @@ -3521,6 +3562,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_GetKeyStore == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) GetProcAddress(hLibrary, "lib3mf_model_getrequirednamespaces"); + #else // _WIN32 + pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) dlsym(hLibrary, "lib3mf_model_getrequirednamespaces"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Model_GetRequiredNameSpaces == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_GetLibraryVersion = (PLib3MFGetLibraryVersionPtr) GetProcAddress(hLibrary, "lib3mf_getlibraryversion"); #else // _WIN32 diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h index c92306d14..e9bccb264 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h @@ -2034,7 +2034,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_SetRelationShipTypePtr) (Lib3MF_Attachm typedef Lib3MFResult (*PLib3MFAttachment_WriteToFilePtr) (Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2043,7 +2043,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_WriteToFilePtr) (Lib3MF_Attachment pAtt typedef Lib3MFResult (*PLib3MFAttachment_ReadFromFilePtr) (Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads a model and from the data provided by a callback function +* Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2075,7 +2075,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_GetStreamSizePtr) (Lib3MF_Attachment pA typedef Lib3MFResult (*PLib3MFAttachment_WriteToBufferPtr) (Lib3MF_Attachment pAttachment, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); /** -* Reads an attachment from a memory buffer +* Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferBufferSize - Number of elements in buffer @@ -2941,6 +2941,48 @@ typedef Lib3MFResult (*PLib3MFKeyStore_GetUUIDPtr) (Lib3MF_KeyStore pKeyStore, b */ typedef Lib3MFResult (*PLib3MFKeyStore_SetUUIDPtr) (Lib3MF_KeyStore pKeyStore, const char * pUUID); +/************************************************************************************************************************* + Class definition for NameSpaceIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasNext - Iterates to the namespace in the list. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_MoveNextPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext); + +/** +* Iterates to the previous namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasPrevious - Iterates to the previous required namespace in the list. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_MovePreviousPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious); + +/** +* Returns the required namespace the iterator points at. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of returns the namespace., may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_GetCurrentPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + +/** +* Returns the number of namespaces the iterator captures. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pCount - returns the number of namspaces the iterator captures. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_CountPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount); + /************************************************************************************************************************* Class definition for Model **************************************************************************************************************************/ @@ -3515,6 +3557,15 @@ typedef Lib3MFResult (*PLib3MFModel_SetRandomNumberCallbackPtr) (Lib3MF_Model pM */ typedef Lib3MFResult (*PLib3MFModel_GetKeyStorePtr) (Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); +/** +* Gets the list of required namespaces for the model +* +* @param[in] pModel - Model instance. +* @param[out] pNameSpaceIterator - The required namespace iterator +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFModel_GetRequiredNameSpacesPtr) (Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -3999,6 +4050,10 @@ typedef struct { PLib3MFKeyStore_GetResourceDataPtr m_KeyStore_GetResourceData; PLib3MFKeyStore_GetUUIDPtr m_KeyStore_GetUUID; PLib3MFKeyStore_SetUUIDPtr m_KeyStore_SetUUID; + PLib3MFNameSpaceIterator_MoveNextPtr m_NameSpaceIterator_MoveNext; + PLib3MFNameSpaceIterator_MovePreviousPtr m_NameSpaceIterator_MovePrevious; + PLib3MFNameSpaceIterator_GetCurrentPtr m_NameSpaceIterator_GetCurrent; + PLib3MFNameSpaceIterator_CountPtr m_NameSpaceIterator_Count; PLib3MFModel_RootModelPartPtr m_Model_RootModelPart; PLib3MFModel_FindOrCreatePackagePartPtr m_Model_FindOrCreatePackagePart; PLib3MFModel_SetUnitPtr m_Model_SetUnit; @@ -4059,6 +4114,7 @@ typedef struct { PLib3MFModel_RemoveCustomContentTypePtr m_Model_RemoveCustomContentType; PLib3MFModel_SetRandomNumberCallbackPtr m_Model_SetRandomNumberCallback; PLib3MFModel_GetKeyStorePtr m_Model_GetKeyStore; + PLib3MFModel_GetRequiredNameSpacesPtr m_Model_GetRequiredNameSpaces; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_types.h b/Autogenerated/Bindings/CDynamic/lib3mf_types.h index b4059ad3f..6747467de 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_types.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_types.h @@ -237,6 +237,7 @@ typedef Lib3MFHandle Lib3MF_ContentEncryptionParams; typedef Lib3MFHandle Lib3MF_ResourceData; typedef Lib3MFHandle Lib3MF_ResourceDataGroup; typedef Lib3MFHandle Lib3MF_KeyStore; +typedef Lib3MFHandle Lib3MF_NameSpaceIterator; typedef Lib3MFHandle Lib3MF_Model; /************************************************************************************************************************* diff --git a/Autogenerated/Bindings/CSharp/Lib3MF.cs b/Autogenerated/Bindings/CSharp/Lib3MF.cs index 1addacc92..fb4ce5c01 100644 --- a/Autogenerated/Bindings/CSharp/Lib3MF.cs +++ b/Autogenerated/Bindings/CSharp/Lib3MF.cs @@ -1165,6 +1165,18 @@ public class Lib3MFWrapper [DllImport("lib3mf.dll", EntryPoint = "lib3mf_keystore_setuuid", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 KeyStore_SetUUID (IntPtr Handle, byte[] AUUID); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_namespaceiterator_movenext", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 NameSpaceIterator_MoveNext (IntPtr Handle, out Byte AHasNext); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_namespaceiterator_moveprevious", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 NameSpaceIterator_MovePrevious (IntPtr Handle, out Byte AHasPrevious); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_namespaceiterator_getcurrent", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 NameSpaceIterator_GetCurrent (IntPtr Handle, UInt32 sizeNameSpace, out UInt32 neededNameSpace, IntPtr dataNameSpace); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_namespaceiterator_count", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 NameSpaceIterator_Count (IntPtr Handle, out UInt64 ACount); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_model_rootmodelpart", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 Model_RootModelPart (IntPtr Handle, out IntPtr ARootModelPart); @@ -1345,6 +1357,9 @@ public class Lib3MFWrapper [DllImport("lib3mf.dll", EntryPoint = "lib3mf_model_getkeystore", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 Model_GetKeyStore (IntPtr Handle, out IntPtr AKeyStore); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_model_getrequirednamespaces", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 Model_GetRequiredNameSpaces (IntPtr Handle, out IntPtr ANameSpaceIterator); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_getlibraryversion", CharSet = CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)] public extern static Int32 GetLibraryVersion (out UInt32 AMajor, out UInt32 AMinor, out UInt32 AMicro); @@ -1751,6 +1766,7 @@ public static T PolymorphicFactory(IntPtr Handle) where T : class case 0x1A47A5E258E22EF9: Object = new CResourceData(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceData" case 0xD59067227E428AA4: Object = new CResourceDataGroup(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceDataGroup" case 0x1CC9E0CC082253C6: Object = new CKeyStore(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::KeyStore" + case 0x8D1206A0FEEFCC31: Object = new CNameSpaceIterator(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::NameSpaceIterator" case 0x5A8164ECEDB03F09: Object = new CModel(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::Model" default: Object = System.Activator.CreateInstance(typeof(T), Handle) as T; break; } @@ -4664,6 +4680,52 @@ public void SetUUID (String AUUID) } + public class CNameSpaceIterator : CBase + { + public CNameSpaceIterator (IntPtr NewHandle) : base (NewHandle) + { + } + + public bool MoveNext () + { + Byte resultHasNext = 0; + + CheckError(Internal.Lib3MFWrapper.NameSpaceIterator_MoveNext (Handle, out resultHasNext)); + return (resultHasNext != 0); + } + + public bool MovePrevious () + { + Byte resultHasPrevious = 0; + + CheckError(Internal.Lib3MFWrapper.NameSpaceIterator_MovePrevious (Handle, out resultHasPrevious)); + return (resultHasPrevious != 0); + } + + public String GetCurrent () + { + UInt32 sizeNameSpace = 0; + UInt32 neededNameSpace = 0; + CheckError(Internal.Lib3MFWrapper.NameSpaceIterator_GetCurrent (Handle, sizeNameSpace, out neededNameSpace, IntPtr.Zero)); + sizeNameSpace = neededNameSpace; + byte[] bytesNameSpace = new byte[sizeNameSpace]; + GCHandle dataNameSpace = GCHandle.Alloc(bytesNameSpace, GCHandleType.Pinned); + + CheckError(Internal.Lib3MFWrapper.NameSpaceIterator_GetCurrent (Handle, sizeNameSpace, out neededNameSpace, dataNameSpace.AddrOfPinnedObject())); + dataNameSpace.Free(); + return Encoding.UTF8.GetString(bytesNameSpace).TrimEnd(char.MinValue); + } + + public UInt64 Count () + { + UInt64 resultCount = 0; + + CheckError(Internal.Lib3MFWrapper.NameSpaceIterator_Count (Handle, out resultCount)); + return resultCount; + } + + } + public class CModel : CBase { public CModel (IntPtr NewHandle) : base (NewHandle) @@ -5177,6 +5239,14 @@ public CKeyStore GetKeyStore () return Internal.Lib3MFWrapper.PolymorphicFactory(newKeyStore); } + public CNameSpaceIterator GetRequiredNameSpaces () + { + IntPtr newNameSpaceIterator = IntPtr.Zero; + + CheckError(Internal.Lib3MFWrapper.Model_GetRequiredNameSpaces (Handle, out newNameSpaceIterator)); + return Internal.Lib3MFWrapper.PolymorphicFactory(newNameSpaceIterator); + } + } class Wrapper diff --git a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp index 455bd3225..7e493f3f2 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp @@ -2047,7 +2047,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_setrelationshiptype(Lib3MF_Attach LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetofile(Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2056,7 +2056,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetofile(Lib3MF_Attachment pAt LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_readfromfile(Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads a model and from the data provided by a callback function +* Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2088,7 +2088,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_getstreamsize(Lib3MF_Attachment p LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetobuffer(Lib3MF_Attachment pAttachment, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); /** -* Reads an attachment from a memory buffer +* Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferBufferSize - Number of elements in buffer @@ -2954,6 +2954,48 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getuuid(Lib3MF_KeyStore pKeyStore, */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_setuuid(Lib3MF_KeyStore pKeyStore, const char * pUUID); +/************************************************************************************************************************* + Class definition for NameSpaceIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasNext - Iterates to the namespace in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_movenext(Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext); + +/** +* Iterates to the previous namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasPrevious - Iterates to the previous required namespace in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_moveprevious(Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious); + +/** +* Returns the required namespace the iterator points at. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of returns the namespace., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_getcurrent(Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + +/** +* Returns the number of namespaces the iterator captures. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pCount - returns the number of namspaces the iterator captures. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_count(Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount); + /************************************************************************************************************************* Class definition for Model **************************************************************************************************************************/ @@ -3528,6 +3570,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_setrandomnumbercallback(Lib3MF_Model p */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getkeystore(Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); +/** +* Gets the list of required namespaces for the model +* +* @param[in] pModel - Model instance. +* @param[out] pNameSpaceIterator - The required namespace iterator +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getrequirednamespaces(Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp index dcd87726d..decb1ee71 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp @@ -98,6 +98,7 @@ class CContentEncryptionParams; class CResourceData; class CResourceDataGroup; class CKeyStore; +class CNameSpaceIterator; class CModel; /************************************************************************************************************************* @@ -145,6 +146,7 @@ typedef CContentEncryptionParams CLib3MFContentEncryptionParams; typedef CResourceData CLib3MFResourceData; typedef CResourceDataGroup CLib3MFResourceDataGroup; typedef CKeyStore CLib3MFKeyStore; +typedef CNameSpaceIterator CLib3MFNameSpaceIterator; typedef CModel CLib3MFModel; /************************************************************************************************************************* @@ -192,6 +194,7 @@ typedef std::shared_ptr PContentEncryptionParams; typedef std::shared_ptr PResourceData; typedef std::shared_ptr PResourceDataGroup; typedef std::shared_ptr PKeyStore; +typedef std::shared_ptr PNameSpaceIterator; typedef std::shared_ptr PModel; /************************************************************************************************************************* @@ -239,6 +242,7 @@ typedef PContentEncryptionParams PLib3MFContentEncryptionParams; typedef PResourceData PLib3MFResourceData; typedef PResourceDataGroup PLib3MFResourceDataGroup; typedef PKeyStore PLib3MFKeyStore; +typedef PNameSpaceIterator PLib3MFNameSpaceIterator; typedef PModel PLib3MFModel; @@ -562,6 +566,7 @@ class CWrapper { friend class CResourceData; friend class CResourceDataGroup; friend class CKeyStore; + friend class CNameSpaceIterator; friend class CModel; }; @@ -1543,6 +1548,26 @@ class CKeyStore : public CBase { inline void SetUUID(const std::string & sUUID); }; +/************************************************************************************************************************* + Class CNameSpaceIterator +**************************************************************************************************************************/ +class CNameSpaceIterator : public CBase { +public: + + /** + * CNameSpaceIterator::CNameSpaceIterator - Constructor for NameSpaceIterator class. + */ + CNameSpaceIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline bool MoveNext(); + inline bool MovePrevious(); + inline std::string GetCurrent(); + inline Lib3MF_uint64 Count(); +}; + /************************************************************************************************************************* Class CModel **************************************************************************************************************************/ @@ -1617,6 +1642,7 @@ class CModel : public CBase { inline void RemoveCustomContentType(const std::string & sExtension); inline void SetRandomNumberCallback(const RandomNumberCallback pTheCallback, const Lib3MF_pvoid pUserData); inline PKeyStore GetKeyStore(); + inline PNameSpaceIterator GetRequiredNameSpaces(); }; /************************************************************************************************************************* @@ -1676,6 +1702,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) case 0x1A47A5E258E22EF9UL: return new CResourceData(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceData" case 0xD59067227E428AA4UL: return new CResourceDataGroup(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceDataGroup" case 0x1CC9E0CC082253C6UL: return new CKeyStore(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::KeyStore" + case 0x8D1206A0FEEFCC31UL: return new CNameSpaceIterator(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::NameSpaceIterator" case 0x5A8164ECEDB03F09UL: return new CModel(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::Model" } return new CBase(this, pHandle); @@ -4396,7 +4423,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CAttachment::ReadFromFile - Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. + * CAttachment::ReadFromFile - Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * @param[in] sFileName - file to read from. */ void CAttachment::ReadFromFile(const std::string & sFileName) @@ -4405,7 +4432,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CAttachment::ReadFromCallback - Reads a model and from the data provided by a callback function + * CAttachment::ReadFromCallback - Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * @param[in] pTheReadCallback - Callback to call for reading a data chunk * @param[in] nStreamSize - number of bytes the callback returns * @param[in] pTheSeekCallback - Callback to call for seeking in the stream. @@ -4442,7 +4469,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CAttachment::ReadFromBuffer - Reads an attachment from a memory buffer + * CAttachment::ReadFromBuffer - Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * @param[in] BufferBuffer - Buffer to read from */ void CAttachment::ReadFromBuffer(const CInputVector & BufferBuffer) @@ -5575,6 +5602,61 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) CheckError(lib3mf_keystore_setuuid(m_pHandle, sUUID.c_str())); } + /** + * Method definitions for class CNameSpaceIterator + */ + + /** + * CNameSpaceIterator::MoveNext - Iterates to the next namespace in the list. + * @return Iterates to the namespace in the list. + */ + bool CNameSpaceIterator::MoveNext() + { + bool resultHasNext = 0; + CheckError(lib3mf_namespaceiterator_movenext(m_pHandle, &resultHasNext)); + + return resultHasNext; + } + + /** + * CNameSpaceIterator::MovePrevious - Iterates to the previous namespace in the list. + * @return Iterates to the previous required namespace in the list. + */ + bool CNameSpaceIterator::MovePrevious() + { + bool resultHasPrevious = 0; + CheckError(lib3mf_namespaceiterator_moveprevious(m_pHandle, &resultHasPrevious)); + + return resultHasPrevious; + } + + /** + * CNameSpaceIterator::GetCurrent - Returns the required namespace the iterator points at. + * @return returns the namespace. + */ + std::string CNameSpaceIterator::GetCurrent() + { + Lib3MF_uint32 bytesNeededNameSpace = 0; + Lib3MF_uint32 bytesWrittenNameSpace = 0; + CheckError(lib3mf_namespaceiterator_getcurrent(m_pHandle, 0, &bytesNeededNameSpace, nullptr)); + std::vector bufferNameSpace(bytesNeededNameSpace); + CheckError(lib3mf_namespaceiterator_getcurrent(m_pHandle, bytesNeededNameSpace, &bytesWrittenNameSpace, &bufferNameSpace[0])); + + return std::string(&bufferNameSpace[0]); + } + + /** + * CNameSpaceIterator::Count - Returns the number of namespaces the iterator captures. + * @return returns the number of namspaces the iterator captures. + */ + Lib3MF_uint64 CNameSpaceIterator::Count() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_namespaceiterator_count(m_pHandle, &resultCount)); + + return resultCount; + } + /** * Method definitions for class CModel */ @@ -6442,6 +6524,21 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hKeyStore))); } + + /** + * CModel::GetRequiredNameSpaces - Gets the list of required namespaces for the model + * @return The required namespace iterator + */ + PNameSpaceIterator CModel::GetRequiredNameSpaces() + { + Lib3MFHandle hNameSpaceIterator = nullptr; + CheckError(lib3mf_model_getrequirednamespaces(m_pHandle, &hNameSpaceIterator)); + + if (!hNameSpaceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hNameSpaceIterator))); + } } // namespace Lib3MF diff --git a/Autogenerated/Bindings/Cpp/lib3mf_types.hpp b/Autogenerated/Bindings/Cpp/lib3mf_types.hpp index e9c0bdad5..5f3f9b44e 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_types.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_types.hpp @@ -236,6 +236,7 @@ typedef Lib3MFHandle Lib3MF_ContentEncryptionParams; typedef Lib3MFHandle Lib3MF_ResourceData; typedef Lib3MFHandle Lib3MF_ResourceDataGroup; typedef Lib3MFHandle Lib3MF_KeyStore; +typedef Lib3MFHandle Lib3MF_NameSpaceIterator; typedef Lib3MFHandle Lib3MF_Model; namespace Lib3MF { diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h index 016b3c496..87889d340 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h @@ -2034,7 +2034,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_SetRelationShipTypePtr) (Lib3MF_Attachm typedef Lib3MFResult (*PLib3MFAttachment_WriteToFilePtr) (Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2043,7 +2043,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_WriteToFilePtr) (Lib3MF_Attachment pAtt typedef Lib3MFResult (*PLib3MFAttachment_ReadFromFilePtr) (Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads a model and from the data provided by a callback function +* Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2075,7 +2075,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_GetStreamSizePtr) (Lib3MF_Attachment pA typedef Lib3MFResult (*PLib3MFAttachment_WriteToBufferPtr) (Lib3MF_Attachment pAttachment, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); /** -* Reads an attachment from a memory buffer +* Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferBufferSize - Number of elements in buffer @@ -2941,6 +2941,48 @@ typedef Lib3MFResult (*PLib3MFKeyStore_GetUUIDPtr) (Lib3MF_KeyStore pKeyStore, b */ typedef Lib3MFResult (*PLib3MFKeyStore_SetUUIDPtr) (Lib3MF_KeyStore pKeyStore, const char * pUUID); +/************************************************************************************************************************* + Class definition for NameSpaceIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasNext - Iterates to the namespace in the list. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_MoveNextPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext); + +/** +* Iterates to the previous namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasPrevious - Iterates to the previous required namespace in the list. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_MovePreviousPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious); + +/** +* Returns the required namespace the iterator points at. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of returns the namespace., may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_GetCurrentPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + +/** +* Returns the number of namespaces the iterator captures. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pCount - returns the number of namspaces the iterator captures. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_CountPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount); + /************************************************************************************************************************* Class definition for Model **************************************************************************************************************************/ @@ -3515,6 +3557,15 @@ typedef Lib3MFResult (*PLib3MFModel_SetRandomNumberCallbackPtr) (Lib3MF_Model pM */ typedef Lib3MFResult (*PLib3MFModel_GetKeyStorePtr) (Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); +/** +* Gets the list of required namespaces for the model +* +* @param[in] pModel - Model instance. +* @param[out] pNameSpaceIterator - The required namespace iterator +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFModel_GetRequiredNameSpacesPtr) (Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -3999,6 +4050,10 @@ typedef struct { PLib3MFKeyStore_GetResourceDataPtr m_KeyStore_GetResourceData; PLib3MFKeyStore_GetUUIDPtr m_KeyStore_GetUUID; PLib3MFKeyStore_SetUUIDPtr m_KeyStore_SetUUID; + PLib3MFNameSpaceIterator_MoveNextPtr m_NameSpaceIterator_MoveNext; + PLib3MFNameSpaceIterator_MovePreviousPtr m_NameSpaceIterator_MovePrevious; + PLib3MFNameSpaceIterator_GetCurrentPtr m_NameSpaceIterator_GetCurrent; + PLib3MFNameSpaceIterator_CountPtr m_NameSpaceIterator_Count; PLib3MFModel_RootModelPartPtr m_Model_RootModelPart; PLib3MFModel_FindOrCreatePackagePartPtr m_Model_FindOrCreatePackagePart; PLib3MFModel_SetUnitPtr m_Model_SetUnit; @@ -4059,6 +4114,7 @@ typedef struct { PLib3MFModel_RemoveCustomContentTypePtr m_Model_RemoveCustomContentType; PLib3MFModel_SetRandomNumberCallbackPtr m_Model_SetRandomNumberCallback; PLib3MFModel_GetKeyStorePtr m_Model_GetKeyStore; + PLib3MFModel_GetRequiredNameSpacesPtr m_Model_GetRequiredNameSpaces; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp index d3da42c55..24eecc8cc 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp @@ -98,6 +98,7 @@ class CContentEncryptionParams; class CResourceData; class CResourceDataGroup; class CKeyStore; +class CNameSpaceIterator; class CModel; /************************************************************************************************************************* @@ -145,6 +146,7 @@ typedef CContentEncryptionParams CLib3MFContentEncryptionParams; typedef CResourceData CLib3MFResourceData; typedef CResourceDataGroup CLib3MFResourceDataGroup; typedef CKeyStore CLib3MFKeyStore; +typedef CNameSpaceIterator CLib3MFNameSpaceIterator; typedef CModel CLib3MFModel; /************************************************************************************************************************* @@ -192,6 +194,7 @@ typedef std::shared_ptr PContentEncryptionParams; typedef std::shared_ptr PResourceData; typedef std::shared_ptr PResourceDataGroup; typedef std::shared_ptr PKeyStore; +typedef std::shared_ptr PNameSpaceIterator; typedef std::shared_ptr PModel; /************************************************************************************************************************* @@ -239,6 +242,7 @@ typedef PContentEncryptionParams PLib3MFContentEncryptionParams; typedef PResourceData PLib3MFResourceData; typedef PResourceDataGroup PLib3MFResourceDataGroup; typedef PKeyStore PLib3MFKeyStore; +typedef PNameSpaceIterator PLib3MFNameSpaceIterator; typedef PModel PLib3MFModel; @@ -586,6 +590,7 @@ class CWrapper { friend class CResourceData; friend class CResourceDataGroup; friend class CKeyStore; + friend class CNameSpaceIterator; friend class CModel; }; @@ -1567,6 +1572,26 @@ class CKeyStore : public CBase { inline void SetUUID(const std::string & sUUID); }; +/************************************************************************************************************************* + Class CNameSpaceIterator +**************************************************************************************************************************/ +class CNameSpaceIterator : public CBase { +public: + + /** + * CNameSpaceIterator::CNameSpaceIterator - Constructor for NameSpaceIterator class. + */ + CNameSpaceIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline bool MoveNext(); + inline bool MovePrevious(); + inline std::string GetCurrent(); + inline Lib3MF_uint64 Count(); +}; + /************************************************************************************************************************* Class CModel **************************************************************************************************************************/ @@ -1641,6 +1666,7 @@ class CModel : public CBase { inline void RemoveCustomContentType(const std::string & sExtension); inline void SetRandomNumberCallback(const RandomNumberCallback pTheCallback, const Lib3MF_pvoid pUserData); inline PKeyStore GetKeyStore(); + inline PNameSpaceIterator GetRequiredNameSpaces(); }; /************************************************************************************************************************* @@ -1700,6 +1726,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) case 0x1A47A5E258E22EF9UL: return new CResourceData(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceData" case 0xD59067227E428AA4UL: return new CResourceDataGroup(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceDataGroup" case 0x1CC9E0CC082253C6UL: return new CKeyStore(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::KeyStore" + case 0x8D1206A0FEEFCC31UL: return new CNameSpaceIterator(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::NameSpaceIterator" case 0x5A8164ECEDB03F09UL: return new CModel(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::Model" } return new CBase(this, pHandle); @@ -2267,6 +2294,10 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) pWrapperTable->m_KeyStore_GetResourceData = nullptr; pWrapperTable->m_KeyStore_GetUUID = nullptr; pWrapperTable->m_KeyStore_SetUUID = nullptr; + pWrapperTable->m_NameSpaceIterator_MoveNext = nullptr; + pWrapperTable->m_NameSpaceIterator_MovePrevious = nullptr; + pWrapperTable->m_NameSpaceIterator_GetCurrent = nullptr; + pWrapperTable->m_NameSpaceIterator_Count = nullptr; pWrapperTable->m_Model_RootModelPart = nullptr; pWrapperTable->m_Model_FindOrCreatePackagePart = nullptr; pWrapperTable->m_Model_SetUnit = nullptr; @@ -2327,6 +2358,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) pWrapperTable->m_Model_RemoveCustomContentType = nullptr; pWrapperTable->m_Model_SetRandomNumberCallback = nullptr; pWrapperTable->m_Model_GetKeyStore = nullptr; + pWrapperTable->m_Model_GetRequiredNameSpaces = nullptr; pWrapperTable->m_GetLibraryVersion = nullptr; pWrapperTable->m_GetPrereleaseInformation = nullptr; pWrapperTable->m_GetBuildInformation = nullptr; @@ -4916,6 +4948,42 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if (pWrapperTable->m_KeyStore_SetUUID == nullptr) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_MoveNext = (PLib3MFNameSpaceIterator_MoveNextPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_movenext"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_MoveNext = (PLib3MFNameSpaceIterator_MoveNextPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_movenext"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_MoveNext == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_MovePrevious = (PLib3MFNameSpaceIterator_MovePreviousPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_moveprevious"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_MovePrevious = (PLib3MFNameSpaceIterator_MovePreviousPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_moveprevious"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_MovePrevious == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_GetCurrent = (PLib3MFNameSpaceIterator_GetCurrentPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_getcurrent"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_GetCurrent = (PLib3MFNameSpaceIterator_GetCurrentPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_getcurrent"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_GetCurrent == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_Count = (PLib3MFNameSpaceIterator_CountPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_count"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_Count = (PLib3MFNameSpaceIterator_CountPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_count"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_Count == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Model_RootModelPart = (PLib3MFModel_RootModelPartPtr) GetProcAddress(hLibrary, "lib3mf_model_rootmodelpart"); #else // _WIN32 @@ -5456,6 +5524,15 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if (pWrapperTable->m_Model_GetKeyStore == nullptr) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) GetProcAddress(hLibrary, "lib3mf_model_getrequirednamespaces"); + #else // _WIN32 + pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) dlsym(hLibrary, "lib3mf_model_getrequirednamespaces"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Model_GetRequiredNameSpaces == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_GetLibraryVersion = (PLib3MFGetLibraryVersionPtr) GetProcAddress(hLibrary, "lib3mf_getlibraryversion"); #else // _WIN32 @@ -6763,6 +6840,22 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if ( (eLookupError != 0) || (pWrapperTable->m_KeyStore_SetUUID == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_namespaceiterator_movenext", (void**)&(pWrapperTable->m_NameSpaceIterator_MoveNext)); + if ( (eLookupError != 0) || (pWrapperTable->m_NameSpaceIterator_MoveNext == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_namespaceiterator_moveprevious", (void**)&(pWrapperTable->m_NameSpaceIterator_MovePrevious)); + if ( (eLookupError != 0) || (pWrapperTable->m_NameSpaceIterator_MovePrevious == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_namespaceiterator_getcurrent", (void**)&(pWrapperTable->m_NameSpaceIterator_GetCurrent)); + if ( (eLookupError != 0) || (pWrapperTable->m_NameSpaceIterator_GetCurrent == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_namespaceiterator_count", (void**)&(pWrapperTable->m_NameSpaceIterator_Count)); + if ( (eLookupError != 0) || (pWrapperTable->m_NameSpaceIterator_Count == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_model_rootmodelpart", (void**)&(pWrapperTable->m_Model_RootModelPart)); if ( (eLookupError != 0) || (pWrapperTable->m_Model_RootModelPart == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -7003,6 +7096,10 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if ( (eLookupError != 0) || (pWrapperTable->m_Model_GetKeyStore == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_model_getrequirednamespaces", (void**)&(pWrapperTable->m_Model_GetRequiredNameSpaces)); + if ( (eLookupError != 0) || (pWrapperTable->m_Model_GetRequiredNameSpaces == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_getlibraryversion", (void**)&(pWrapperTable->m_GetLibraryVersion)); if ( (eLookupError != 0) || (pWrapperTable->m_GetLibraryVersion == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -9522,7 +9619,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CAttachment::ReadFromFile - Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. + * CAttachment::ReadFromFile - Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * @param[in] sFileName - file to read from. */ void CAttachment::ReadFromFile(const std::string & sFileName) @@ -9531,7 +9628,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CAttachment::ReadFromCallback - Reads a model and from the data provided by a callback function + * CAttachment::ReadFromCallback - Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * @param[in] pTheReadCallback - Callback to call for reading a data chunk * @param[in] nStreamSize - number of bytes the callback returns * @param[in] pTheSeekCallback - Callback to call for seeking in the stream. @@ -9568,7 +9665,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CAttachment::ReadFromBuffer - Reads an attachment from a memory buffer + * CAttachment::ReadFromBuffer - Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * @param[in] BufferBuffer - Buffer to read from */ void CAttachment::ReadFromBuffer(const CInputVector & BufferBuffer) @@ -10701,6 +10798,61 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) CheckError(m_pWrapper->m_WrapperTable.m_KeyStore_SetUUID(m_pHandle, sUUID.c_str())); } + /** + * Method definitions for class CNameSpaceIterator + */ + + /** + * CNameSpaceIterator::MoveNext - Iterates to the next namespace in the list. + * @return Iterates to the namespace in the list. + */ + bool CNameSpaceIterator::MoveNext() + { + bool resultHasNext = 0; + CheckError(m_pWrapper->m_WrapperTable.m_NameSpaceIterator_MoveNext(m_pHandle, &resultHasNext)); + + return resultHasNext; + } + + /** + * CNameSpaceIterator::MovePrevious - Iterates to the previous namespace in the list. + * @return Iterates to the previous required namespace in the list. + */ + bool CNameSpaceIterator::MovePrevious() + { + bool resultHasPrevious = 0; + CheckError(m_pWrapper->m_WrapperTable.m_NameSpaceIterator_MovePrevious(m_pHandle, &resultHasPrevious)); + + return resultHasPrevious; + } + + /** + * CNameSpaceIterator::GetCurrent - Returns the required namespace the iterator points at. + * @return returns the namespace. + */ + std::string CNameSpaceIterator::GetCurrent() + { + Lib3MF_uint32 bytesNeededNameSpace = 0; + Lib3MF_uint32 bytesWrittenNameSpace = 0; + CheckError(m_pWrapper->m_WrapperTable.m_NameSpaceIterator_GetCurrent(m_pHandle, 0, &bytesNeededNameSpace, nullptr)); + std::vector bufferNameSpace(bytesNeededNameSpace); + CheckError(m_pWrapper->m_WrapperTable.m_NameSpaceIterator_GetCurrent(m_pHandle, bytesNeededNameSpace, &bytesWrittenNameSpace, &bufferNameSpace[0])); + + return std::string(&bufferNameSpace[0]); + } + + /** + * CNameSpaceIterator::Count - Returns the number of namespaces the iterator captures. + * @return returns the number of namspaces the iterator captures. + */ + Lib3MF_uint64 CNameSpaceIterator::Count() + { + Lib3MF_uint64 resultCount = 0; + CheckError(m_pWrapper->m_WrapperTable.m_NameSpaceIterator_Count(m_pHandle, &resultCount)); + + return resultCount; + } + /** * Method definitions for class CModel */ @@ -11568,6 +11720,21 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hKeyStore))); } + + /** + * CModel::GetRequiredNameSpaces - Gets the list of required namespaces for the model + * @return The required namespace iterator + */ + PNameSpaceIterator CModel::GetRequiredNameSpaces() + { + Lib3MFHandle hNameSpaceIterator = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Model_GetRequiredNameSpaces(m_pHandle, &hNameSpaceIterator)); + + if (!hNameSpaceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hNameSpaceIterator))); + } } // namespace Lib3MF diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp b/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp index e9c0bdad5..5f3f9b44e 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp @@ -236,6 +236,7 @@ typedef Lib3MFHandle Lib3MF_ContentEncryptionParams; typedef Lib3MFHandle Lib3MF_ResourceData; typedef Lib3MFHandle Lib3MF_ResourceDataGroup; typedef Lib3MFHandle Lib3MF_KeyStore; +typedef Lib3MFHandle Lib3MF_NameSpaceIterator; typedef Lib3MFHandle Lib3MF_Model; namespace Lib3MF { diff --git a/Autogenerated/Bindings/Go/lib3mf.go b/Autogenerated/Bindings/Go/lib3mf.go index aeac95c81..776ac181a 100644 --- a/Autogenerated/Bindings/Go/lib3mf.go +++ b/Autogenerated/Bindings/Go/lib3mf.go @@ -2592,6 +2592,42 @@ Lib3MFResult CCall_lib3mf_keystore_setuuid(Lib3MFHandle libraryHandle, Lib3MF_Ke } +Lib3MFResult CCall_lib3mf_namespaceiterator_movenext(Lib3MFHandle libraryHandle, Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_NameSpaceIterator_MoveNext (pNameSpaceIterator, pHasNext); +} + + +Lib3MFResult CCall_lib3mf_namespaceiterator_moveprevious(Lib3MFHandle libraryHandle, Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_NameSpaceIterator_MovePrevious (pNameSpaceIterator, pHasPrevious); +} + + +Lib3MFResult CCall_lib3mf_namespaceiterator_getcurrent(Lib3MFHandle libraryHandle, Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_NameSpaceIterator_GetCurrent (pNameSpaceIterator, nNameSpaceBufferSize, pNameSpaceNeededChars, pNameSpaceBuffer); +} + + +Lib3MFResult CCall_lib3mf_namespaceiterator_count(Lib3MFHandle libraryHandle, Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_NameSpaceIterator_Count (pNameSpaceIterator, pCount); +} + + Lib3MFResult CCall_lib3mf_model_rootmodelpart(Lib3MFHandle libraryHandle, Lib3MF_Model pModel, Lib3MF_PackagePart * pRootModelPart) { if (libraryHandle == 0) @@ -3132,6 +3168,15 @@ Lib3MFResult CCall_lib3mf_model_getkeystore(Lib3MFHandle libraryHandle, Lib3MF_M } +Lib3MFResult CCall_lib3mf_model_getrequirednamespaces(Lib3MFHandle libraryHandle, Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_Model_GetRequiredNameSpaces (pModel, pNameSpaceIterator); +} + + Lib3MFResult CCall_lib3mf_getlibraryversion(Lib3MFHandle libraryHandle, Lib3MF_uint32 * pMajor, Lib3MF_uint32 * pMinor, Lib3MF_uint32 * pMicro) { if (libraryHandle == 0) @@ -6230,7 +6275,7 @@ func (inst Attachment) WriteToFile(fileName string) error { return nil } -// ReadFromFile reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +// ReadFromFile reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. func (inst Attachment) ReadFromFile(fileName string) error { ret := C.CCall_lib3mf_attachment_readfromfile(inst.wrapperRef.LibraryHandle, inst.Ref, (*C.char)(unsafe.Pointer(&[]byte(fileName)[0]))) if ret != 0 { @@ -6239,7 +6284,7 @@ func (inst Attachment) ReadFromFile(fileName string) error { return nil } -// ReadFromCallback reads a model and from the data provided by a callback function. +// ReadFromCallback reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. func (inst Attachment) ReadFromCallback(theReadCallback ReadCallbackFunc, streamSize uint64, theSeekCallback SeekCallbackFunc, userData uintptr) error { ret := C.CCall_lib3mf_attachment_readfromcallback(inst.wrapperRef.LibraryHandle, inst.Ref, (C.Lib3MFReadCallback)(unsafe.Pointer(C.Lib3MFReadCallback_cgo)), C.uint64_t(streamSize), (C.Lib3MFSeekCallback)(unsafe.Pointer(C.Lib3MFSeekCallback_cgo)), (C.Lib3MF_pvoid)(userData)) if ret != 0 { @@ -6277,7 +6322,7 @@ func (inst Attachment) WriteToBuffer(buffer []uint8) ([]uint8, error) { return buffer[:int(neededforbuffer)], nil } -// ReadFromBuffer reads an attachment from a memory buffer. +// ReadFromBuffer reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). func (inst Attachment) ReadFromBuffer(buffer []uint8) error { ret := C.CCall_lib3mf_attachment_readfrombuffer(inst.wrapperRef.LibraryHandle, inst.Ref, C.uint64_t(len(buffer)), (*C.uint8_t)(unsafe.Pointer(&buffer[0]))) if ret != 0 { @@ -7344,6 +7389,63 @@ func (inst KeyStore) SetUUID(uUID string) error { } +// NameSpaceIterator represents a Lib3MF class. +type NameSpaceIterator struct { + Base +} + +func (wrapper Wrapper) NewNameSpaceIterator(r ref) NameSpaceIterator { + return NameSpaceIterator{wrapper.NewBase(r)} +} + +// MoveNext iterates to the next namespace in the list. +func (inst NameSpaceIterator) MoveNext() (bool, error) { + var hasNext C.bool + ret := C.CCall_lib3mf_namespaceiterator_movenext(inst.wrapperRef.LibraryHandle, inst.Ref, &hasNext) + if ret != 0 { + return false, makeError(uint32(ret)) + } + return bool(hasNext), nil +} + +// MovePrevious iterates to the previous namespace in the list. +func (inst NameSpaceIterator) MovePrevious() (bool, error) { + var hasPrevious C.bool + ret := C.CCall_lib3mf_namespaceiterator_moveprevious(inst.wrapperRef.LibraryHandle, inst.Ref, &hasPrevious) + if ret != 0 { + return false, makeError(uint32(ret)) + } + return bool(hasPrevious), nil +} + +// GetCurrent returns the required namespace the iterator points at. +func (inst NameSpaceIterator) GetCurrent() (string, error) { + var neededfornameSpace C.uint32_t + var filledinnameSpace C.uint32_t + ret := C.CCall_lib3mf_namespaceiterator_getcurrent(inst.wrapperRef.LibraryHandle, inst.Ref, 0, &neededfornameSpace, nil) + if ret != 0 { + return "", makeError(uint32(ret)) + } + bufferSizenameSpace := neededfornameSpace + buffernameSpace := make([]byte, bufferSizenameSpace) + ret = C.CCall_lib3mf_namespaceiterator_getcurrent(inst.wrapperRef.LibraryHandle, inst.Ref, bufferSizenameSpace, &filledinnameSpace, (*C.char)(unsafe.Pointer(&buffernameSpace[0]))) + if ret != 0 { + return "", makeError(uint32(ret)) + } + return string(buffernameSpace[:(filledinnameSpace-1)]), nil +} + +// Count returns the number of namespaces the iterator captures. +func (inst NameSpaceIterator) Count() (uint64, error) { + var count C.uint64_t + ret := C.CCall_lib3mf_namespaceiterator_count(inst.wrapperRef.LibraryHandle, inst.Ref, &count) + if ret != 0 { + return 0, makeError(uint32(ret)) + } + return uint64(count), nil +} + + // Model represents a Lib3MF class. type Model struct { Base @@ -7965,6 +8067,16 @@ func (inst Model) GetKeyStore() (KeyStore, error) { return inst.wrapperRef.NewKeyStore(keyStore), nil } +// GetRequiredNameSpaces gets the list of required namespaces for the model. +func (inst Model) GetRequiredNameSpaces() (NameSpaceIterator, error) { + var nameSpaceIterator ref + ret := C.CCall_lib3mf_model_getrequirednamespaces(inst.wrapperRef.LibraryHandle, inst.Ref, &nameSpaceIterator) + if ret != 0 { + return NameSpaceIterator{}, makeError(uint32(ret)) + } + return inst.wrapperRef.NewNameSpaceIterator(nameSpaceIterator), nil +} + // GetLibraryVersion retrieves the binary version of this library. func (wrapper Wrapper) GetLibraryVersion() (uint32, uint32, uint32, error) { diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc index 967ef1f16..c420d8064 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc @@ -328,6 +328,10 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_KeyStore_GetResourceData = NULL; pWrapperTable->m_KeyStore_GetUUID = NULL; pWrapperTable->m_KeyStore_SetUUID = NULL; + pWrapperTable->m_NameSpaceIterator_MoveNext = NULL; + pWrapperTable->m_NameSpaceIterator_MovePrevious = NULL; + pWrapperTable->m_NameSpaceIterator_GetCurrent = NULL; + pWrapperTable->m_NameSpaceIterator_Count = NULL; pWrapperTable->m_Model_RootModelPart = NULL; pWrapperTable->m_Model_FindOrCreatePackagePart = NULL; pWrapperTable->m_Model_SetUnit = NULL; @@ -388,6 +392,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_RemoveCustomContentType = NULL; pWrapperTable->m_Model_SetRandomNumberCallback = NULL; pWrapperTable->m_Model_GetKeyStore = NULL; + pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -2981,6 +2986,42 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_KeyStore_SetUUID == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_MoveNext = (PLib3MFNameSpaceIterator_MoveNextPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_movenext"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_MoveNext = (PLib3MFNameSpaceIterator_MoveNextPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_movenext"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_MoveNext == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_MovePrevious = (PLib3MFNameSpaceIterator_MovePreviousPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_moveprevious"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_MovePrevious = (PLib3MFNameSpaceIterator_MovePreviousPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_moveprevious"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_MovePrevious == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_GetCurrent = (PLib3MFNameSpaceIterator_GetCurrentPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_getcurrent"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_GetCurrent = (PLib3MFNameSpaceIterator_GetCurrentPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_getcurrent"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_GetCurrent == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_Count = (PLib3MFNameSpaceIterator_CountPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_count"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_Count = (PLib3MFNameSpaceIterator_CountPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_count"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_Count == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Model_RootModelPart = (PLib3MFModel_RootModelPartPtr) GetProcAddress(hLibrary, "lib3mf_model_rootmodelpart"); #else // _WIN32 @@ -3521,6 +3562,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_GetKeyStore == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) GetProcAddress(hLibrary, "lib3mf_model_getrequirednamespaces"); + #else // _WIN32 + pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) dlsym(hLibrary, "lib3mf_model_getrequirednamespaces"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Model_GetRequiredNameSpaces == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_GetLibraryVersion = (PLib3MFGetLibraryVersionPtr) GetProcAddress(hLibrary, "lib3mf_getlibraryversion"); #else // _WIN32 diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.h b/Autogenerated/Bindings/Go/lib3mf_dynamic.h index c92306d14..e9bccb264 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.h @@ -2034,7 +2034,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_SetRelationShipTypePtr) (Lib3MF_Attachm typedef Lib3MFResult (*PLib3MFAttachment_WriteToFilePtr) (Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2043,7 +2043,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_WriteToFilePtr) (Lib3MF_Attachment pAtt typedef Lib3MFResult (*PLib3MFAttachment_ReadFromFilePtr) (Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads a model and from the data provided by a callback function +* Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2075,7 +2075,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_GetStreamSizePtr) (Lib3MF_Attachment pA typedef Lib3MFResult (*PLib3MFAttachment_WriteToBufferPtr) (Lib3MF_Attachment pAttachment, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); /** -* Reads an attachment from a memory buffer +* Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferBufferSize - Number of elements in buffer @@ -2941,6 +2941,48 @@ typedef Lib3MFResult (*PLib3MFKeyStore_GetUUIDPtr) (Lib3MF_KeyStore pKeyStore, b */ typedef Lib3MFResult (*PLib3MFKeyStore_SetUUIDPtr) (Lib3MF_KeyStore pKeyStore, const char * pUUID); +/************************************************************************************************************************* + Class definition for NameSpaceIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasNext - Iterates to the namespace in the list. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_MoveNextPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext); + +/** +* Iterates to the previous namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasPrevious - Iterates to the previous required namespace in the list. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_MovePreviousPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious); + +/** +* Returns the required namespace the iterator points at. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of returns the namespace., may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_GetCurrentPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + +/** +* Returns the number of namespaces the iterator captures. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pCount - returns the number of namspaces the iterator captures. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_CountPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount); + /************************************************************************************************************************* Class definition for Model **************************************************************************************************************************/ @@ -3515,6 +3557,15 @@ typedef Lib3MFResult (*PLib3MFModel_SetRandomNumberCallbackPtr) (Lib3MF_Model pM */ typedef Lib3MFResult (*PLib3MFModel_GetKeyStorePtr) (Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); +/** +* Gets the list of required namespaces for the model +* +* @param[in] pModel - Model instance. +* @param[out] pNameSpaceIterator - The required namespace iterator +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFModel_GetRequiredNameSpacesPtr) (Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -3999,6 +4050,10 @@ typedef struct { PLib3MFKeyStore_GetResourceDataPtr m_KeyStore_GetResourceData; PLib3MFKeyStore_GetUUIDPtr m_KeyStore_GetUUID; PLib3MFKeyStore_SetUUIDPtr m_KeyStore_SetUUID; + PLib3MFNameSpaceIterator_MoveNextPtr m_NameSpaceIterator_MoveNext; + PLib3MFNameSpaceIterator_MovePreviousPtr m_NameSpaceIterator_MovePrevious; + PLib3MFNameSpaceIterator_GetCurrentPtr m_NameSpaceIterator_GetCurrent; + PLib3MFNameSpaceIterator_CountPtr m_NameSpaceIterator_Count; PLib3MFModel_RootModelPartPtr m_Model_RootModelPart; PLib3MFModel_FindOrCreatePackagePartPtr m_Model_FindOrCreatePackagePart; PLib3MFModel_SetUnitPtr m_Model_SetUnit; @@ -4059,6 +4114,7 @@ typedef struct { PLib3MFModel_RemoveCustomContentTypePtr m_Model_RemoveCustomContentType; PLib3MFModel_SetRandomNumberCallbackPtr m_Model_SetRandomNumberCallback; PLib3MFModel_GetKeyStorePtr m_Model_GetKeyStore; + PLib3MFModel_GetRequiredNameSpacesPtr m_Model_GetRequiredNameSpaces; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; diff --git a/Autogenerated/Bindings/Go/lib3mf_types.h b/Autogenerated/Bindings/Go/lib3mf_types.h index b4059ad3f..6747467de 100644 --- a/Autogenerated/Bindings/Go/lib3mf_types.h +++ b/Autogenerated/Bindings/Go/lib3mf_types.h @@ -237,6 +237,7 @@ typedef Lib3MFHandle Lib3MF_ContentEncryptionParams; typedef Lib3MFHandle Lib3MF_ResourceData; typedef Lib3MFHandle Lib3MF_ResourceDataGroup; typedef Lib3MFHandle Lib3MF_KeyStore; +typedef Lib3MFHandle Lib3MF_NameSpaceIterator; typedef Lib3MFHandle Lib3MF_Model; /************************************************************************************************************************* diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc index 967ef1f16..c420d8064 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc @@ -328,6 +328,10 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_KeyStore_GetResourceData = NULL; pWrapperTable->m_KeyStore_GetUUID = NULL; pWrapperTable->m_KeyStore_SetUUID = NULL; + pWrapperTable->m_NameSpaceIterator_MoveNext = NULL; + pWrapperTable->m_NameSpaceIterator_MovePrevious = NULL; + pWrapperTable->m_NameSpaceIterator_GetCurrent = NULL; + pWrapperTable->m_NameSpaceIterator_Count = NULL; pWrapperTable->m_Model_RootModelPart = NULL; pWrapperTable->m_Model_FindOrCreatePackagePart = NULL; pWrapperTable->m_Model_SetUnit = NULL; @@ -388,6 +392,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_RemoveCustomContentType = NULL; pWrapperTable->m_Model_SetRandomNumberCallback = NULL; pWrapperTable->m_Model_GetKeyStore = NULL; + pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -2981,6 +2986,42 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_KeyStore_SetUUID == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_MoveNext = (PLib3MFNameSpaceIterator_MoveNextPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_movenext"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_MoveNext = (PLib3MFNameSpaceIterator_MoveNextPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_movenext"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_MoveNext == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_MovePrevious = (PLib3MFNameSpaceIterator_MovePreviousPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_moveprevious"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_MovePrevious = (PLib3MFNameSpaceIterator_MovePreviousPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_moveprevious"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_MovePrevious == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_GetCurrent = (PLib3MFNameSpaceIterator_GetCurrentPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_getcurrent"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_GetCurrent = (PLib3MFNameSpaceIterator_GetCurrentPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_getcurrent"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_GetCurrent == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_NameSpaceIterator_Count = (PLib3MFNameSpaceIterator_CountPtr) GetProcAddress(hLibrary, "lib3mf_namespaceiterator_count"); + #else // _WIN32 + pWrapperTable->m_NameSpaceIterator_Count = (PLib3MFNameSpaceIterator_CountPtr) dlsym(hLibrary, "lib3mf_namespaceiterator_count"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_NameSpaceIterator_Count == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Model_RootModelPart = (PLib3MFModel_RootModelPartPtr) GetProcAddress(hLibrary, "lib3mf_model_rootmodelpart"); #else // _WIN32 @@ -3521,6 +3562,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_GetKeyStore == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) GetProcAddress(hLibrary, "lib3mf_model_getrequirednamespaces"); + #else // _WIN32 + pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) dlsym(hLibrary, "lib3mf_model_getrequirednamespaces"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Model_GetRequiredNameSpaces == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_GetLibraryVersion = (PLib3MFGetLibraryVersionPtr) GetProcAddress(hLibrary, "lib3mf_getlibraryversion"); #else // _WIN32 diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h index c92306d14..e9bccb264 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h @@ -2034,7 +2034,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_SetRelationShipTypePtr) (Lib3MF_Attachm typedef Lib3MFResult (*PLib3MFAttachment_WriteToFilePtr) (Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2043,7 +2043,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_WriteToFilePtr) (Lib3MF_Attachment pAtt typedef Lib3MFResult (*PLib3MFAttachment_ReadFromFilePtr) (Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads a model and from the data provided by a callback function +* Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2075,7 +2075,7 @@ typedef Lib3MFResult (*PLib3MFAttachment_GetStreamSizePtr) (Lib3MF_Attachment pA typedef Lib3MFResult (*PLib3MFAttachment_WriteToBufferPtr) (Lib3MF_Attachment pAttachment, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); /** -* Reads an attachment from a memory buffer +* Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferBufferSize - Number of elements in buffer @@ -2941,6 +2941,48 @@ typedef Lib3MFResult (*PLib3MFKeyStore_GetUUIDPtr) (Lib3MF_KeyStore pKeyStore, b */ typedef Lib3MFResult (*PLib3MFKeyStore_SetUUIDPtr) (Lib3MF_KeyStore pKeyStore, const char * pUUID); +/************************************************************************************************************************* + Class definition for NameSpaceIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasNext - Iterates to the namespace in the list. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_MoveNextPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext); + +/** +* Iterates to the previous namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasPrevious - Iterates to the previous required namespace in the list. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_MovePreviousPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious); + +/** +* Returns the required namespace the iterator points at. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of returns the namespace., may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_GetCurrentPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + +/** +* Returns the number of namespaces the iterator captures. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pCount - returns the number of namspaces the iterator captures. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFNameSpaceIterator_CountPtr) (Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount); + /************************************************************************************************************************* Class definition for Model **************************************************************************************************************************/ @@ -3515,6 +3557,15 @@ typedef Lib3MFResult (*PLib3MFModel_SetRandomNumberCallbackPtr) (Lib3MF_Model pM */ typedef Lib3MFResult (*PLib3MFModel_GetKeyStorePtr) (Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); +/** +* Gets the list of required namespaces for the model +* +* @param[in] pModel - Model instance. +* @param[out] pNameSpaceIterator - The required namespace iterator +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFModel_GetRequiredNameSpacesPtr) (Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -3999,6 +4050,10 @@ typedef struct { PLib3MFKeyStore_GetResourceDataPtr m_KeyStore_GetResourceData; PLib3MFKeyStore_GetUUIDPtr m_KeyStore_GetUUID; PLib3MFKeyStore_SetUUIDPtr m_KeyStore_SetUUID; + PLib3MFNameSpaceIterator_MoveNextPtr m_NameSpaceIterator_MoveNext; + PLib3MFNameSpaceIterator_MovePreviousPtr m_NameSpaceIterator_MovePrevious; + PLib3MFNameSpaceIterator_GetCurrentPtr m_NameSpaceIterator_GetCurrent; + PLib3MFNameSpaceIterator_CountPtr m_NameSpaceIterator_Count; PLib3MFModel_RootModelPartPtr m_Model_RootModelPart; PLib3MFModel_FindOrCreatePackagePartPtr m_Model_FindOrCreatePackagePart; PLib3MFModel_SetUnitPtr m_Model_SetUnit; @@ -4059,6 +4114,7 @@ typedef struct { PLib3MFModel_RemoveCustomContentTypePtr m_Model_RemoveCustomContentType; PLib3MFModel_SetRandomNumberCallbackPtr m_Model_SetRandomNumberCallback; PLib3MFModel_GetKeyStorePtr m_Model_GetKeyStore; + PLib3MFModel_GetRequiredNameSpacesPtr m_Model_GetRequiredNameSpaces; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc b/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc index 723898b55..9151a2dec 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc @@ -89,6 +89,7 @@ void InitAll(v8::Local exports, v8::Local module) CLib3MFResourceData::Init(); CLib3MFResourceDataGroup::Init(); CLib3MFKeyStore::Init(); + CLib3MFNameSpaceIterator::Init(); CLib3MFModel::Init(); CLib3MFWrapper::Init(); NODE_SET_METHOD(module, "exports", LoadLib3MF); diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc index 75fbffa47..861d8992f 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc @@ -82,6 +82,7 @@ Persistent CLib3MFContentEncryptionParams::constructor; Persistent CLib3MFResourceData::constructor; Persistent CLib3MFResourceDataGroup::constructor; Persistent CLib3MFKeyStore::constructor; +Persistent CLib3MFNameSpaceIterator::constructor; Persistent CLib3MFModel::constructor; /************************************************************************************************************************* @@ -10587,6 +10588,158 @@ void CLib3MFKeyStore::SetUUID(const FunctionCallbackInfo& args) } } +/************************************************************************************************************************* + Class CLib3MFNameSpaceIterator Implementation +**************************************************************************************************************************/ + +CLib3MFNameSpaceIterator::CLib3MFNameSpaceIterator() + : CLib3MFBaseClass() +{ +} + +CLib3MFNameSpaceIterator::~CLib3MFNameSpaceIterator() +{ +} + +void CLib3MFNameSpaceIterator::Init() +{ + Isolate* isolate = Isolate::GetCurrent(); + + // Prepare constructor template + Local tpl = FunctionTemplate::New(isolate, New); + tpl->SetClassName(String::NewFromUtf8(isolate, "Lib3MFNameSpaceIterator")); + tpl->InstanceTemplate()->SetInternalFieldCount(NODEWRAPPER_FIELDCOUNT); + + // Prototype + NODE_SET_PROTOTYPE_METHOD(tpl, "MoveNext", MoveNext); + NODE_SET_PROTOTYPE_METHOD(tpl, "MovePrevious", MovePrevious); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetCurrent", GetCurrent); + NODE_SET_PROTOTYPE_METHOD(tpl, "Count", Count); + constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); + +} + +void CLib3MFNameSpaceIterator::New(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + + if (args.IsConstructCall()) { + CLib3MFBaseClass * holderObj = ObjectWrap::Unwrap(args.Holder()); + CLib3MFNameSpaceIterator * namespaceiteratorInstance = new CLib3MFNameSpaceIterator(); + namespaceiteratorInstance->Wrap(args.This()); + args.GetReturnValue().Set(args.This()); + } else { + RaiseError(isolate, "Lib3MFNameSpaceIterator: Invalid call to Constructor"); + } +} + +Local CLib3MFNameSpaceIterator::NewInstance(Local pParent, Lib3MFHandle pHandle) +{ + Isolate* isolate = Isolate::GetCurrent(); + HandleScope scope(isolate); + Local cons = Local::New(isolate, constructor); + Local instance; + if (cons->NewInstance(isolate->GetCurrentContext()).ToLocal(&instance)) { + instance->SetInternalField(NODEWRAPPER_TABLEINDEX, External::New(isolate, CLib3MFBaseClass::getDynamicWrapperTable(pParent))); + instance->SetInternalField(NODEWRAPPER_HANDLEINDEX, External::New(isolate, pHandle)); + } + return instance; +} + + +void CLib3MFNameSpaceIterator::MoveNext(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + bool bReturnHasNext = false; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method MoveNext."); + if (wrapperTable->m_NameSpaceIterator_MoveNext == nullptr) + throw std::runtime_error("Could not call Lib3MF method NameSpaceIterator::MoveNext."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_NameSpaceIterator_MoveNext(instanceHandle, &bReturnHasNext); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(Boolean::New(isolate, bReturnHasNext)); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFNameSpaceIterator::MovePrevious(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + bool bReturnHasPrevious = false; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method MovePrevious."); + if (wrapperTable->m_NameSpaceIterator_MovePrevious == nullptr) + throw std::runtime_error("Could not call Lib3MF method NameSpaceIterator::MovePrevious."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_NameSpaceIterator_MovePrevious(instanceHandle, &bReturnHasPrevious); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(Boolean::New(isolate, bReturnHasPrevious)); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFNameSpaceIterator::GetCurrent(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + unsigned int bytesNeededNameSpace = 0; + unsigned int bytesWrittenNameSpace = 0; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method GetCurrent."); + if (wrapperTable->m_NameSpaceIterator_GetCurrent == nullptr) + throw std::runtime_error("Could not call Lib3MF method NameSpaceIterator::GetCurrent."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult initErrorCode = wrapperTable->m_NameSpaceIterator_GetCurrent(instanceHandle, 0, &bytesNeededNameSpace, nullptr); + CheckError(isolate, wrapperTable, instanceHandle, initErrorCode); + std::vector bufferNameSpace; + bufferNameSpace.resize(bytesNeededNameSpace); + Lib3MFResult errorCode = wrapperTable->m_NameSpaceIterator_GetCurrent(instanceHandle, bytesNeededNameSpace, &bytesWrittenNameSpace, &bufferNameSpace[0]); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(String::NewFromUtf8(isolate, &bufferNameSpace[0])); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFNameSpaceIterator::Count(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + uint64_t nReturnCount = 0; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method Count."); + if (wrapperTable->m_NameSpaceIterator_Count == nullptr) + throw std::runtime_error("Could not call Lib3MF method NameSpaceIterator::Count."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_NameSpaceIterator_Count(instanceHandle, &nReturnCount); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(String::NewFromUtf8(isolate, std::to_string(nReturnCount).c_str())); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + /************************************************************************************************************************* Class CLib3MFModel Implementation **************************************************************************************************************************/ @@ -10670,6 +10823,7 @@ void CLib3MFModel::Init() NODE_SET_PROTOTYPE_METHOD(tpl, "RemoveCustomContentType", RemoveCustomContentType); NODE_SET_PROTOTYPE_METHOD(tpl, "SetRandomNumberCallback", SetRandomNumberCallback); NODE_SET_PROTOTYPE_METHOD(tpl, "GetKeyStore", GetKeyStore); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetRequiredNameSpaces", GetRequiredNameSpaces); constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); } @@ -12231,6 +12385,29 @@ void CLib3MFModel::GetKeyStore(const FunctionCallbackInfo& args) } } + +void CLib3MFModel::GetRequiredNameSpaces(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + Lib3MFHandle hReturnNameSpaceIterator = nullptr; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method GetRequiredNameSpaces."); + if (wrapperTable->m_Model_GetRequiredNameSpaces == nullptr) + throw std::runtime_error("Could not call Lib3MF method Model::GetRequiredNameSpaces."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_Model_GetRequiredNameSpaces(instanceHandle, &hReturnNameSpaceIterator); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + Local instanceObjNameSpaceIterator = CLib3MFNameSpaceIterator::NewInstance(args.Holder(), hReturnNameSpaceIterator); + args.GetReturnValue().Set(instanceObjNameSpaceIterator); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + /************************************************************************************************************************* Class CLib3MFWrapper Implementation **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h index 4f9389864..6fecb2406 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h @@ -1046,6 +1046,27 @@ class CLib3MFKeyStore : public CLib3MFBaseClass { }; +/************************************************************************************************************************* + Class CLib3MFNameSpaceIterator +**************************************************************************************************************************/ +class CLib3MFNameSpaceIterator : public CLib3MFBaseClass { +private: + static void New(const v8::FunctionCallbackInfo& args); + static v8::Persistent constructor; + static void MoveNext(const v8::FunctionCallbackInfo& args); + static void MovePrevious(const v8::FunctionCallbackInfo& args); + static void GetCurrent(const v8::FunctionCallbackInfo& args); + static void Count(const v8::FunctionCallbackInfo& args); + +public: + CLib3MFNameSpaceIterator(); + ~CLib3MFNameSpaceIterator(); + + static void Init(); + static v8::Local NewInstance(v8::Local, Lib3MFHandle pHandle); + +}; + /************************************************************************************************************************* Class CLib3MFModel **************************************************************************************************************************/ @@ -1113,6 +1134,7 @@ class CLib3MFModel : public CLib3MFBaseClass { static void RemoveCustomContentType(const v8::FunctionCallbackInfo& args); static void SetRandomNumberCallback(const v8::FunctionCallbackInfo& args); static void GetKeyStore(const v8::FunctionCallbackInfo& args); + static void GetRequiredNameSpaces(const v8::FunctionCallbackInfo& args); public: CLib3MFModel(); diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_types.h b/Autogenerated/Bindings/NodeJS/lib3mf_types.h index b4059ad3f..6747467de 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_types.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_types.h @@ -237,6 +237,7 @@ typedef Lib3MFHandle Lib3MF_ContentEncryptionParams; typedef Lib3MFHandle Lib3MF_ResourceData; typedef Lib3MFHandle Lib3MF_ResourceDataGroup; typedef Lib3MFHandle Lib3MF_KeyStore; +typedef Lib3MFHandle Lib3MF_NameSpaceIterator; typedef Lib3MFHandle Lib3MF_Model; /************************************************************************************************************************* diff --git a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas index 7f51715d0..a0528bd7b 100644 --- a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas +++ b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas @@ -409,6 +409,7 @@ TLib3MFContentEncryptionParams = class; TLib3MFResourceData = class; TLib3MFResourceDataGroup = class; TLib3MFKeyStore = class; + TLib3MFNameSpaceIterator = class; TLib3MFModel = class; @@ -2435,7 +2436,7 @@ TLib3MFModel = class; TLib3MFAttachment_WriteToFileFunc = function(pAttachment: TLib3MFHandle; const pFileName: PAnsiChar): TLib3MFResult; cdecl; (** - * Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. + * Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2444,7 +2445,7 @@ TLib3MFModel = class; TLib3MFAttachment_ReadFromFileFunc = function(pAttachment: TLib3MFHandle; const pFileName: PAnsiChar): TLib3MFResult; cdecl; (** - * Reads a model and from the data provided by a callback function + * Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2476,7 +2477,7 @@ TLib3MFModel = class; TLib3MFAttachment_WriteToBufferFunc = function(pAttachment: TLib3MFHandle; const nBufferCount: QWord; out pBufferNeededCount: QWord; pBufferBuffer: PByte): TLib3MFResult; cdecl; (** - * Reads an attachment from a memory buffer + * Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferCount - Number of elements in buffer @@ -3354,6 +3355,49 @@ TLib3MFModel = class; TLib3MFKeyStore_SetUUIDFunc = function(pKeyStore: TLib3MFHandle; const pUUID: PAnsiChar): TLib3MFResult; cdecl; +(************************************************************************************************************************* + Function type definitions for NameSpaceIterator +**************************************************************************************************************************) + + (** + * Iterates to the next namespace in the list. + * + * @param[in] pNameSpaceIterator - NameSpaceIterator instance. + * @param[out] pHasNext - Iterates to the namespace in the list. + * @return error code or 0 (success) + *) + TLib3MFNameSpaceIterator_MoveNextFunc = function(pNameSpaceIterator: TLib3MFHandle; out pHasNext: Byte): TLib3MFResult; cdecl; + + (** + * Iterates to the previous namespace in the list. + * + * @param[in] pNameSpaceIterator - NameSpaceIterator instance. + * @param[out] pHasPrevious - Iterates to the previous required namespace in the list. + * @return error code or 0 (success) + *) + TLib3MFNameSpaceIterator_MovePreviousFunc = function(pNameSpaceIterator: TLib3MFHandle; out pHasPrevious: Byte): TLib3MFResult; cdecl; + + (** + * Returns the required namespace the iterator points at. + * + * @param[in] pNameSpaceIterator - NameSpaceIterator instance. + * @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) + * @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. + * @param[out] pNameSpaceBuffer - buffer of returns the namespace., may be NULL + * @return error code or 0 (success) + *) + TLib3MFNameSpaceIterator_GetCurrentFunc = function(pNameSpaceIterator: TLib3MFHandle; const nNameSpaceBufferSize: Cardinal; out pNameSpaceNeededChars: Cardinal; pNameSpaceBuffer: PAnsiChar): TLib3MFResult; cdecl; + + (** + * Returns the number of namespaces the iterator captures. + * + * @param[in] pNameSpaceIterator - NameSpaceIterator instance. + * @param[out] pCount - returns the number of namspaces the iterator captures. + * @return error code or 0 (success) + *) + TLib3MFNameSpaceIterator_CountFunc = function(pNameSpaceIterator: TLib3MFHandle; out pCount: QWord): TLib3MFResult; cdecl; + + (************************************************************************************************************************* Function type definitions for Model **************************************************************************************************************************) @@ -3928,6 +3972,15 @@ TLib3MFModel = class; *) TLib3MFModel_GetKeyStoreFunc = function(pModel: TLib3MFHandle; out pKeyStore: TLib3MFHandle): TLib3MFResult; cdecl; + (** + * Gets the list of required namespaces for the model + * + * @param[in] pModel - Model instance. + * @param[out] pNameSpaceIterator - The required namespace iterator + * @return error code or 0 (success) + *) + TLib3MFModel_GetRequiredNameSpacesFunc = function(pModel: TLib3MFHandle; out pNameSpaceIterator: TLib3MFHandle): TLib3MFResult; cdecl; + (************************************************************************************************************************* Global function definitions **************************************************************************************************************************) @@ -4883,6 +4936,21 @@ TLib3MFKeyStore = class(TLib3MFBase) end; +(************************************************************************************************************************* + Class definition for NameSpaceIterator +**************************************************************************************************************************) + + TLib3MFNameSpaceIterator = class(TLib3MFBase) + public + constructor Create(AWrapper: TLib3MFWrapper; AHandle: TLib3MFHandle); + destructor Destroy; override; + function MoveNext(): Boolean; + function MovePrevious(): Boolean; + function GetCurrent(): String; + function Count(): QWord; + end; + + (************************************************************************************************************************* Class definition for Model **************************************************************************************************************************) @@ -4951,6 +5019,7 @@ TLib3MFModel = class(TLib3MFBase) procedure RemoveCustomContentType(const AExtension: String); procedure SetRandomNumberCallback(const ATheCallback: PLib3MF_RandomNumberCallback; const AUserData: Pointer); function GetKeyStore(): TLib3MFKeyStore; + function GetRequiredNameSpaces(): TLib3MFNameSpaceIterator; end; (************************************************************************************************************************* @@ -5240,6 +5309,10 @@ TLib3MFWrapper = class(TObject) FLib3MFKeyStore_GetResourceDataFunc: TLib3MFKeyStore_GetResourceDataFunc; FLib3MFKeyStore_GetUUIDFunc: TLib3MFKeyStore_GetUUIDFunc; FLib3MFKeyStore_SetUUIDFunc: TLib3MFKeyStore_SetUUIDFunc; + FLib3MFNameSpaceIterator_MoveNextFunc: TLib3MFNameSpaceIterator_MoveNextFunc; + FLib3MFNameSpaceIterator_MovePreviousFunc: TLib3MFNameSpaceIterator_MovePreviousFunc; + FLib3MFNameSpaceIterator_GetCurrentFunc: TLib3MFNameSpaceIterator_GetCurrentFunc; + FLib3MFNameSpaceIterator_CountFunc: TLib3MFNameSpaceIterator_CountFunc; FLib3MFModel_RootModelPartFunc: TLib3MFModel_RootModelPartFunc; FLib3MFModel_FindOrCreatePackagePartFunc: TLib3MFModel_FindOrCreatePackagePartFunc; FLib3MFModel_SetUnitFunc: TLib3MFModel_SetUnitFunc; @@ -5300,6 +5373,7 @@ TLib3MFWrapper = class(TObject) FLib3MFModel_RemoveCustomContentTypeFunc: TLib3MFModel_RemoveCustomContentTypeFunc; FLib3MFModel_SetRandomNumberCallbackFunc: TLib3MFModel_SetRandomNumberCallbackFunc; FLib3MFModel_GetKeyStoreFunc: TLib3MFModel_GetKeyStoreFunc; + FLib3MFModel_GetRequiredNameSpacesFunc: TLib3MFModel_GetRequiredNameSpacesFunc; FLib3MFGetLibraryVersionFunc: TLib3MFGetLibraryVersionFunc; FLib3MFGetPrereleaseInformationFunc: TLib3MFGetPrereleaseInformationFunc; FLib3MFGetBuildInformationFunc: TLib3MFGetBuildInformationFunc; @@ -5609,6 +5683,10 @@ TLib3MFWrapper = class(TObject) property Lib3MFKeyStore_GetResourceDataFunc: TLib3MFKeyStore_GetResourceDataFunc read FLib3MFKeyStore_GetResourceDataFunc; property Lib3MFKeyStore_GetUUIDFunc: TLib3MFKeyStore_GetUUIDFunc read FLib3MFKeyStore_GetUUIDFunc; property Lib3MFKeyStore_SetUUIDFunc: TLib3MFKeyStore_SetUUIDFunc read FLib3MFKeyStore_SetUUIDFunc; + property Lib3MFNameSpaceIterator_MoveNextFunc: TLib3MFNameSpaceIterator_MoveNextFunc read FLib3MFNameSpaceIterator_MoveNextFunc; + property Lib3MFNameSpaceIterator_MovePreviousFunc: TLib3MFNameSpaceIterator_MovePreviousFunc read FLib3MFNameSpaceIterator_MovePreviousFunc; + property Lib3MFNameSpaceIterator_GetCurrentFunc: TLib3MFNameSpaceIterator_GetCurrentFunc read FLib3MFNameSpaceIterator_GetCurrentFunc; + property Lib3MFNameSpaceIterator_CountFunc: TLib3MFNameSpaceIterator_CountFunc read FLib3MFNameSpaceIterator_CountFunc; property Lib3MFModel_RootModelPartFunc: TLib3MFModel_RootModelPartFunc read FLib3MFModel_RootModelPartFunc; property Lib3MFModel_FindOrCreatePackagePartFunc: TLib3MFModel_FindOrCreatePackagePartFunc read FLib3MFModel_FindOrCreatePackagePartFunc; property Lib3MFModel_SetUnitFunc: TLib3MFModel_SetUnitFunc read FLib3MFModel_SetUnitFunc; @@ -5669,6 +5747,7 @@ TLib3MFWrapper = class(TObject) property Lib3MFModel_RemoveCustomContentTypeFunc: TLib3MFModel_RemoveCustomContentTypeFunc read FLib3MFModel_RemoveCustomContentTypeFunc; property Lib3MFModel_SetRandomNumberCallbackFunc: TLib3MFModel_SetRandomNumberCallbackFunc read FLib3MFModel_SetRandomNumberCallbackFunc; property Lib3MFModel_GetKeyStoreFunc: TLib3MFModel_GetKeyStoreFunc read FLib3MFModel_GetKeyStoreFunc; + property Lib3MFModel_GetRequiredNameSpacesFunc: TLib3MFModel_GetRequiredNameSpacesFunc read FLib3MFModel_GetRequiredNameSpacesFunc; property Lib3MFGetLibraryVersionFunc: TLib3MFGetLibraryVersionFunc read FLib3MFGetLibraryVersionFunc; property Lib3MFGetPrereleaseInformationFunc: TLib3MFGetPrereleaseInformationFunc read FLib3MFGetPrereleaseInformationFunc; property Lib3MFGetBuildInformationFunc: TLib3MFGetBuildInformationFunc read FLib3MFGetBuildInformationFunc; @@ -5797,6 +5876,7 @@ TLib3MFPolymorphicFactory<_T:class; _B> = record function TLib3MFPolymorphicFactoryMakeResourceData(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFResourceData; function TLib3MFPolymorphicFactoryMakeResourceDataGroup(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFResourceDataGroup; function TLib3MFPolymorphicFactoryMakeKeyStore(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFKeyStore; + function TLib3MFPolymorphicFactoryMakeNameSpaceIterator(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFNameSpaceIterator; function TLib3MFPolymorphicFactoryMakeModel(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFModel; implementation @@ -6306,6 +6386,7 @@ implementation QWord($1A47A5E258E22EF9): begin Obj := TLIB3MFResourceData.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceData" QWord($D59067227E428AA4): begin Obj := TLIB3MFResourceDataGroup.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceDataGroup" QWord($1CC9E0CC082253C6): begin Obj := TLIB3MFKeyStore.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::KeyStore" + QWord($8D1206A0FEEFCC31): begin Obj := TLIB3MFNameSpaceIterator.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::NameSpaceIterator" QWord($5A8164ECEDB03F09): begin Obj := TLIB3MFModel.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::Model" end; if Result = nil then Result := _B.Create(Wrapper, Handle); @@ -6474,6 +6555,10 @@ implementation begin Result := TLib3MFPolymorphicFactory.Make(Wrapper, Handle); end; + function TLib3MFPolymorphicFactoryMakeNameSpaceIterator(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFNameSpaceIterator; + begin + Result := TLib3MFPolymorphicFactory.Make(Wrapper, Handle); + end; function TLib3MFPolymorphicFactoryMakeModel(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFModel; begin Result := TLib3MFPolymorphicFactory.Make(Wrapper, Handle); @@ -9652,6 +9737,57 @@ implementation FWrapper.CheckError(Self, FWrapper.Lib3MFKeyStore_SetUUIDFunc(FHandle, PAnsiChar(AUUID))); end; +(************************************************************************************************************************* + Class implementation for NameSpaceIterator +**************************************************************************************************************************) + + constructor TLib3MFNameSpaceIterator.Create(AWrapper: TLib3MFWrapper; AHandle: TLib3MFHandle); + begin + inherited Create(AWrapper, AHandle); + end; + + destructor TLib3MFNameSpaceIterator.Destroy; + begin + inherited; + end; + + function TLib3MFNameSpaceIterator.MoveNext(): Boolean; + var + ResultHasNext: Byte; + begin + ResultHasNext := 0; + FWrapper.CheckError(Self, FWrapper.Lib3MFNameSpaceIterator_MoveNextFunc(FHandle, ResultHasNext)); + Result := (ResultHasNext <> 0); + end; + + function TLib3MFNameSpaceIterator.MovePrevious(): Boolean; + var + ResultHasPrevious: Byte; + begin + ResultHasPrevious := 0; + FWrapper.CheckError(Self, FWrapper.Lib3MFNameSpaceIterator_MovePreviousFunc(FHandle, ResultHasPrevious)); + Result := (ResultHasPrevious <> 0); + end; + + function TLib3MFNameSpaceIterator.GetCurrent(): String; + var + bytesNeededNameSpace: Cardinal; + bytesWrittenNameSpace: Cardinal; + bufferNameSpace: array of Char; + begin + bytesNeededNameSpace:= 0; + bytesWrittenNameSpace:= 0; + FWrapper.CheckError(Self, FWrapper.Lib3MFNameSpaceIterator_GetCurrentFunc(FHandle, 0, bytesNeededNameSpace, nil)); + SetLength(bufferNameSpace, bytesNeededNameSpace); + FWrapper.CheckError(Self, FWrapper.Lib3MFNameSpaceIterator_GetCurrentFunc(FHandle, bytesNeededNameSpace, bytesWrittenNameSpace, @bufferNameSpace[0])); + Result := StrPas(@bufferNameSpace[0]); + end; + + function TLib3MFNameSpaceIterator.Count(): QWord; + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFNameSpaceIterator_CountFunc(FHandle, Result)); + end; + (************************************************************************************************************************* Class implementation for Model **************************************************************************************************************************) @@ -10297,6 +10433,17 @@ implementation Result := TLib3MFPolymorphicFactory.Make(FWrapper, HKeyStore); end; + function TLib3MFModel.GetRequiredNameSpaces(): TLib3MFNameSpaceIterator; + var + HNameSpaceIterator: TLib3MFHandle; + begin + Result := nil; + HNameSpaceIterator := nil; + FWrapper.CheckError(Self, FWrapper.Lib3MFModel_GetRequiredNameSpacesFunc(FHandle, HNameSpaceIterator)); + if Assigned(HNameSpaceIterator) then + Result := TLib3MFPolymorphicFactory.Make(FWrapper, HNameSpaceIterator); + end; + (************************************************************************************************************************* Wrapper class implementation **************************************************************************************************************************) @@ -10599,6 +10746,10 @@ implementation FLib3MFKeyStore_GetResourceDataFunc := LoadFunction('lib3mf_keystore_getresourcedata'); FLib3MFKeyStore_GetUUIDFunc := LoadFunction('lib3mf_keystore_getuuid'); FLib3MFKeyStore_SetUUIDFunc := LoadFunction('lib3mf_keystore_setuuid'); + FLib3MFNameSpaceIterator_MoveNextFunc := LoadFunction('lib3mf_namespaceiterator_movenext'); + FLib3MFNameSpaceIterator_MovePreviousFunc := LoadFunction('lib3mf_namespaceiterator_moveprevious'); + FLib3MFNameSpaceIterator_GetCurrentFunc := LoadFunction('lib3mf_namespaceiterator_getcurrent'); + FLib3MFNameSpaceIterator_CountFunc := LoadFunction('lib3mf_namespaceiterator_count'); FLib3MFModel_RootModelPartFunc := LoadFunction('lib3mf_model_rootmodelpart'); FLib3MFModel_FindOrCreatePackagePartFunc := LoadFunction('lib3mf_model_findorcreatepackagepart'); FLib3MFModel_SetUnitFunc := LoadFunction('lib3mf_model_setunit'); @@ -10659,6 +10810,7 @@ implementation FLib3MFModel_RemoveCustomContentTypeFunc := LoadFunction('lib3mf_model_removecustomcontenttype'); FLib3MFModel_SetRandomNumberCallbackFunc := LoadFunction('lib3mf_model_setrandomnumbercallback'); FLib3MFModel_GetKeyStoreFunc := LoadFunction('lib3mf_model_getkeystore'); + FLib3MFModel_GetRequiredNameSpacesFunc := LoadFunction('lib3mf_model_getrequirednamespaces'); FLib3MFGetLibraryVersionFunc := LoadFunction('lib3mf_getlibraryversion'); FLib3MFGetPrereleaseInformationFunc := LoadFunction('lib3mf_getprereleaseinformation'); FLib3MFGetBuildInformationFunc := LoadFunction('lib3mf_getbuildinformation'); @@ -11527,6 +11679,18 @@ implementation if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_keystore_setuuid'), @FLib3MFKeyStore_SetUUIDFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_namespaceiterator_movenext'), @FLib3MFNameSpaceIterator_MoveNextFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_namespaceiterator_moveprevious'), @FLib3MFNameSpaceIterator_MovePreviousFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_namespaceiterator_getcurrent'), @FLib3MFNameSpaceIterator_GetCurrentFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_namespaceiterator_count'), @FLib3MFNameSpaceIterator_CountFunc); if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_model_rootmodelpart'), @FLib3MFModel_RootModelPartFunc); @@ -11707,6 +11871,9 @@ implementation if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_model_getkeystore'), @FLib3MFModel_GetKeyStoreFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_model_getrequirednamespaces'), @FLib3MFModel_GetRequiredNameSpacesFunc); if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_getlibraryversion'), @FLib3MFGetLibraryVersionFunc); diff --git a/Autogenerated/Bindings/Python/Lib3MF.py b/Autogenerated/Bindings/Python/Lib3MF.py index 0268092b3..01eeab217 100644 --- a/Autogenerated/Bindings/Python/Lib3MF.py +++ b/Autogenerated/Bindings/Python/Lib3MF.py @@ -410,6 +410,10 @@ class FunctionTable: lib3mf_keystore_getresourcedata = None lib3mf_keystore_getuuid = None lib3mf_keystore_setuuid = None + lib3mf_namespaceiterator_movenext = None + lib3mf_namespaceiterator_moveprevious = None + lib3mf_namespaceiterator_getcurrent = None + lib3mf_namespaceiterator_count = None lib3mf_model_rootmodelpart = None lib3mf_model_findorcreatepackagepart = None lib3mf_model_setunit = None @@ -470,6 +474,7 @@ class FunctionTable: lib3mf_model_removecustomcontenttype = None lib3mf_model_setrandomnumbercallback = None lib3mf_model_getkeystore = None + lib3mf_model_getrequirednamespaces = None '''Definition of Enumerations ''' @@ -2572,6 +2577,30 @@ def _loadFunctionTableFromMethod(self, symbolLookupMethodAddress): methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_char_p) self.lib.lib3mf_keystore_setuuid = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_namespaceiterator_movenext")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_bool)) + self.lib.lib3mf_namespaceiterator_movenext = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_namespaceiterator_moveprevious")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_bool)) + self.lib.lib3mf_namespaceiterator_moveprevious = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_namespaceiterator_getcurrent")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.c_char_p) + self.lib.lib3mf_namespaceiterator_getcurrent = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_namespaceiterator_count")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint64)) + self.lib.lib3mf_namespaceiterator_count = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_model_rootmodelpart")), methodAddress) if err != 0: raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) @@ -2932,6 +2961,12 @@ def _loadFunctionTableFromMethod(self, symbolLookupMethodAddress): methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)) self.lib.lib3mf_model_getkeystore = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_model_getrequirednamespaces")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)) + self.lib.lib3mf_model_getrequirednamespaces = methodType(int(methodAddress.value)) + except AttributeError as ae: raise ELib3MFException(ErrorCodes.COULDNOTFINDLIBRARYEXPORT, ae.args[0]) @@ -3834,6 +3869,18 @@ def _loadFunctionTable(self): self.lib.lib3mf_keystore_setuuid.restype = ctypes.c_int32 self.lib.lib3mf_keystore_setuuid.argtypes = [ctypes.c_void_p, ctypes.c_char_p] + self.lib.lib3mf_namespaceiterator_movenext.restype = ctypes.c_int32 + self.lib.lib3mf_namespaceiterator_movenext.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_bool)] + + self.lib.lib3mf_namespaceiterator_moveprevious.restype = ctypes.c_int32 + self.lib.lib3mf_namespaceiterator_moveprevious.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_bool)] + + self.lib.lib3mf_namespaceiterator_getcurrent.restype = ctypes.c_int32 + self.lib.lib3mf_namespaceiterator_getcurrent.argtypes = [ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.c_char_p] + + self.lib.lib3mf_namespaceiterator_count.restype = ctypes.c_int32 + self.lib.lib3mf_namespaceiterator_count.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint64)] + self.lib.lib3mf_model_rootmodelpart.restype = ctypes.c_int32 self.lib.lib3mf_model_rootmodelpart.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)] @@ -4014,6 +4061,9 @@ def _loadFunctionTable(self): self.lib.lib3mf_model_getkeystore.restype = ctypes.c_int32 self.lib.lib3mf_model_getkeystore.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)] + self.lib.lib3mf_model_getrequirednamespaces.restype = ctypes.c_int32 + self.lib.lib3mf_model_getrequirednamespaces.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)] + except AttributeError as ae: raise ELib3MFException(ErrorCodes.COULDNOTFINDLIBRARYEXPORT, ae.args[0]) @@ -4302,6 +4352,8 @@ def getObjectById_D59067227E428AA4(self, handle, wrapper): # First 64 bits of SH return ResourceDataGroup(handle, wrapper) def getObjectById_1CC9E0CC082253C6(self, handle, wrapper): # First 64 bits of SHA1 of a string: "Lib3MF::KeyStore" return KeyStore(handle, wrapper) + def getObjectById_8D1206A0FEEFCC31(self, handle, wrapper): # First 64 bits of SHA1 of a string: "Lib3MF::NameSpaceIterator" + return NameSpaceIterator(handle, wrapper) def getObjectById_5A8164ECEDB03F09(self, handle, wrapper): # First 64 bits of SHA1 of a string: "Lib3MF::Model" return Model(handle, wrapper) @@ -6783,6 +6835,42 @@ def SetUUID(self, UUID): +''' Class Implementation for NameSpaceIterator +''' +class NameSpaceIterator(Base): + def __init__(self, handle, wrapper): + Base.__init__(self, handle, wrapper) + def MoveNext(self): + pHasNext = ctypes.c_bool() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_namespaceiterator_movenext(self._handle, pHasNext)) + + return pHasNext.value + + def MovePrevious(self): + pHasPrevious = ctypes.c_bool() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_namespaceiterator_moveprevious(self._handle, pHasPrevious)) + + return pHasPrevious.value + + def GetCurrent(self): + nNameSpaceBufferSize = ctypes.c_uint64(0) + nNameSpaceNeededChars = ctypes.c_uint64(0) + pNameSpaceBuffer = ctypes.c_char_p(None) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_namespaceiterator_getcurrent(self._handle, nNameSpaceBufferSize, nNameSpaceNeededChars, pNameSpaceBuffer)) + nNameSpaceBufferSize = ctypes.c_uint64(nNameSpaceNeededChars.value) + pNameSpaceBuffer = (ctypes.c_char * (nNameSpaceNeededChars.value))() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_namespaceiterator_getcurrent(self._handle, nNameSpaceBufferSize, nNameSpaceNeededChars, pNameSpaceBuffer)) + + return pNameSpaceBuffer.value.decode() + + def Count(self): + pCount = ctypes.c_uint64() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_namespaceiterator_count(self._handle, pCount)) + + return pCount.value + + + ''' Class Implementation for Model ''' class Model(Base): @@ -7372,4 +7460,14 @@ def GetKeyStore(self): return KeyStoreObject + def GetRequiredNameSpaces(self): + NameSpaceIteratorHandle = ctypes.c_void_p() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_model_getrequirednamespaces(self._handle, NameSpaceIteratorHandle)) + if NameSpaceIteratorHandle: + NameSpaceIteratorObject = self._wrapper._polymorphicFactory(NameSpaceIteratorHandle) + else: + raise ELib3MFException(ErrorCodes.INVALIDCAST, 'Invalid return/output value') + + return NameSpaceIteratorObject + diff --git a/Autogenerated/Source/lib3mf_abi.hpp b/Autogenerated/Source/lib3mf_abi.hpp index 455bd3225..7e493f3f2 100644 --- a/Autogenerated/Source/lib3mf_abi.hpp +++ b/Autogenerated/Source/lib3mf_abi.hpp @@ -2047,7 +2047,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_setrelationshiptype(Lib3MF_Attach LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetofile(Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2056,7 +2056,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetofile(Lib3MF_Attachment pAt LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_readfromfile(Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads a model and from the data provided by a callback function +* Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2088,7 +2088,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_getstreamsize(Lib3MF_Attachment p LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetobuffer(Lib3MF_Attachment pAttachment, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); /** -* Reads an attachment from a memory buffer +* Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferBufferSize - Number of elements in buffer @@ -2954,6 +2954,48 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getuuid(Lib3MF_KeyStore pKeyStore, */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_setuuid(Lib3MF_KeyStore pKeyStore, const char * pUUID); +/************************************************************************************************************************* + Class definition for NameSpaceIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasNext - Iterates to the namespace in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_movenext(Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext); + +/** +* Iterates to the previous namespace in the list. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pHasPrevious - Iterates to the previous required namespace in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_moveprevious(Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious); + +/** +* Returns the required namespace the iterator points at. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of returns the namespace., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_getcurrent(Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + +/** +* Returns the number of namespaces the iterator captures. +* +* @param[in] pNameSpaceIterator - NameSpaceIterator instance. +* @param[out] pCount - returns the number of namspaces the iterator captures. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_namespaceiterator_count(Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount); + /************************************************************************************************************************* Class definition for Model **************************************************************************************************************************/ @@ -3528,6 +3570,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_setrandomnumbercallback(Lib3MF_Model p */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getkeystore(Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); +/** +* Gets the list of required namespaces for the model +* +* @param[in] pModel - Model instance. +* @param[out] pNameSpaceIterator - The required namespace iterator +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getrequirednamespaces(Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ diff --git a/Autogenerated/Source/lib3mf_interfaces.hpp b/Autogenerated/Source/lib3mf_interfaces.hpp index 8bc997a12..c937e825e 100644 --- a/Autogenerated/Source/lib3mf_interfaces.hpp +++ b/Autogenerated/Source/lib3mf_interfaces.hpp @@ -92,6 +92,7 @@ class IContentEncryptionParams; class IResourceData; class IResourceDataGroup; class IKeyStore; +class INameSpaceIterator; class IModel; @@ -2132,13 +2133,13 @@ class IAttachment : public virtual IBase { virtual void WriteToFile(const std::string & sFileName) = 0; /** - * IAttachment::ReadFromFile - Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. + * IAttachment::ReadFromFile - Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * @param[in] sFileName - file to read from. */ virtual void ReadFromFile(const std::string & sFileName) = 0; /** - * IAttachment::ReadFromCallback - Reads a model and from the data provided by a callback function + * IAttachment::ReadFromCallback - Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer-methods. * @param[in] pTheReadCallback - callback function * @param[in] nStreamSize - number of bytes the callback returns * @param[in] pTheSeekCallback - callback function @@ -2161,7 +2162,7 @@ class IAttachment : public virtual IBase { virtual void WriteToBuffer(Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer) = 0; /** - * IAttachment::ReadFromBuffer - Reads an attachment from a memory buffer + * IAttachment::ReadFromBuffer - Reads an attachment from a memory buffer. This buffer is immediatly read (in contrast to the ReadFromCallback and ReadFromFile-methods). * @param[in] nBufferBufferSize - Number of elements in buffer * @param[in] pBufferBuffer - Buffer to read from */ @@ -2938,6 +2939,50 @@ class IKeyStore : public virtual IBase { typedef IBaseSharedPtr PIKeyStore; +/************************************************************************************************************************* + Class interface for NameSpaceIterator +**************************************************************************************************************************/ + +class INameSpaceIterator : public virtual IBase { +public: + /** + * INameSpaceIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x8D1206A0FEEFCC31UL; // First 64 bits of SHA1 of a string: "Lib3MF::NameSpaceIterator" + } + + /** + * INameSpaceIterator::MoveNext - Iterates to the next namespace in the list. + * @return Iterates to the namespace in the list. + */ + virtual bool MoveNext() = 0; + + /** + * INameSpaceIterator::MovePrevious - Iterates to the previous namespace in the list. + * @return Iterates to the previous required namespace in the list. + */ + virtual bool MovePrevious() = 0; + + /** + * INameSpaceIterator::GetCurrent - Returns the required namespace the iterator points at. + * @return returns the namespace. + */ + virtual std::string GetCurrent() = 0; + + /** + * INameSpaceIterator::Count - Returns the number of namespaces the iterator captures. + * @return returns the number of namspaces the iterator captures. + */ + virtual Lib3MF_uint64 Count() = 0; + +}; + +typedef IBaseSharedPtr PINameSpaceIterator; + + /************************************************************************************************************************* Class interface for Model **************************************************************************************************************************/ @@ -3339,6 +3384,12 @@ class IModel : public virtual IBase { */ virtual IKeyStore * GetKeyStore() = 0; + /** + * IModel::GetRequiredNameSpaces - Gets the list of required namespaces for the model + * @return The required namespace iterator + */ + virtual INameSpaceIterator * GetRequiredNameSpaces() = 0; + }; typedef IBaseSharedPtr PIModel; diff --git a/Autogenerated/Source/lib3mf_interfacewrapper.cpp b/Autogenerated/Source/lib3mf_interfacewrapper.cpp index 8b3d7d174..a26f0729e 100644 --- a/Autogenerated/Source/lib3mf_interfacewrapper.cpp +++ b/Autogenerated/Source/lib3mf_interfacewrapper.cpp @@ -10534,6 +10534,168 @@ Lib3MFResult lib3mf_keystore_setuuid(Lib3MF_KeyStore pKeyStore, const char * pUU } +/************************************************************************************************************************* + Class implementation for NameSpaceIterator +**************************************************************************************************************************/ +Lib3MFResult lib3mf_namespaceiterator_movenext(Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext) +{ + IBase* pIBaseClass = (IBase *)pNameSpaceIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNameSpaceIterator, "NameSpaceIterator", "MoveNext"); + } + if (pHasNext == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + INameSpaceIterator* pINameSpaceIterator = dynamic_cast(pIBaseClass); + if (!pINameSpaceIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pHasNext = pINameSpaceIterator->MoveNext(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("HasNext", *pHasNext); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_namespaceiterator_moveprevious(Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious) +{ + IBase* pIBaseClass = (IBase *)pNameSpaceIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNameSpaceIterator, "NameSpaceIterator", "MovePrevious"); + } + if (pHasPrevious == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + INameSpaceIterator* pINameSpaceIterator = dynamic_cast(pIBaseClass); + if (!pINameSpaceIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pHasPrevious = pINameSpaceIterator->MovePrevious(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("HasPrevious", *pHasPrevious); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_namespaceiterator_getcurrent(Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer) +{ + IBase* pIBaseClass = (IBase *)pNameSpaceIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNameSpaceIterator, "NameSpaceIterator", "GetCurrent"); + } + if ( (!pNameSpaceBuffer) && !(pNameSpaceNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sNameSpace(""); + INameSpaceIterator* pINameSpaceIterator = dynamic_cast(pIBaseClass); + if (!pINameSpaceIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pNameSpaceBuffer == nullptr); + if (isCacheCall) { + sNameSpace = pINameSpaceIterator->GetCurrent(); + + pINameSpaceIterator->_setCache (new ParameterCache_1 (sNameSpace)); + } + else { + auto cache = dynamic_cast*> (pINameSpaceIterator->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sNameSpace); + pINameSpaceIterator->_setCache (nullptr); + } + + if (pNameSpaceNeededChars) + *pNameSpaceNeededChars = (Lib3MF_uint32) (sNameSpace.size()+1); + if (pNameSpaceBuffer) { + if (sNameSpace.size() >= nNameSpaceBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iNameSpace = 0; iNameSpace < sNameSpace.size(); iNameSpace++) + pNameSpaceBuffer[iNameSpace] = sNameSpace[iNameSpace]; + pNameSpaceBuffer[sNameSpace.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("NameSpace", sNameSpace.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_namespaceiterator_count(Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount) +{ + IBase* pIBaseClass = (IBase *)pNameSpaceIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNameSpaceIterator, "NameSpaceIterator", "Count"); + } + if (pCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + INameSpaceIterator* pINameSpaceIterator = dynamic_cast(pIBaseClass); + if (!pINameSpaceIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pCount = pINameSpaceIterator->Count(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt64Result("Count", *pCount); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + /************************************************************************************************************************* Class implementation for Model **************************************************************************************************************************/ @@ -12779,6 +12941,42 @@ Lib3MFResult lib3mf_model_getkeystore(Lib3MF_Model pModel, Lib3MF_KeyStore * pKe } } +Lib3MFResult lib3mf_model_getrequirednamespaces(Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "GetRequiredNameSpaces"); + } + if (pNameSpaceIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseNameSpaceIterator(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNameSpaceIterator = pIModel->GetRequiredNameSpaces(); + + *pNameSpaceIterator = (IBase*)(pBaseNameSpaceIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("NameSpaceIterator", *pNameSpaceIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + /************************************************************************************************************************* @@ -13354,6 +13552,14 @@ Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void * *ppProcAddress = (void*) &lib3mf_keystore_getuuid; if (sProcName == "lib3mf_keystore_setuuid") *ppProcAddress = (void*) &lib3mf_keystore_setuuid; + if (sProcName == "lib3mf_namespaceiterator_movenext") + *ppProcAddress = (void*) &lib3mf_namespaceiterator_movenext; + if (sProcName == "lib3mf_namespaceiterator_moveprevious") + *ppProcAddress = (void*) &lib3mf_namespaceiterator_moveprevious; + if (sProcName == "lib3mf_namespaceiterator_getcurrent") + *ppProcAddress = (void*) &lib3mf_namespaceiterator_getcurrent; + if (sProcName == "lib3mf_namespaceiterator_count") + *ppProcAddress = (void*) &lib3mf_namespaceiterator_count; if (sProcName == "lib3mf_model_rootmodelpart") *ppProcAddress = (void*) &lib3mf_model_rootmodelpart; if (sProcName == "lib3mf_model_findorcreatepackagepart") @@ -13474,6 +13680,8 @@ Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void * *ppProcAddress = (void*) &lib3mf_model_setrandomnumbercallback; if (sProcName == "lib3mf_model_getkeystore") *ppProcAddress = (void*) &lib3mf_model_getkeystore; + if (sProcName == "lib3mf_model_getrequirednamespaces") + *ppProcAddress = (void*) &lib3mf_model_getrequirednamespaces; if (sProcName == "lib3mf_getlibraryversion") *ppProcAddress = (void*) &lib3mf_getlibraryversion; if (sProcName == "lib3mf_getprereleaseinformation") diff --git a/Autogenerated/Source/lib3mf_types.hpp b/Autogenerated/Source/lib3mf_types.hpp index e9c0bdad5..5f3f9b44e 100644 --- a/Autogenerated/Source/lib3mf_types.hpp +++ b/Autogenerated/Source/lib3mf_types.hpp @@ -236,6 +236,7 @@ typedef Lib3MFHandle Lib3MF_ContentEncryptionParams; typedef Lib3MFHandle Lib3MF_ResourceData; typedef Lib3MFHandle Lib3MF_ResourceDataGroup; typedef Lib3MFHandle Lib3MF_KeyStore; +typedef Lib3MFHandle Lib3MF_NameSpaceIterator; typedef Lib3MFHandle Lib3MF_Model; namespace Lib3MF { diff --git a/AutomaticComponentToolkit/lib3mf.xml b/AutomaticComponentToolkit/lib3mf.xml index 26b0c171e..14f35d50c 100644 --- a/AutomaticComponentToolkit/lib3mf.xml +++ b/AutomaticComponentToolkit/lib3mf.xml @@ -1398,6 +1398,21 @@ + + + + + + + + + + + + + + + @@ -1605,6 +1620,10 @@ + + + + diff --git a/Include/API/lib3mf_model.hpp b/Include/API/lib3mf_model.hpp index d491ea086..df0c9dc18 100644 --- a/Include/API/lib3mf_model.hpp +++ b/Include/API/lib3mf_model.hpp @@ -195,9 +195,12 @@ class CModel : public virtual IModel, public virtual CBase { Lib3MF::sBox GetOutbox() override; - IKeyStore * GetKeyStore(); + IKeyStore * GetKeyStore() override; - void SetRandomNumberCallback(const Lib3MF::RandomNumberCallback pTheCallback, const Lib3MF_pvoid pUserData); + void SetRandomNumberCallback(const Lib3MF::RandomNumberCallback pTheCallback, const Lib3MF_pvoid pUserData) override; + + + INameSpaceIterator * GetRequiredNameSpaces() override; }; } diff --git a/Include/API/lib3mf_namespaceiterator.hpp b/Include/API/lib3mf_namespaceiterator.hpp new file mode 100644 index 000000000..6af77bb9f --- /dev/null +++ b/Include/API/lib3mf_namespaceiterator.hpp @@ -0,0 +1,111 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CNameSpaceIterator + +*/ + + +#ifndef __LIB3MF_NAMESPACEITERATOR +#define __LIB3MF_NAMESPACEITERATOR + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CNameSpaceIterator +**************************************************************************************************************************/ + +class CNameSpaceIterator : public virtual INameSpaceIterator, public virtual CBase { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * INameSpaceIterator::MoveNext - Iterates to the next namespace in the list. + * @return Iterates to the namespace in the list. + */ + bool MoveNext() override; + + /** + * INameSpaceIterator::MovePrevious - Iterates to the previous namespace in the list. + * @return Iterates to the previous required namespace in the list. + */ + bool MovePrevious() override; + + /** + * INameSpaceIterator::GetCurrent - Returns the required namespace the iterator points at. + * @return returns the namespace. + */ + std::string GetCurrent() override; + + /** + * INameSpaceIterator::Count - Returns the number of namespaces the iterator captures. + * @return returns the number of namspaces the iterator captures. + */ + Lib3MF_uint64 Count() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_NAMESPACEITERATOR diff --git a/Source/API/lib3mf_model.cpp b/Source/API/lib3mf_model.cpp index 69f57312f..9179e27ea 100644 --- a/Source/API/lib3mf_model.cpp +++ b/Source/API/lib3mf_model.cpp @@ -34,32 +34,33 @@ Abstract: This is a stub class definition of CModel #include "lib3mf_reader.hpp" #include "lib3mf_writer.hpp" +#include "lib3mf_attachment.hpp" +#include "lib3mf_basematerialgroup.hpp" +#include "lib3mf_basematerialgroupiterator.hpp" #include "lib3mf_builditem.hpp" #include "lib3mf_builditemiterator.hpp" -#include "lib3mf_meshobject.hpp" -#include "lib3mf_objectiterator.hpp" -#include "lib3mf_meshobjectiterator.hpp" -#include "lib3mf_resourceiterator.hpp" +#include "lib3mf_colorgroup.hpp" +#include "lib3mf_colorgroupiterator.hpp" #include "lib3mf_componentsobject.hpp" #include "lib3mf_componentsobjectiterator.hpp" -#include "lib3mf_basematerialgroup.hpp" +#include "lib3mf_compositematerials.hpp" +#include "lib3mf_compositematerialsiterator.hpp" +#include "lib3mf_keystore.hpp" +#include "lib3mf_meshobject.hpp" +#include "lib3mf_meshobjectiterator.hpp" #include "lib3mf_metadatagroup.hpp" -#include "lib3mf_attachment.hpp" +#include "lib3mf_multipropertygroup.hpp" +#include "lib3mf_multipropertygroupiterator.hpp" +#include "lib3mf_namespaceiterator.hpp" +#include "lib3mf_objectiterator.hpp" +#include "lib3mf_packagepart.hpp" +#include "lib3mf_resourceiterator.hpp" #include "lib3mf_slicestack.hpp" #include "lib3mf_slicestackiterator.hpp" #include "lib3mf_texture2d.hpp" -#include "lib3mf_texture2diterator.hpp" -#include "lib3mf_basematerialgroupiterator.hpp" -#include "lib3mf_colorgroup.hpp" -#include "lib3mf_colorgroupiterator.hpp" #include "lib3mf_texture2dgroup.hpp" #include "lib3mf_texture2dgroupiterator.hpp" -#include "lib3mf_compositematerials.hpp" -#include "lib3mf_compositematerialsiterator.hpp" -#include "lib3mf_multipropertygroup.hpp" -#include "lib3mf_multipropertygroupiterator.hpp" -#include "lib3mf_packagepart.hpp" -#include "lib3mf_keystore.hpp" +#include "lib3mf_texture2diterator.hpp" // Include custom headers here. @@ -764,3 +765,19 @@ void Lib3MF::Impl::CModel::SetRandomNumberCallback(Lib3MF::RandomNumberCallback m_model->setCryptoRandCallback(descriptor); } +// auto pResult = std::unique_ptr(new CBuildItemIterator()); +// Lib3MF_uint32 nBuildItemCount = m_model->getBuildItemCount(); +// Lib3MF_uint32 nIdx; + +// for (nIdx = 0; nIdx < nBuildItemCount; nIdx++) +// pResult->addBuildItem(m_model->getBuildItem(nIdx)); + +// return pResult.release(); +INameSpaceIterator * CModel::GetRequiredNameSpaces() +{ + auto pResult = std::unique_ptr(new CNameSpaceIterator()); + + //ToDo: Add namespaces + + return pResult.release(); +} diff --git a/Source/API/lib3mf_namespaceiterator.cpp b/Source/API/lib3mf_namespaceiterator.cpp new file mode 100644 index 000000000..5bdedfff3 --- /dev/null +++ b/Source/API/lib3mf_namespaceiterator.cpp @@ -0,0 +1,62 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CNameSpaceIterator + +*/ + +#include "lib3mf_namespaceiterator.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CNameSpaceIterator +**************************************************************************************************************************/ + +bool CNameSpaceIterator::MoveNext() +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +bool CNameSpaceIterator::MovePrevious() +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +std::string CNameSpaceIterator::GetCurrent() +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +Lib3MF_uint64 CNameSpaceIterator::Count() +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 68df6e414..352fa3484 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -72,6 +72,7 @@ Source/API/lib3mf_texture2dgroupiterator.cpp Source/API/lib3mf_texture2diterator.cpp Source/API/lib3mf_writer.cpp Source/API/lib3mf_utils.cpp +Source/API/lib3mf_namespaceiterator.cpp Source/Common/3MF_ProgressMonitor.cpp Source/Common/Math/NMR_Matrix.cpp Source/Common/Math/NMR_PairMatchingTree.cpp diff --git a/Tests/googletest b/Tests/googletest index b796f7d44..8b6d3f9c4 160000 --- a/Tests/googletest +++ b/Tests/googletest @@ -1 +1 @@ -Subproject commit b796f7d44681514f58a683a3a71ff17c94edb0c1 +Subproject commit 8b6d3f9c4a774bef3081195d422993323b6bb2e0 From 0ae7c434c430aaa2f844dc97a22d09723604811d Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:05:06 +0100 Subject: [PATCH 04/12] Add namespace functionality to lib3mf_namespaceiterator and CModel --- Include/API/lib3mf_namespaceiterator.hpp | 3 ++ Include/Model/Classes/NMR_Model.h | 6 ++++ Source/API/lib3mf_namespaceiterator.cpp | 40 +++++++++++++++++++----- Source/Model/Classes/NMR_Model.cpp | 18 +++++++++++ 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/Include/API/lib3mf_namespaceiterator.hpp b/Include/API/lib3mf_namespaceiterator.hpp index 6af77bb9f..8b6a9cf5f 100644 --- a/Include/API/lib3mf_namespaceiterator.hpp +++ b/Include/API/lib3mf_namespaceiterator.hpp @@ -58,6 +58,8 @@ class CNameSpaceIterator : public virtual INameSpaceIterator, public virtual CBa /** * Put private members here. */ + std::vector m_namespaces; + Lib3MF_int32 m_nCurrentIndex = -1; protected: @@ -71,6 +73,7 @@ class CNameSpaceIterator : public virtual INameSpaceIterator, public virtual CBa * Put additional public members here. They will not be visible in the external API. */ + void setNameSpaces(std::vector&& namespaces); /** * Public member functions to implement. diff --git a/Include/Model/Classes/NMR_Model.h b/Include/Model/Classes/NMR_Model.h index ebb114608..f549b0b9f 100644 --- a/Include/Model/Classes/NMR_Model.h +++ b/Include/Model/Classes/NMR_Model.h @@ -96,6 +96,9 @@ namespace NMR { typedef std::map UniqueResourceIDMapping; + + using NameSpaces = std::vector; + // The Model class implements the unification of all model-file in a 3MF package // It should be understood as a "MultiModel" class CModel { @@ -327,6 +330,9 @@ namespace NMR { nfBool hasCryptoRandCallbak() const; nfUint64 generateRandomBytes(nfByte *, nfUint64); + /// @brief Determines the namespaces that are required by the model + /// @return The namespaces that are required by the model + NameSpaces getRequiredNameSpaces(); }; typedef std::shared_ptr PModel; diff --git a/Source/API/lib3mf_namespaceiterator.cpp b/Source/API/lib3mf_namespaceiterator.cpp index 5bdedfff3..cb39cd564 100644 --- a/Source/API/lib3mf_namespaceiterator.cpp +++ b/Source/API/lib3mf_namespaceiterator.cpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,15 +24,13 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Abstract: This is a stub class definition of CNameSpaceIterator +Abstract: Iterator for namespaces */ #include "lib3mf_namespaceiterator.hpp" #include "lib3mf_interfaceexception.hpp" -// Include custom headers here. - using namespace Lib3MF::Impl; @@ -42,21 +40,47 @@ using namespace Lib3MF::Impl; bool CNameSpaceIterator::MoveNext() { - throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); + Lib3MF_int32 count = (Lib3MF_int32)m_namespaces.size(); + m_nCurrentIndex++; + + // Check new Index + if (m_nCurrentIndex >= count) { + m_nCurrentIndex = count; + return false; + } + else { + return true; + } } bool CNameSpaceIterator::MovePrevious() { - throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); + m_nCurrentIndex--; + + // Check new Index + if (m_nCurrentIndex < 0) { + m_nCurrentIndex = -1; + return false; + } + else { + return true; + } } std::string CNameSpaceIterator::GetCurrent() { - throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); + if ((m_nCurrentIndex < 0) || (m_nCurrentIndex >= (Lib3MF_int32)m_namespaces.size())) + throw ELib3MFInterfaceException(LIB3MF_ERROR_ITERATORINVALIDINDEX); + + return m_namespaces[m_nCurrentIndex]; } Lib3MF_uint64 CNameSpaceIterator::Count() { - throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); + return (Lib3MF_uint64)m_namespaces.size(); } +void Lib3MF::Impl::CNameSpaceIterator::setNameSpaces(std::vector &&nameSpaces) +{ + m_namespaces = std::move(nameSpaces); +} diff --git a/Source/Model/Classes/NMR_Model.cpp b/Source/Model/Classes/NMR_Model.cpp index 3a92be985..73baa20ed 100644 --- a/Source/Model/Classes/NMR_Model.cpp +++ b/Source/Model/Classes/NMR_Model.cpp @@ -1315,4 +1315,22 @@ namespace NMR { return size; } + NameSpaces CModel::getRequiredNameSpaces() + { + static const NameSpaces ExtensionNameSpaces {XML_3MF_NAMESPACE_MATERIALSPEC, + XML_3MF_NAMESPACE_PRODUCTIONSPEC, + XML_3MF_NAMESPACE_BEAMLATTICESPEC, + XML_3MF_NAMESPACE_SLICESPEC, + XML_3MF_NAMESPACE_SECURECONTENTSPEC, + XML_3MF_NAMESPACE_DIGITALSIGNATURESPEC, + XML_3MF_NAMESPACE_CIPHERVALUESPEC}; + + NameSpaces requiredNameSpaces; + for (auto const &nameSpace : ExtensionNameSpaces) { + if (RequireExtension(nameSpace)) { + requiredNameSpaces.push_back(nameSpace); + } + } + return requiredNameSpaces; + } } From 334a8d36b559efbcfb5105199ba2fbeaf3b2e635 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:42:56 +0100 Subject: [PATCH 05/12] Set namespaces in GetRequiredNameSpaces() method --- Source/API/lib3mf_model.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Source/API/lib3mf_model.cpp b/Source/API/lib3mf_model.cpp index 9179e27ea..e658bb9d8 100644 --- a/Source/API/lib3mf_model.cpp +++ b/Source/API/lib3mf_model.cpp @@ -765,19 +765,11 @@ void Lib3MF::Impl::CModel::SetRandomNumberCallback(Lib3MF::RandomNumberCallback m_model->setCryptoRandCallback(descriptor); } -// auto pResult = std::unique_ptr(new CBuildItemIterator()); -// Lib3MF_uint32 nBuildItemCount = m_model->getBuildItemCount(); -// Lib3MF_uint32 nIdx; - -// for (nIdx = 0; nIdx < nBuildItemCount; nIdx++) -// pResult->addBuildItem(m_model->getBuildItem(nIdx)); - -// return pResult.release(); INameSpaceIterator * CModel::GetRequiredNameSpaces() { auto pResult = std::unique_ptr(new CNameSpaceIterator()); - //ToDo: Add namespaces + pResult->setNameSpaces(std::move(m_model->getRequiredNameSpaces())); return pResult.release(); } From 51c0245dcbe33741c25fca6f56246f5e4ab5f2a6 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:43:12 +0100 Subject: [PATCH 06/12] Add tests for GetRequiredNamespaces function in Model class --- Tests/CPP_Bindings/Source/Model.cpp | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Tests/CPP_Bindings/Source/Model.cpp b/Tests/CPP_Bindings/Source/Model.cpp index 75768635a..9aea10a03 100644 --- a/Tests/CPP_Bindings/Source/Model.cpp +++ b/Tests/CPP_Bindings/Source/Model.cpp @@ -175,4 +175,47 @@ namespace Lib3MF ASSERT_EQ(oldID, newId); } + TEST_F(Model, GetRequiredNamespaces_NoExtensions_IsEmpty) + { + auto requiredNamespaces = m_pModel->GetRequiredNameSpaces(); + ASSERT_TRUE(requiredNamespaces); + EXPECT_EQ(requiredNamespaces->Count(), 0u); + } + + TEST_F(Model, GetRequiredNamespaces_BeamLatticeExtension_ContainsBeamLattice) + { + auto model = wrapper->CreateModel(); // create a new model to avoid interference with other tests + auto mesh = model->AddMeshObject(); + auto beamLattice = mesh->BeamLattice(); + + ASSERT_TRUE(model); + ASSERT_TRUE(mesh); + ASSERT_TRUE(beamLattice); + + sPosition p; + p.m_Coordinates[0] = 0; + p.m_Coordinates[1] = 0; + p.m_Coordinates[2] = 0; + mesh->AddVertex(p); + + p.m_Coordinates[1] = 1; + mesh->AddVertex(p); + + p.m_Coordinates[2] = 1; + mesh->AddVertex(p); + + sBeam beam; + beam.m_Radii[0] = 1.0; + beam.m_Radii[1] = 1.0; + beam.m_Indices[0] = 0; + beam.m_Indices[1] = 1; + beamLattice->AddBeam(beam); + + auto requiredNamespaces = model->GetRequiredNameSpaces(); + ASSERT_TRUE(requiredNamespaces); + EXPECT_EQ(requiredNamespaces->Count(), 1u); + EXPECT_EQ(requiredNamespaces->MoveNext(), true); + EXPECT_EQ(requiredNamespaces->GetCurrent(), "http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02"); + EXPECT_EQ(requiredNamespaces->MoveNext(), false); + } } From 12f34f7f6988e6efcc22deaa33791a5cdabaff05 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:11:58 +0100 Subject: [PATCH 07/12] Store required namespaces found while parsing model --- Include/Model/Classes/NMR_Model.h | 4 ++ Source/Model/Classes/NMR_Model.cpp | 42 +++++++++++++------ .../Reader/NMR_ModelReaderNode_ModelBase.cpp | 2 + Tests/CPP_Bindings/Source/Model.cpp | 17 ++++++++ 4 files changed, 53 insertions(+), 12 deletions(-) diff --git a/Include/Model/Classes/NMR_Model.h b/Include/Model/Classes/NMR_Model.h index f549b0b9f..1baadffab 100644 --- a/Include/Model/Classes/NMR_Model.h +++ b/Include/Model/Classes/NMR_Model.h @@ -156,6 +156,8 @@ namespace NMR { CryptoRandGenDescriptor m_sRandDescriptor; + NameSpaces m_requiredNameSpaces; + // Add Resource to resource lookup tables void addResourceToLookupTable(_In_ PModelResource pResource); @@ -330,6 +332,8 @@ namespace NMR { nfBool hasCryptoRandCallbak() const; nfUint64 generateRandomBytes(nfByte *, nfUint64); + + void registerRequiredNameSpace(std::string const& nameSpace); /// @brief Determines the namespaces that are required by the model /// @return The namespaces that are required by the model NameSpaces getRequiredNameSpaces(); diff --git a/Source/Model/Classes/NMR_Model.cpp b/Source/Model/Classes/NMR_Model.cpp index 73baa20ed..6708b77dc 100644 --- a/Source/Model/Classes/NMR_Model.cpp +++ b/Source/Model/Classes/NMR_Model.cpp @@ -1315,22 +1315,40 @@ namespace NMR { return size; } - NameSpaces CModel::getRequiredNameSpaces() + void CModel::registerRequiredNameSpace(std::string const&nameSpace) { - static const NameSpaces ExtensionNameSpaces {XML_3MF_NAMESPACE_MATERIALSPEC, - XML_3MF_NAMESPACE_PRODUCTIONSPEC, - XML_3MF_NAMESPACE_BEAMLATTICESPEC, - XML_3MF_NAMESPACE_SLICESPEC, - XML_3MF_NAMESPACE_SECURECONTENTSPEC, - XML_3MF_NAMESPACE_DIGITALSIGNATURESPEC, - XML_3MF_NAMESPACE_CIPHERVALUESPEC}; - + m_requiredNameSpaces.push_back(nameSpace); + } + + NameSpaces CModel::getRequiredNameSpaces() + { + static const NameSpaces knownExtensionNameSpaces{XML_3MF_NAMESPACE_MATERIALSPEC, + XML_3MF_NAMESPACE_PRODUCTIONSPEC, + XML_3MF_NAMESPACE_BEAMLATTICESPEC, + XML_3MF_NAMESPACE_SLICESPEC, + XML_3MF_NAMESPACE_SECURECONTENTSPEC, + XML_3MF_NAMESPACE_DIGITALSIGNATURESPEC, + XML_3MF_NAMESPACE_CIPHERVALUESPEC}; + NameSpaces requiredNameSpaces; - for (auto const &nameSpace : ExtensionNameSpaces) { - if (RequireExtension(nameSpace)) { + + // Add all namespaces from m_requiredExtensions that are not in knownExtensionNameSpaces to requiredNameSpaces + for (auto const &nameSpace : m_requiredNameSpaces) + { + if (std::find(knownExtensionNameSpaces.begin(), knownExtensionNameSpaces.end(), nameSpace) == knownExtensionNameSpaces.end()) + { + requiredNameSpaces.push_back(nameSpace); + } + } + + // For the namespaces this version of lib3mf knows, we test if the namespace is required by the model + for (auto const &nameSpace : knownExtensionNameSpaces) + { + if (RequireExtension(nameSpace)) + { requiredNameSpaces.push_back(nameSpace); } } return requiredNameSpaces; - } + } } diff --git a/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp b/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp index 710ac8867..283c54e0b 100644 --- a/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp +++ b/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp @@ -80,6 +80,8 @@ namespace NMR { } // is the extension supported? std::string sExtensionURI = m_ListedExtensions[token]; + m_pModel->registerRequiredNameSpace(sExtensionURI); + if (strcmp(sExtensionURI.c_str(), PACKAGE_XMLNS_100) != 0 && strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_MATERIALSPEC) != 0 && strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_PRODUCTIONSPEC) != 0 && diff --git a/Tests/CPP_Bindings/Source/Model.cpp b/Tests/CPP_Bindings/Source/Model.cpp index 9aea10a03..cdf31efce 100644 --- a/Tests/CPP_Bindings/Source/Model.cpp +++ b/Tests/CPP_Bindings/Source/Model.cpp @@ -218,4 +218,21 @@ namespace Lib3MF EXPECT_EQ(requiredNamespaces->GetCurrent(), "http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02"); EXPECT_EQ(requiredNamespaces->MoveNext(), false); } + + TEST_F(Model, GetRequiredNamespaces_3mfFileWithUnknownExtension_ContainsUnknownNameSpace) + { + auto model = wrapper->CreateModel(); // create a new model to avoid interference with other tests + auto reader3MF = model->QueryReader("3mf"); + + + ASSERT_TRUE(reader3MF); + reader3MF->ReadFromFile(sTestFilesPath + "/RequiredExtensions/" + "Unsupported.3mf"); + EXPECT_GE(reader3MF->GetWarningCount(), 1u); + auto requiredNameSpaces = model->GetRequiredNameSpaces(); + + EXPECT_TRUE(requiredNameSpaces->MoveNext()); + std::string const fictionalNameSpace = "http://schemas.autodesk.com/dmg/ExtensionUnsupported/2999/12"; + EXPECT_EQ(requiredNameSpaces->GetCurrent(), fictionalNameSpace); + EXPECT_FALSE(requiredNameSpaces->MoveNext()); + } } From 0f3ab86ba0c4fea22e3f0e822fbb2d4b4b58ae75 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:07:14 +0100 Subject: [PATCH 08/12] Add option to build as static library --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe8004a5f..cbd8689a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option(USE_INCLUDED_SSL "Use included libressl" ON) option(BUILD_FOR_CODECOVERAGE "Build for code coverage analysis" OFF) option(STRIP_BINARIES "Strip binaries (on non-apple)" ON) option(USE_PLATFORM_UUID "Use UUID geneator that is provided by the OS (always ON for Windows)" OFF) +option(BUILD_AS_STATIC_LIB "Build as static lib (default=OFF)" OFF) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # using GCC @@ -108,10 +109,18 @@ endif() ######################################################### # Shared library -add_library(${PROJECT_NAME} SHARED ${SRCS_COMMON} ${HDRS_COMMON} - ${ACT_GENERATED_SOURCE} - ${VERSION_FILES_OUTPUTLOCATION} +if (BUILD_AS_STATIC_LIB) + add_library(${PROJECT_NAME} STATIC ${SRCS_COMMON} ${HDRS_COMMON} + ${ACT_GENERATED_SOURCE} + ${VERSION_FILES_OUTPUTLOCATION} ) +else() + add_library(${PROJECT_NAME} SHARED ${SRCS_COMMON} ${HDRS_COMMON} + ${ACT_GENERATED_SOURCE} + ${VERSION_FILES_OUTPUTLOCATION} +) +endif() + SOURCE_GROUP("Source Files\\Autogenerated" FILES ${ACT_GENERATED_SOURCE}) From 8e9464915c5f3279ac7b0d9664a2f224d364d4ec Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:16:36 +0100 Subject: [PATCH 09/12] [.gitignore] Remove conflicting entries and clean up ignored files; [lib3mf_dynamic.cc] Fix initialization of required namespaces in wrapper table --- .gitignore | 4 ---- Autogenerated/Bindings/Go/lib3mf_dynamic.cc | 11 ++++------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 10f6ff772..863438904 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,7 @@ Include/Model/COM/NMR_COMVersion.h debug .DS_Store .vscode -<<<<<<< HEAD .vs -======= TestOutput nonrootmodels.3mf SetupWriteRead1.3mf @@ -16,7 +14,5 @@ SetupWriteRead3.3mf SetupWriteRead4.3mf SetupWriteRead5.3mf v093reout.3mf -.vs .idea cmake-build-* ->>>>>>> 3732957fa520612a7156de3e01d935ec2569de07 diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc index f992001ac..cef9bc704 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc @@ -628,9 +628,6 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_RemoveCustomContentType = NULL; pWrapperTable->m_Model_SetRandomNumberCallback = NULL; pWrapperTable->m_Model_GetKeyStore = NULL; -<<<<<<< HEAD - pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; -======= pWrapperTable->m_Model_GetFunctions = NULL; pWrapperTable->m_Model_AddImplicitFunction = NULL; pWrapperTable->m_Model_AddFunctionFromImage3D = NULL; @@ -638,7 +635,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_AddLevelSet = NULL; pWrapperTable->m_Model_GetLevelSets = NULL; pWrapperTable->m_Model_RemoveResource = NULL; ->>>>>>> 3732957fa520612a7156de3e01d935ec2569de07 + pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -5933,14 +5930,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 -<<<<<<< HEAD pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) GetProcAddress(hLibrary, "lib3mf_model_getrequirednamespaces"); #else // _WIN32 pWrapperTable->m_Model_GetRequiredNameSpaces = (PLib3MFModel_GetRequiredNameSpacesPtr) dlsym(hLibrary, "lib3mf_model_getrequirednamespaces"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Model_GetRequiredNameSpaces == NULL) -======= + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 pWrapperTable->m_Model_GetFunctions = (PLib3MFModel_GetFunctionsPtr) GetProcAddress(hLibrary, "lib3mf_model_getfunctions"); #else // _WIN32 pWrapperTable->m_Model_GetFunctions = (PLib3MFModel_GetFunctionsPtr) dlsym(hLibrary, "lib3mf_model_getfunctions"); @@ -6001,7 +5999,6 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, dlerror(); #endif // _WIN32 if (pWrapperTable->m_Model_RemoveResource == NULL) ->>>>>>> 3732957fa520612a7156de3e01d935ec2569de07 return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 From ce2d6c0c94050689477cd961e18288f4bb2af656 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Mon, 12 Jan 2026 11:11:14 +0100 Subject: [PATCH 10/12] [CMakeLists.txt] Change target link libraries to PRIVATE for libzip and zlib --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10e4842ed..b1605eaa7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,7 +214,7 @@ if (USE_INCLUDED_LIBZIP) else() find_package(PkgConfig REQUIRED) pkg_check_modules(LIBZIP REQUIRED libzip) - target_link_libraries(${PROJECT_NAME} ${LIBZIP_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBZIP_LIBRARIES}) endif() @@ -229,7 +229,7 @@ if (USE_INCLUDED_ZLIB) else() find_package(PkgConfig REQUIRED) pkg_check_modules(ZLIB REQUIRED zlib) - target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} PRIVATE ${ZLIB_LIBRARIES}) endif() From b3da1907c3f7b8260c4e1dea7b9a9a15c271e290 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Mon, 12 Jan 2026 12:59:43 +0100 Subject: [PATCH 11/12] [CMakeLists.txt] Add target include directories for libzip and zlib when included --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1605eaa7..21d7af0d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,7 @@ if (USE_INCLUDED_LIBZIP) else() find_package(PkgConfig REQUIRED) pkg_check_modules(LIBZIP REQUIRED libzip) + target_include_directories(${PROJECT_NAME} PRIVATE ${LIBZIP_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBZIP_LIBRARIES}) endif() @@ -229,6 +230,7 @@ if (USE_INCLUDED_ZLIB) else() find_package(PkgConfig REQUIRED) pkg_check_modules(ZLIB REQUIRED zlib) + target_include_directories(${PROJECT_NAME} PRIVATE ${ZLIB_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} PRIVATE ${ZLIB_LIBRARIES}) endif() From 1eabc86e703ed493c7af82c37f9ffd4332ead98d Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Mon, 12 Jan 2026 16:18:21 +0100 Subject: [PATCH 12/12] [CMakeLists.txt] Add target link directories for libzip and zlib --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21d7af0d4..3acc74fad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,6 +215,7 @@ else() find_package(PkgConfig REQUIRED) pkg_check_modules(LIBZIP REQUIRED libzip) target_include_directories(${PROJECT_NAME} PRIVATE ${LIBZIP_INCLUDE_DIRS}) + target_link_directories(${PROJECT_NAME} PRIVATE ${LIBZIP_LIBRARY_DIRS}) target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBZIP_LIBRARIES}) endif() @@ -231,6 +232,7 @@ else() find_package(PkgConfig REQUIRED) pkg_check_modules(ZLIB REQUIRED zlib) target_include_directories(${PROJECT_NAME} PRIVATE ${ZLIB_INCLUDE_DIRS}) + target_link_directories(${PROJECT_NAME} PRIVATE ${ZLIB_LIBRARY_DIRS}) target_link_libraries(${PROJECT_NAME} PRIVATE ${ZLIB_LIBRARIES}) endif()