1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "gdcmUIDGenerator.h"
#include "gdcmSystem.h"
#include <bitset>
#include <iostream>
int TestUIDGenerator3(int argc, char *argv[])
{
char randbytesbuf[200];
gdcm::UIDGenerator uid;
unsigned char data[16];
for(unsigned int i = 0; i < 100; ++i)
{
uid.GenerateUUID( data );
size_t len = gdcm::System::EncodeBytes(randbytesbuf, data, sizeof(data));
//std::cout << randbytesbuf << std::endl;
std::bitset<8> x;
//x.reset();
//std::cout << x << std::endl;
//x.flip();
//std::cout << x << std::endl;
//std::cout << sizeof(x) << std::endl;
//std::cout << sizeof(data) << std::endl;
x = data[0];
//std::cout << x << std::endl;
//std::cout << (int)data[0] << std::endl;
//x = data[5];
//std::cout << x << std::endl;
x[2+0] = 0;
x[2+1] = 0;
x[2+2] = 0;
x[2+3] = 0;
x[2+4] = 0;
x[2+5] = 0;
data[0] = x.to_ulong();
//std::cout << x << std::endl;
//std::cout << (int)data[0] << std::endl;
len = gdcm::System::EncodeBytes(randbytesbuf, data, sizeof(data));
std::cout << randbytesbuf << std::endl;
if( len > 37 )
{
return 1;
}
// Can't use the following, this would declare x2 as a function
//std::bitset<128> x2( std::string(randbytesbuf) );
// instead split it out :
//std::string s(randbytesbuf);
//std::bitset<128> x2( s );
//std::cout << x2 << std::endl;
}
return 0;
}