comparison Core/Toolbox.cpp @ 2512:4dcafa8d6633

SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Mar 2018 15:20:50 +0200
parents 878b59270859
children 97a74f0eac7a
comparison
equal deleted inserted replaced
2511:8a0d3044ef53 2512:4dcafa8d6633
85 # include "ChunkedBuffer.h" 85 # include "ChunkedBuffer.h"
86 # include <pugixml.hpp> 86 # include <pugixml.hpp>
87 #endif 87 #endif
88 88
89 89
90 // Inclusions for UUID
91 // http://stackoverflow.com/a/1626302
92
93 extern "C"
94 {
95 #if defined(_WIN32)
96 # include <rpc.h>
97 #else
98 # include <uuid/uuid.h>
99 #endif
100 }
101
102
103
90 namespace Orthanc 104 namespace Orthanc
91 { 105 {
92 void Toolbox::ToUpperCase(std::string& s) 106 void Toolbox::ToUpperCase(std::string& s)
93 { 107 {
94 std::transform(s.begin(), s.end(), s.begin(), toupper); 108 std::transform(s.begin(), s.end(), s.begin(), toupper);
1374 std::wstring w = boost::locale::conv::utf_to_utf<wchar_t>(source); 1388 std::wstring w = boost::locale::conv::utf_to_utf<wchar_t>(source);
1375 w = boost::algorithm::to_upper_copy<std::wstring>(w, *globalLocale_); 1389 w = boost::algorithm::to_upper_copy<std::wstring>(w, *globalLocale_);
1376 return boost::locale::conv::utf_to_utf<char>(w); 1390 return boost::locale::conv::utf_to_utf<char>(w);
1377 } 1391 }
1378 #endif 1392 #endif
1393
1394
1395 std::string Toolbox::GenerateUuid()
1396 {
1397 #ifdef WIN32
1398 UUID uuid;
1399 UuidCreate ( &uuid );
1400
1401 unsigned char * str;
1402 UuidToStringA ( &uuid, &str );
1403
1404 std::string s( ( char* ) str );
1405
1406 RpcStringFreeA ( &str );
1407 #else
1408 uuid_t uuid;
1409 uuid_generate_random ( uuid );
1410 char s[37];
1411 uuid_unparse ( uuid, s );
1412 #endif
1413 return s;
1414 }
1379 } 1415 }