-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic_template_index.go
More file actions
238 lines (175 loc) · 8.39 KB
/
dynamic_template_index.go
File metadata and controls
238 lines (175 loc) · 8.39 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
package facesdk
/*
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#define UUID_DEFAULT_SIZE 36
#define MAX_METHOD_NAME_SIZE 16
typedef void (*binary_stream_write_func_type)(
void* stream,
const void* data,
uint64_t bytes_count);
typedef struct {
char* data;
size_t size;
size_t offset;
} WriteData;
uint64_t __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_size(void* implementation, void** exception);
uint64_t __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_capacity(void* implementation, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_add_3(void* templateIndex, const void* contextTemplate, const char* uuid, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_add_4(void* templateIndex, const void** contextTemplates, const char** uuids, uint64_t size, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_remove_1(void* templateIndex, const char* uuid, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_remove_2(void* templateIndex, const char** uuids, uint64_t size, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_concatenate(void* templateIndex, void* otherIndex, void** exception);
void* __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_at_by_uuid(void* templateIndex, const char* uuid, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_at_by_index(void* templateIndex, int64_t index, void* stream, binary_stream_write_func_type binary_stream_write_func, void** exception);
void* __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_get(void* templateIndex, int64_t index, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_getMethodName(void* templateIndex, void* stream, binary_stream_write_func_type binary_stream_write_func, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_clear(void* templateIndex, void** exception);
void __4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_destructor(void* templateIndex);
extern void writeFunction(void* data, const void* buffer, uint64_t bytesCount);
const char* atByIndex(void* templateIndex, int64_t index, size_t* size, void** exception)
{
WriteData writeData = { (char*)malloc(UUID_DEFAULT_SIZE), UUID_DEFAULT_SIZE, 0 };
__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_at_by_index(templateIndex, index, &writeData, writeFunction, exception);
*size = writeData.offset;
return writeData.data;
}
const char* getDynamicTemplateIndexMethodName(void* templatIndex, size_t* size, void** exception)
{
WriteData writeData = { (char*)malloc(MAX_METHOD_NAME_SIZE), MAX_METHOD_NAME_SIZE, 0 };
__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_getMethodName(templatIndex, &writeData, writeFunction, exception);
*size = writeData.offset;
return writeData.data;
}
*/
import "C"
import (
"errors"
"unsafe"
)
type DynamicTemplateIndex struct {
implementation unsafe.Pointer
}
// Get size of DynamicTemplateIndex
func (templateIndex DynamicTemplateIndex) Size() (uint64, error) {
exception := createException()
result := uint64(C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_size(templateIndex.implementation, &exception))
return result, checkApiException(exception)
}
// Get capacity of DynamicTemplateIndex
func (templateIndex DynamicTemplateIndex) Capacity() (uint64, error) {
exception := createException()
result := uint64(C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_capacity(templateIndex.implementation, &exception))
return result, checkApiException(exception)
}
// Add ContextTemplate to DynamicTemplateIndex
func (templateIndex *DynamicTemplateIndex) AddSingle(contextTemplate ContextTemplate, uuid string) error {
exception := createException()
uuidPtr := C.CString(uuid)
C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_add_3(
templateIndex.implementation,
contextTemplate.implementation,
uuidPtr,
&exception)
C.free(unsafe.Pointer(uuidPtr))
return checkApiException(exception)
}
// Add []ContextTemplate to DynamicTemplateIndex
func (templateIndex *DynamicTemplateIndex) AddMultiple(contextTemplates []ContextTemplate, uuids []string) error {
exception := createException()
tempTemplates := make([]unsafe.Pointer, len(contextTemplates))
tempUuids, cleanup := createCStringArray(uuids)
for i, template := range contextTemplates {
tempTemplates[i] = template.implementation
}
C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_add_4(
templateIndex.implementation,
&tempTemplates[0],
tempUuids,
C.uint64_t(len(contextTemplates)),
&exception)
cleanup()
return checkApiException(exception)
}
// Remove ContextTemplate by UUID from DynamicTemplateIndex
func (templateIndex *DynamicTemplateIndex) RemoveSingle(uuid string) error {
exception := createException()
uuidPtr := C.CString(uuid)
C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_remove_1(templateIndex.implementation, uuidPtr, &exception)
C.free(unsafe.Pointer(uuidPtr))
return checkApiException(exception)
}
// Remove []ContextTemplate by UUIDs from DynamicTemplateIndex
func (templateIndex *DynamicTemplateIndex) RemoveMultiple(uuids []string) error {
exception := createException()
tempUuids, cleanup := createCStringArray(uuids)
C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_remove_2(
templateIndex.implementation,
tempUuids, C.uint64_t(len(uuids)),
&exception)
cleanup()
return checkApiException(exception)
}
// Append DynamicTemplateIndex to another DynamicTemplateIndex
func (templateIndex *DynamicTemplateIndex) Concatenate(otherIndex DynamicTemplateIndex) error {
exception := createException()
C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_concatenate(
templateIndex.implementation,
otherIndex.implementation,
&exception)
return checkApiException(exception)
}
// Get ContextTemplate by UUID from DynamicTemplateIndex
func (templateIndex DynamicTemplateIndex) GetContextTemplateByUuid(uuid string) (ContextTemplate, error) {
exception := createException()
uuidPtr := C.CString(uuid)
result := C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_at_by_uuid(
templateIndex.implementation,
uuidPtr,
&exception)
C.free(unsafe.Pointer(uuidPtr))
return ContextTemplate{implementation: result}, checkApiException(exception)
}
// Get UUID by index from DynamicTemplateIndex
func (templateIndex DynamicTemplateIndex) GetUuidByIndex(index int64) (string, error) {
exception := createException()
size := C.size_t(0)
temp := C.atByIndex(templateIndex.implementation, C.int64_t(index), &size, &exception)
result := C.GoStringN(temp, C.int(size))
C.free(unsafe.Pointer(temp))
return result, checkApiException(exception)
}
// Get ContextTemplate by index from DynamicTemplateIndex
func (templateIndex DynamicTemplateIndex) GetContextTemplateByIndex(index int64) (ContextTemplate, error) {
exception := createException()
result := C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_get(
templateIndex.implementation,
C.int64_t(index),
&exception)
return ContextTemplate{implementation: result}, checkApiException(exception)
}
// Get method name of DynamicTemplateIndex
func (templateIndex DynamicTemplateIndex) GetMethodName() (string, error) {
exception := createException()
var size = C.size_t(0)
temp := C.getDynamicTemplateIndexMethodName(templateIndex.implementation, &size, &exception)
result := C.GoStringN(temp, C.int(size))
C.free(unsafe.Pointer(temp))
return result, checkApiException(exception)
}
// Remove all ContextTemplates from DynamicTemplateIndex
func (templateIndex *DynamicTemplateIndex) Clear() error {
exception := createException()
C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_clear(templateIndex.implementation, &exception)
return checkApiException(exception)
}
// Destroy DynamicTemplateIndex
func (templateIndex *DynamicTemplateIndex) Close() error {
if templateIndex.implementation == nil {
return errors.New("DynamicTemplateIndex already destroyed")
}
C.__4848a76477c449608aa5deb15c5495e4_facerec_v3_DynamicTemplateIndex_destructor(templateIndex.implementation)
templateIndex.implementation = nil
return nil
}