Vuo  2.3.2
VuoUuid.c
Go to the documentation of this file.
1 
10 #include "type.h"
11 #include "VuoUuid.h"
12 #include <uuid/uuid.h>
13 
15 #ifdef VUO_COMPILER
17  "title" : "UUID",
18  "description" : "Universally Unique Identifier.",
19  "keywords" : [ "guid", "unique", "tag" ],
20  "version" : "1.0.0",
21  "dependencies" : [
22  "VuoText",
23  "VuoList_VuoUuid"
24  ]
25  });
26 #endif
28 
35 {
36  VuoUuid id;
37  uuid_generate(id.bytes);
38  return id;
39 }
40 
48 {
49  VuoUuid id;
50  bzero(&id, sizeof(VuoUuid));
51 
52  if (json_object_get_type(js) == json_type_array)
53  {
54  for (int i = 0; i < 16; ++i)
55  {
56  json_object* index = json_object_array_get_idx(js, i);
57  int64_t value = json_object_get_int64(index);
58  id.bytes[i] = value;
59  }
60  }
61 
62  return id;
63 }
64 
72 {
73  json_object *bytes = json_object_new_array();
74 
75  for (unsigned int i = 0; i < 16; i++)
76  {
77  json_object* o = json_object_new_int64(value.bytes[i]);
78  json_object_array_add(bytes, o);
79  }
80 
81  return bytes;
82 }
83 
90 char * VuoUuid_getSummary(const VuoUuid value)
91 {
92  return VuoText_format("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
93  value.bytes[ 0],
94  value.bytes[ 1],
95  value.bytes[ 2],
96  value.bytes[ 3],
97  value.bytes[ 4],
98  value.bytes[ 5],
99  value.bytes[ 6],
100  value.bytes[ 7],
101  value.bytes[ 8],
102  value.bytes[ 9],
103  value.bytes[10],
104  value.bytes[11],
105  value.bytes[12],
106  value.bytes[13],
107  value.bytes[14],
108  value.bytes[15] );
109 }