diff --git a/.gitignore b/.gitignore index 85501469d..863438904 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ Include/Model/COM/NMR_COMVersion.h debug .DS_Store .vscode +.vs TestOutput nonrootmodels.3mf SetupWriteRead1.3mf @@ -13,6 +14,5 @@ SetupWriteRead3.3mf SetupWriteRead4.3mf SetupWriteRead5.3mf v093reout.3mf -.vs .idea -cmake-build-* \ No newline at end of file +cmake-build-* diff --git a/Autogenerated/Bindings/C/lib3mf.h b/Autogenerated/Bindings/C/lib3mf.h index a9077e2e5..d7377e1d5 100644 --- a/Autogenerated/Bindings/C/lib3mf.h +++ b/Autogenerated/Bindings/C/lib3mf.h @@ -6007,6 +6007,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 **************************************************************************************************************************/ @@ -6695,6 +6737,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3 */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource); +/** +* 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 91f0a3781..3f0442f0d 100644 --- a/Autogenerated/Bindings/C/lib3mf_types.h +++ b/Autogenerated/Bindings/C/lib3mf_types.h @@ -328,6 +328,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 131ee6fe2..ae274933b 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc @@ -603,6 +603,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; @@ -675,6 +679,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_AddLevelSet = NULL; pWrapperTable->m_Model_GetLevelSets = NULL; pWrapperTable->m_Model_RemoveResource = NULL; + pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -5743,6 +5748,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 @@ -6391,6 +6432,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_RemoveResource == 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 c57bff963..1f7f751cd 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h @@ -5994,6 +5994,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 **************************************************************************************************************************/ @@ -6682,6 +6724,15 @@ typedef Lib3MFResult (*PLib3MFModel_GetLevelSetsPtr) (Lib3MF_Model pModel, Lib3M */ typedef Lib3MFResult (*PLib3MFModel_RemoveResourcePtr) (Lib3MF_Model pModel, Lib3MF_Resource pResource); +/** +* 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 **************************************************************************************************************************/ @@ -7441,6 +7492,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; @@ -7513,6 +7568,7 @@ typedef struct { PLib3MFModel_AddLevelSetPtr m_Model_AddLevelSet; PLib3MFModel_GetLevelSetsPtr m_Model_GetLevelSets; PLib3MFModel_RemoveResourcePtr m_Model_RemoveResource; + 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 91f0a3781..3f0442f0d 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_types.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_types.h @@ -328,6 +328,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 83d6c1442..5558260ee 100644 --- a/Autogenerated/Bindings/CSharp/Lib3MF.cs +++ b/Autogenerated/Bindings/CSharp/Lib3MF.cs @@ -2103,6 +2103,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); @@ -2319,6 +2331,9 @@ public class Lib3MFWrapper [DllImport("lib3mf.dll", EntryPoint = "lib3mf_model_removeresource", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 Model_RemoveResource (IntPtr Handle, IntPtr AResource); + [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); @@ -2849,6 +2864,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; } @@ -8868,6 +8884,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) @@ -9482,6 +9544,14 @@ public void RemoveResource (CResource AResource) CheckError(Internal.Lib3MFWrapper.Model_RemoveResource (Handle, AResourceHandle)); } + 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 5fffb814b..2e22acac3 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp @@ -6007,6 +6007,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 **************************************************************************************************************************/ @@ -6695,6 +6737,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3 */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource); +/** +* 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 5a8c99876..38455b5e7 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp @@ -175,6 +175,7 @@ class CContentEncryptionParams; class CResourceData; class CResourceDataGroup; class CKeyStore; +class CNameSpaceIterator; class CModel; /************************************************************************************************************************* @@ -299,6 +300,7 @@ typedef CContentEncryptionParams CLib3MFContentEncryptionParams; typedef CResourceData CLib3MFResourceData; typedef CResourceDataGroup CLib3MFResourceDataGroup; typedef CKeyStore CLib3MFKeyStore; +typedef CNameSpaceIterator CLib3MFNameSpaceIterator; typedef CModel CLib3MFModel; /************************************************************************************************************************* @@ -423,6 +425,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; /************************************************************************************************************************* @@ -547,6 +550,7 @@ typedef PContentEncryptionParams PLib3MFContentEncryptionParams; typedef PResourceData PLib3MFResourceData; typedef PResourceDataGroup PLib3MFResourceDataGroup; typedef PKeyStore PLib3MFKeyStore; +typedef PNameSpaceIterator PLib3MFNameSpaceIterator; typedef PModel PLib3MFModel; @@ -963,6 +967,7 @@ class CWrapper { friend class CResourceData; friend class CResourceDataGroup; friend class CKeyStore; + friend class CNameSpaceIterator; friend class CModel; }; @@ -3451,6 +3456,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 **************************************************************************************************************************/ @@ -3537,6 +3562,7 @@ class CModel : public CBase { inline PLevelSet AddLevelSet(); inline PLevelSetIterator GetLevelSets(); inline void RemoveResource(classParam pResource); + inline PNameSpaceIterator GetRequiredNameSpaces(); }; /************************************************************************************************************************* @@ -3673,6 +3699,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); @@ -11799,6 +11826,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 */ @@ -12843,6 +12925,21 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) Lib3MFHandle hResource = pResource.GetHandle(); CheckError(lib3mf_model_removeresource(m_pHandle, hResource)); } + + /** + * CModel::GetRequiredNameSpaces - Gets the list of required namespaces for the model + * @return The required namespace iterator + */ + PNameSpaceIterator CModel::GetRequiredNameSpaces() + { + Lib3MFHandle hNameSpaceIterator = (Lib3MFHandle)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 bbd323979..fcb614550 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_types.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_types.hpp @@ -327,6 +327,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 ec5d5aa98..698e01fd5 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h @@ -5994,6 +5994,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 **************************************************************************************************************************/ @@ -6682,6 +6724,15 @@ typedef Lib3MFResult (*PLib3MFModel_GetLevelSetsPtr) (Lib3MF_Model pModel, Lib3M */ typedef Lib3MFResult (*PLib3MFModel_RemoveResourcePtr) (Lib3MF_Model pModel, Lib3MF_Resource pResource); +/** +* 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 **************************************************************************************************************************/ @@ -7441,6 +7492,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; @@ -7513,6 +7568,7 @@ typedef struct { PLib3MFModel_AddLevelSetPtr m_Model_AddLevelSet; PLib3MFModel_GetLevelSetsPtr m_Model_GetLevelSets; PLib3MFModel_RemoveResourcePtr m_Model_RemoveResource; + 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 24c1e7c41..a6b33967c 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp @@ -175,6 +175,7 @@ class CContentEncryptionParams; class CResourceData; class CResourceDataGroup; class CKeyStore; +class CNameSpaceIterator; class CModel; /************************************************************************************************************************* @@ -299,6 +300,7 @@ typedef CContentEncryptionParams CLib3MFContentEncryptionParams; typedef CResourceData CLib3MFResourceData; typedef CResourceDataGroup CLib3MFResourceDataGroup; typedef CKeyStore CLib3MFKeyStore; +typedef CNameSpaceIterator CLib3MFNameSpaceIterator; typedef CModel CLib3MFModel; /************************************************************************************************************************* @@ -423,6 +425,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; /************************************************************************************************************************* @@ -547,6 +550,7 @@ typedef PContentEncryptionParams PLib3MFContentEncryptionParams; typedef PResourceData PLib3MFResourceData; typedef PResourceDataGroup PLib3MFResourceDataGroup; typedef PKeyStore PLib3MFKeyStore; +typedef PNameSpaceIterator PLib3MFNameSpaceIterator; typedef PModel PLib3MFModel; @@ -987,6 +991,7 @@ class CWrapper { friend class CResourceData; friend class CResourceDataGroup; friend class CKeyStore; + friend class CNameSpaceIterator; friend class CModel; }; @@ -3475,6 +3480,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 **************************************************************************************************************************/ @@ -3561,6 +3586,7 @@ class CModel : public CBase { inline PLevelSet AddLevelSet(); inline PLevelSetIterator GetLevelSets(); inline void RemoveResource(classParam pResource); + inline PNameSpaceIterator GetRequiredNameSpaces(); }; /************************************************************************************************************************* @@ -3697,6 +3723,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); @@ -4539,6 +4566,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; @@ -4611,6 +4642,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) pWrapperTable->m_Model_AddLevelSet = nullptr; pWrapperTable->m_Model_GetLevelSets = nullptr; pWrapperTable->m_Model_RemoveResource = nullptr; + pWrapperTable->m_Model_GetRequiredNameSpaces = nullptr; pWrapperTable->m_GetLibraryVersion = nullptr; pWrapperTable->m_GetPrereleaseInformation = nullptr; pWrapperTable->m_GetBuildInformation = nullptr; @@ -9675,6 +9707,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 @@ -10323,6 +10391,15 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if (pWrapperTable->m_Model_RemoveResource == 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 @@ -12730,6 +12807,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; @@ -13018,6 +13111,10 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if ( (eLookupError != 0) || (pWrapperTable->m_Model_RemoveResource == 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; @@ -20942,6 +21039,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 */ @@ -21986,6 +22138,21 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) Lib3MFHandle hResource = pResource.GetHandle(); CheckError(m_pWrapper->m_WrapperTable.m_Model_RemoveResource(m_pHandle, hResource)); } + + /** + * CModel::GetRequiredNameSpaces - Gets the list of required namespaces for the model + * @return The required namespace iterator + */ + PNameSpaceIterator CModel::GetRequiredNameSpaces() + { + Lib3MFHandle hNameSpaceIterator = (Lib3MFHandle)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 bbd323979..fcb614550 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp @@ -327,6 +327,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 0e6cf48ca..3e28cb435 100644 --- a/Autogenerated/Bindings/Go/lib3mf.go +++ b/Autogenerated/Bindings/Go/lib3mf.go @@ -7855,6 +7855,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 @@ -8594,6 +8651,16 @@ func (inst Model) RemoveResource(resource Resource) error { return 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.c b/Autogenerated/Bindings/Go/lib3mf_dynamic.c index b122f9b26..af9ba44a6 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.c +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.c @@ -603,6 +603,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; @@ -675,6 +679,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_AddLevelSet = NULL; pWrapperTable->m_Model_GetLevelSets = NULL; pWrapperTable->m_Model_RemoveResource = NULL; + pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -5743,6 +5748,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 @@ -6391,6 +6432,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_RemoveResource == 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 @@ -11592,6 +11642,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) @@ -12240,6 +12326,15 @@ Lib3MFResult CCall_lib3mf_model_removeresource(Lib3MFHandle libraryHandle, Lib3M } +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) diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc index e15559ef4..cef9bc704 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc @@ -559,6 +559,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; @@ -631,6 +635,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_AddLevelSet = NULL; pWrapperTable->m_Model_GetLevelSets = NULL; pWrapperTable->m_Model_RemoveResource = NULL; + pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -5303,6 +5308,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 @@ -5888,6 +5929,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_Model_GetFunctions = (PLib3MFModel_GetFunctionsPtr) GetProcAddress(hLibrary, "lib3mf_model_getfunctions"); #else // _WIN32 diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.h b/Autogenerated/Bindings/Go/lib3mf_dynamic.h index ba356d345..4d41e9822 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.h @@ -5994,6 +5994,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 **************************************************************************************************************************/ @@ -6682,6 +6724,15 @@ typedef Lib3MFResult (*PLib3MFModel_GetLevelSetsPtr) (Lib3MF_Model pModel, Lib3M */ typedef Lib3MFResult (*PLib3MFModel_RemoveResourcePtr) (Lib3MF_Model pModel, Lib3MF_Resource pResource); +/** +* 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 **************************************************************************************************************************/ @@ -7441,6 +7492,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; @@ -7513,6 +7568,7 @@ typedef struct { PLib3MFModel_AddLevelSetPtr m_Model_AddLevelSet; PLib3MFModel_GetLevelSetsPtr m_Model_GetLevelSets; PLib3MFModel_RemoveResourcePtr m_Model_RemoveResource; + PLib3MFModel_GetRequiredNameSpacesPtr m_Model_GetRequiredNameSpaces; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; @@ -9212,6 +9268,18 @@ Lib3MFResult CCall_lib3mf_keystore_getuuid(Lib3MFHandle libraryHandle, Lib3MF_Ke Lib3MFResult CCall_lib3mf_keystore_setuuid(Lib3MFHandle libraryHandle, Lib3MF_KeyStore pKeyStore, const char * pUUID); +Lib3MFResult CCall_lib3mf_namespaceiterator_movenext(Lib3MFHandle libraryHandle, Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasNext); + + +Lib3MFResult CCall_lib3mf_namespaceiterator_moveprevious(Lib3MFHandle libraryHandle, Lib3MF_NameSpaceIterator pNameSpaceIterator, bool * pHasPrevious); + + +Lib3MFResult CCall_lib3mf_namespaceiterator_getcurrent(Lib3MFHandle libraryHandle, Lib3MF_NameSpaceIterator pNameSpaceIterator, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + + +Lib3MFResult CCall_lib3mf_namespaceiterator_count(Lib3MFHandle libraryHandle, Lib3MF_NameSpaceIterator pNameSpaceIterator, Lib3MF_uint64 * pCount); + + Lib3MFResult CCall_lib3mf_model_rootmodelpart(Lib3MFHandle libraryHandle, Lib3MF_Model pModel, Lib3MF_PackagePart * pRootModelPart); @@ -9428,6 +9496,9 @@ Lib3MFResult CCall_lib3mf_model_getlevelsets(Lib3MFHandle libraryHandle, Lib3MF_ Lib3MFResult CCall_lib3mf_model_removeresource(Lib3MFHandle libraryHandle, Lib3MF_Model pModel, Lib3MF_Resource pResource); +Lib3MFResult CCall_lib3mf_model_getrequirednamespaces(Lib3MFHandle libraryHandle, Lib3MF_Model pModel, Lib3MF_NameSpaceIterator * pNameSpaceIterator); + + Lib3MFResult CCall_lib3mf_getlibraryversion(Lib3MFHandle libraryHandle, Lib3MF_uint32 * pMajor, Lib3MF_uint32 * pMinor, Lib3MF_uint32 * pMicro); diff --git a/Autogenerated/Bindings/Go/lib3mf_types.h b/Autogenerated/Bindings/Go/lib3mf_types.h index 91f0a3781..3f0442f0d 100644 --- a/Autogenerated/Bindings/Go/lib3mf_types.h +++ b/Autogenerated/Bindings/Go/lib3mf_types.h @@ -328,6 +328,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 131ee6fe2..ae274933b 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc @@ -603,6 +603,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; @@ -675,6 +679,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_AddLevelSet = NULL; pWrapperTable->m_Model_GetLevelSets = NULL; pWrapperTable->m_Model_RemoveResource = NULL; + pWrapperTable->m_Model_GetRequiredNameSpaces = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -5743,6 +5748,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 @@ -6391,6 +6432,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_RemoveResource == 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 c57bff963..1f7f751cd 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h @@ -5994,6 +5994,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 **************************************************************************************************************************/ @@ -6682,6 +6724,15 @@ typedef Lib3MFResult (*PLib3MFModel_GetLevelSetsPtr) (Lib3MF_Model pModel, Lib3M */ typedef Lib3MFResult (*PLib3MFModel_RemoveResourcePtr) (Lib3MF_Model pModel, Lib3MF_Resource pResource); +/** +* 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 **************************************************************************************************************************/ @@ -7441,6 +7492,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; @@ -7513,6 +7568,7 @@ typedef struct { PLib3MFModel_AddLevelSetPtr m_Model_AddLevelSet; PLib3MFModel_GetLevelSetsPtr m_Model_GetLevelSets; PLib3MFModel_RemoveResourcePtr m_Model_RemoveResource; + 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 ae8e32b16..f05313ea7 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc @@ -166,6 +166,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 a65f5b7ca..dfb704e23 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc @@ -159,6 +159,7 @@ Persistent CLib3MFContentEncryptionParams::constructor; Persistent CLib3MFResourceData::constructor; Persistent CLib3MFResourceDataGroup::constructor; Persistent CLib3MFKeyStore::constructor; +Persistent CLib3MFNameSpaceIterator::constructor; Persistent CLib3MFModel::constructor; /************************************************************************************************************************* @@ -22926,6 +22927,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 **************************************************************************************************************************/ @@ -23021,6 +23174,7 @@ void CLib3MFModel::Init() NODE_SET_PROTOTYPE_METHOD(tpl, "AddLevelSet", AddLevelSet); NODE_SET_PROTOTYPE_METHOD(tpl, "GetLevelSets", GetLevelSets); NODE_SET_PROTOTYPE_METHOD(tpl, "RemoveResource", RemoveResource); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetRequiredNameSpaces", GetRequiredNameSpaces); constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); } @@ -24896,6 +25050,29 @@ void CLib3MFModel::RemoveResource(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 1d4bce79e..5fc5aeff3 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h @@ -2630,6 +2630,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 **************************************************************************************************************************/ @@ -2709,6 +2730,7 @@ class CLib3MFModel : public CLib3MFBaseClass { static void AddLevelSet(const v8::FunctionCallbackInfo& args); static void GetLevelSets(const v8::FunctionCallbackInfo& args); static void RemoveResource(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 91f0a3781..3f0442f0d 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_types.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_types.h @@ -328,6 +328,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 5d3c5b62f..2446a8ffa 100644 --- a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas +++ b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas @@ -596,6 +596,7 @@ TLib3MFContentEncryptionParams = class; TLib3MFResourceData = class; TLib3MFResourceDataGroup = class; TLib3MFKeyStore = class; + TLib3MFNameSpaceIterator = class; TLib3MFModel = class; @@ -6671,6 +6672,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 **************************************************************************************************************************) @@ -7359,6 +7403,15 @@ TLib3MFModel = class; *) TLib3MFModel_RemoveResourceFunc = function(pModel: TLib3MFHandle; const pResource: 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 **************************************************************************************************************************) @@ -9436,6 +9489,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 **************************************************************************************************************************) @@ -9516,6 +9584,7 @@ TLib3MFModel = class(TLib3MFBase) function AddLevelSet(): TLib3MFLevelSet; function GetLevelSets(): TLib3MFLevelSetIterator; procedure RemoveResource(const AResource: TLib3MFResource); + function GetRequiredNameSpaces(): TLib3MFNameSpaceIterator; end; (************************************************************************************************************************* @@ -10080,6 +10149,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; @@ -10152,6 +10225,7 @@ TLib3MFWrapper = class(TObject) FLib3MFModel_AddLevelSetFunc: TLib3MFModel_AddLevelSetFunc; FLib3MFModel_GetLevelSetsFunc: TLib3MFModel_GetLevelSetsFunc; FLib3MFModel_RemoveResourceFunc: TLib3MFModel_RemoveResourceFunc; + FLib3MFModel_GetRequiredNameSpacesFunc: TLib3MFModel_GetRequiredNameSpacesFunc; FLib3MFGetLibraryVersionFunc: TLib3MFGetLibraryVersionFunc; FLib3MFGetPrereleaseInformationFunc: TLib3MFGetPrereleaseInformationFunc; FLib3MFGetBuildInformationFunc: TLib3MFGetBuildInformationFunc; @@ -10736,6 +10810,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; @@ -10808,6 +10886,7 @@ TLib3MFWrapper = class(TObject) property Lib3MFModel_AddLevelSetFunc: TLib3MFModel_AddLevelSetFunc read FLib3MFModel_AddLevelSetFunc; property Lib3MFModel_GetLevelSetsFunc: TLib3MFModel_GetLevelSetsFunc read FLib3MFModel_GetLevelSetsFunc; property Lib3MFModel_RemoveResourceFunc: TLib3MFModel_RemoveResourceFunc read FLib3MFModel_RemoveResourceFunc; + property Lib3MFModel_GetRequiredNameSpacesFunc: TLib3MFModel_GetRequiredNameSpacesFunc read FLib3MFModel_GetRequiredNameSpacesFunc; property Lib3MFGetLibraryVersionFunc: TLib3MFGetLibraryVersionFunc read FLib3MFGetLibraryVersionFunc; property Lib3MFGetPrereleaseInformationFunc: TLib3MFGetPrereleaseInformationFunc read FLib3MFGetPrereleaseInformationFunc; property Lib3MFGetBuildInformationFunc: TLib3MFGetBuildInformationFunc read FLib3MFGetBuildInformationFunc; @@ -11025,6 +11104,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 @@ -11859,6 +11939,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); @@ -12335,6 +12416,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); @@ -19287,6 +19372,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 **************************************************************************************************************************) @@ -20069,6 +20205,17 @@ implementation FWrapper.CheckError(Self, FWrapper.Lib3MFModel_RemoveResourceFunc(FHandle, AResourceHandle)); 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 **************************************************************************************************************************) @@ -20646,6 +20793,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'); @@ -20718,6 +20869,7 @@ implementation FLib3MFModel_AddLevelSetFunc := LoadFunction('lib3mf_model_addlevelset'); FLib3MFModel_GetLevelSetsFunc := LoadFunction('lib3mf_model_getlevelsets'); FLib3MFModel_RemoveResourceFunc := LoadFunction('lib3mf_model_removeresource'); + FLib3MFModel_GetRequiredNameSpacesFunc := LoadFunction('lib3mf_model_getrequirednamespaces'); FLib3MFGetLibraryVersionFunc := LoadFunction('lib3mf_getlibraryversion'); FLib3MFGetPrereleaseInformationFunc := LoadFunction('lib3mf_getprereleaseinformation'); FLib3MFGetBuildInformationFunc := LoadFunction('lib3mf_getbuildinformation'); @@ -22411,6 +22563,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); @@ -22627,6 +22791,9 @@ implementation if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_model_removeresource'), @FLib3MFModel_RemoveResourceFunc); + 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 5447f693a..ba875d393 100644 --- a/Autogenerated/Bindings/Python/Lib3MF.py +++ b/Autogenerated/Bindings/Python/Lib3MF.py @@ -692,6 +692,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 @@ -764,6 +768,7 @@ class FunctionTable: lib3mf_model_addlevelset = None lib3mf_model_getlevelsets = None lib3mf_model_removeresource = None + lib3mf_model_getrequirednamespaces = None '''Definition of Enumerations ''' @@ -4621,6 +4626,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)) @@ -5053,6 +5082,12 @@ def _loadFunctionTableFromMethod(self, symbolLookupMethodAddress): methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_void_p) self.lib.lib3mf_model_removeresource = 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]) @@ -6780,6 +6815,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)] @@ -6996,6 +7043,9 @@ def _loadFunctionTable(self): self.lib.lib3mf_model_removeresource.restype = ctypes.c_int32 self.lib.lib3mf_model_removeresource.argtypes = [ctypes.c_void_p, 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]) @@ -7438,6 +7488,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) @@ -13035,6 +13087,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): @@ -13752,4 +13840,14 @@ def RemoveResource(self, ResourceObject): self._wrapper.checkError(self, self._wrapper.lib.lib3mf_model_removeresource(self._handle, ResourceHandle)) + 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 5fffb814b..2e22acac3 100644 --- a/Autogenerated/Source/lib3mf_abi.hpp +++ b/Autogenerated/Source/lib3mf_abi.hpp @@ -6007,6 +6007,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 **************************************************************************************************************************/ @@ -6695,6 +6737,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3 */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource); +/** +* 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 48a1429e4..079a951f2 100644 --- a/Autogenerated/Source/lib3mf_interfaces.hpp +++ b/Autogenerated/Source/lib3mf_interfaces.hpp @@ -169,6 +169,7 @@ class IContentEncryptionParams; class IResourceData; class IResourceDataGroup; class IKeyStore; +class INameSpaceIterator; class IModel; @@ -6439,6 +6440,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 **************************************************************************************************************************/ @@ -6918,6 +6963,12 @@ class IModel : public virtual IBase { */ virtual void RemoveResource(IResource* pResource) = 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 bf1d29e36..2a22c198d 100644 --- a/Autogenerated/Source/lib3mf_interfacewrapper.cpp +++ b/Autogenerated/Source/lib3mf_interfacewrapper.cpp @@ -21690,6 +21690,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 **************************************************************************************************************************/ @@ -24380,6 +24542,42 @@ Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pR } } +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()); + } +} + /************************************************************************************************************************* @@ -25505,6 +25703,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") @@ -25649,6 +25855,8 @@ Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void * *ppProcAddress = (void*) &lib3mf_model_getlevelsets; if (sProcName == "lib3mf_model_removeresource") *ppProcAddress = (void*) &lib3mf_model_removeresource; + 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 bbd323979..fcb614550 100644 --- a/Autogenerated/Source/lib3mf_types.hpp +++ b/Autogenerated/Source/lib3mf_types.hpp @@ -327,6 +327,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/generateWrapperAndBindingsLinux64.sh b/AutomaticComponentToolkit/generateWrapperAndBindingsLinux64.sh old mode 100755 new mode 100644 diff --git a/AutomaticComponentToolkit/lib3mf.xml b/AutomaticComponentToolkit/lib3mf.xml index 3eeccd1aa..1c1700bbf 100644 --- a/AutomaticComponentToolkit/lib3mf.xml +++ b/AutomaticComponentToolkit/lib3mf.xml @@ -3994,6 +3994,21 @@ + + + + + + + + + + + + + + + @@ -4387,6 +4402,10 @@ + + + + :/MP>) set (CMAKE_CXX_STANDARD 17) @@ -128,10 +129,17 @@ 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() if (${MSVC}) # using Visual Studio C++ @@ -206,7 +214,9 @@ if (USE_INCLUDED_LIBZIP) else() find_package(PkgConfig REQUIRED) pkg_check_modules(LIBZIP REQUIRED libzip) - target_link_libraries(${PROJECT_NAME} ${LIBZIP_LIBRARIES}) + 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() @@ -221,7 +231,9 @@ if (USE_INCLUDED_ZLIB) else() find_package(PkgConfig REQUIRED) pkg_check_modules(ZLIB REQUIRED zlib) - target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES}) + 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() diff --git a/Include/API/lib3mf_model.hpp b/Include/API/lib3mf_model.hpp index 6326c1227..9c3d2bd07 100644 --- a/Include/API/lib3mf_model.hpp +++ b/Include/API/lib3mf_model.hpp @@ -224,6 +224,8 @@ class CModel : public virtual IModel, public virtual CBase { ILevelSetIterator * GetLevelSets() override; void RemoveResource(IResource* pResource) override; + + INameSpaceIterator * GetRequiredNameSpaces() override; }; } diff --git a/Include/API/lib3mf_namespaceiterator.hpp b/Include/API/lib3mf_namespaceiterator.hpp new file mode 100644 index 000000000..8b6a9cf5f --- /dev/null +++ b/Include/API/lib3mf_namespaceiterator.hpp @@ -0,0 +1,114 @@ +/*++ + +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. + */ + std::vector m_namespaces; + Lib3MF_int32 m_nCurrentIndex = -1; + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + void setNameSpaces(std::vector&& namespaces); + + /** + * 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/Include/Model/Classes/NMR_Model.h b/Include/Model/Classes/NMR_Model.h index 21581aa38..3daa7d2af 100644 --- a/Include/Model/Classes/NMR_Model.h +++ b/Include/Model/Classes/NMR_Model.h @@ -96,6 +96,8 @@ namespace NMR { typedef std::map UniqueResourceIDMapping; + using NameSpaces = std::vector; + class CModelImage3D; typedef std::shared_ptr PModelImage3D; @@ -179,6 +181,8 @@ namespace NMR { CryptoRandGenDescriptor m_sRandDescriptor; + NameSpaces m_requiredNameSpaces; + // Add Resource to resource lookup tables void addResourceToLookupTable(_In_ PModelResource pResource); @@ -380,6 +384,10 @@ namespace NMR { void removeResource(PModelResource pResource); + 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(); }; typedef std::shared_ptr PModel; diff --git a/Source/API/lib3mf_model.cpp b/Source/API/lib3mf_model.cpp index 8bffb590f..b4b8cc12a 100644 --- a/Source/API/lib3mf_model.cpp +++ b/Source/API/lib3mf_model.cpp @@ -34,26 +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_texture2diterator.hpp" #include "lib3mf_compositematerials.hpp" #include "lib3mf_compositematerialsiterator.hpp" #include "lib3mf_multipropertygroup.hpp" @@ -69,6 +76,7 @@ Abstract: This is a stub class definition of CModel #include "lib3mf_volumedata.hpp" #include "lib3mf_levelset.hpp" #include "lib3mf_levelsetiterator.hpp" +#include "lib3mf_namespaceiterator.hpp" // Include custom headers here. #include "Model/Classes/NMR_ModelMeshObject.h" @@ -946,3 +954,12 @@ void CModel::RemoveResource(IResource* pResource) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDRESOURCE); model().removeResource(pLib3MFResource->resource()); } + +INameSpaceIterator * CModel::GetRequiredNameSpaces() +{ + auto pResult = std::unique_ptr(new CNameSpaceIterator()); + + pResult->setNameSpaces(std::move(m_model->getRequiredNameSpaces())); + + return pResult.release(); +} diff --git a/Source/API/lib3mf_namespaceiterator.cpp b/Source/API/lib3mf_namespaceiterator.cpp new file mode 100644 index 000000000..cb39cd564 --- /dev/null +++ b/Source/API/lib3mf_namespaceiterator.cpp @@ -0,0 +1,86 @@ +/*++ + +Copyright (C) 2024 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: Iterator for namespaces + +*/ + +#include "lib3mf_namespaceiterator.hpp" +#include "lib3mf_interfaceexception.hpp" + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CNameSpaceIterator +**************************************************************************************************************************/ + +bool CNameSpaceIterator::MoveNext() +{ + 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() +{ + m_nCurrentIndex--; + + // Check new Index + if (m_nCurrentIndex < 0) { + m_nCurrentIndex = -1; + return false; + } + else { + return true; + } +} + +std::string CNameSpaceIterator::GetCurrent() +{ + 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() +{ + 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 32e58c37f..6ea83f939 100644 --- a/Source/Model/Classes/NMR_Model.cpp +++ b/Source/Model/Classes/NMR_Model.cpp @@ -1815,5 +1815,41 @@ namespace NMR { throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); } -} // namespace NMR + void CModel::registerRequiredNameSpace(std::string const&nameSpace) + { + 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; + + // 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; + } +} // namespace NMR diff --git a/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp b/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp index a421891f7..947de9ba3 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 67af619a9..9c7a51d63 100644 --- a/Tests/CPP_Bindings/Source/Model.cpp +++ b/Tests/CPP_Bindings/Source/Model.cpp @@ -175,6 +175,67 @@ 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); + } + + 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()); + } + TEST_F(Model, RemoveResource_MaterialGroup) { auto baseMaterial = m_pModel->AddBaseMaterialGroup();