comparison Orthanc/Core/Toolbox.cpp @ 155:08f30c8962a7

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Nov 2016 13:28:58 +0100
parents 1a90184363f8
children 5dc54316d68b
comparison
equal deleted inserted replaced
154:fcc3be30b116 155:08f30c8962a7
75 } 75 }
76 } 76 }
77 #endif 77 #endif
78 78
79 79
80 80 #if defined(_WIN32)
81 // Inclusions for UUID 81 # include <windows.h> // For ::Sleep
82 // http://stackoverflow.com/a/1626302
83
84 extern "C"
85 {
86 #ifdef WIN32
87 # include <rpc.h>
88 #else
89 # include <uuid/uuid.h>
90 #endif 82 #endif
91 }
92 83
93 84
94 #if ORTHANC_ENABLE_PUGIXML == 1 85 #if ORTHANC_ENABLE_PUGIXML == 1
95 # include "ChunkedBuffer.h" 86 # include "ChunkedBuffer.h"
96 # include <pugixml.hpp> 87 # include <pugixml.hpp>
1224 return static_cast<unsigned int>(v); 1215 return static_cast<unsigned int>(v);
1225 } 1216 }
1226 } 1217 }
1227 1218
1228 1219
1229 std::string Toolbox::GenerateUuid()
1230 {
1231 #ifdef WIN32
1232 UUID uuid;
1233 UuidCreate ( &uuid );
1234
1235 unsigned char * str;
1236 UuidToStringA ( &uuid, &str );
1237
1238 std::string s( ( char* ) str );
1239
1240 RpcStringFreeA ( &str );
1241 #else
1242 uuid_t uuid;
1243 uuid_generate_random ( uuid );
1244 char s[37];
1245 uuid_unparse ( uuid, s );
1246 #endif
1247 return s;
1248 }
1249
1250
1251 bool Toolbox::IsUuid(const std::string& str) 1220 bool Toolbox::IsUuid(const std::string& str)
1252 { 1221 {
1253 if (str.size() != 36) 1222 if (str.size() != 36)
1254 { 1223 {
1255 return false; 1224 return false;