lib3mf 2.5 :

- aggiornamento versione
- utilizzate le nostre librerie esterne libzip e zlib e non quelle incluse in lib3mf.
This commit is contained in:
SaraP
2026-08-25 12:44:11 +02:00
parent ea6efc1e36
commit 513f08e691
544 changed files with 52634 additions and 30760 deletions
+50 -15
View File
@@ -37,25 +37,34 @@ NMR_UUID.cpp implements a datatype and functions to handle UUIDs
#include <algorithm>
#ifdef _WIN32
#ifdef GUID_WINDOWS
#include <objbase.h>
#include <iomanip>
#else
#endif
#ifdef GUID_LIBUUID
#include <uuid/uuid.h>
#endif
#ifdef GUID_CFUUID
#include <CoreFoundation/CFUUID.h>
#endif
#ifdef GUID_CUSTOM
#include <ctime>
#endif
namespace NMR
{
#ifndef _WIN32
bool CUUID::S_mtwister_initialised = false;
#ifdef GUID_CUSTOM
std::mutex CUUID::S_uuid_gen_mutex;
std::random_device CUUID::S_rand_dev;
std::mt19937 CUUID::S_mtwister;
std::unique_ptr<std::mt19937> CUUID::S_mtwister;
#endif
CUUID::CUUID()
{
#ifdef _WIN32
#ifdef GUID_WINDOWS
GUID guid;
if (CoCreateGuid(&guid) != S_OK)
throw CNMRException(NMR_ERROR_UUIDGENERATIONFAILED);
@@ -63,23 +72,49 @@ namespace NMR
if (StringFromCLSID(guid, &str) != S_OK)
throw CNMRException(NMR_ERROR_UUIDGENERATIONFAILED);
set(fnUTF16toUTF8(str).c_str());
#else
#endif
#ifdef GUID_LIBUUID
uuid_t uuid;
uuid_generate_random(uuid);
char s[37];
uuid_unparse(uuid, s);
set(std::string(s).c_str());
#endif
#ifdef GUID_CFUUID
auto newId = CFUUIDCreate(NULL);
auto bytes = CFUUIDGetUUIDBytes(newId);
CFRelease(newId);
char out[16*2+3+1+1];
out[36] = 0;
snprintf(out, 37, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
bytes.byte0, bytes.byte1, bytes.byte2, bytes.byte3,
bytes.byte4, bytes.byte5,
bytes.byte6, bytes.byte7,
bytes.byte8, bytes.byte9,
bytes.byte10, bytes.byte11, bytes.byte12, bytes.byte13, bytes.byte14, bytes.byte15);
set(out);
#endif
#ifdef GUID_CUSTOM
std::lock_guard<std::mutex> l_lock(S_uuid_gen_mutex);
if (!S_mtwister_initialised)
if (!S_mtwister)
{
S_mtwister.reset(new std::mt19937);
std::random_device rand_dev;
// Prepare seed data
uint32_t l_seed_data[std::mt19937::state_size];
uint32_t l_cur_time = static_cast<uint32_t>(time(nullptr));
for (size_t i = 0; i < std::mt19937::state_size; ++i)
{
l_seed_data[i] = S_rand_dev() ^ l_cur_time;
l_seed_data[i] = rand_dev() ^ l_cur_time;
}
// Init Mersenne Twister pseudo-random generator
std::seed_seq l_seed_seq(std::begin(l_seed_data), std::end(l_seed_data));
S_mtwister.seed(l_seed_seq);
S_mtwister_initialised = true;
S_mtwister->seed(l_seed_seq);
}
// generation of a v4 UUID according to https://tools.ietf.org/html/rfc4122#section-4.4
@@ -88,9 +123,9 @@ namespace NMR
const nfChar* hexaDec = "0123456789abcdef";
nfChar string[33];
for (int i = 0; i < 32; i++)
string[i] = hexaDec[distHexaDec(S_mtwister)];
string[i] = hexaDec[distHexaDec(*S_mtwister)];
string[12] = hexaDec[4]; // set version 4
string[16] = hexaDec[8 + dist4(S_mtwister)];
string[16] = hexaDec[8 + dist4(*S_mtwister)];
string[32] = 0;
set(string);