-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquery.cpp
58 lines (46 loc) · 1.82 KB
/
query.cpp
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
#include <stdexcept>
#include <cstring>
#include <unity/scopes/CannedQuery.h>
extern "C" {
#include "_cgo_export.h"
}
#include "helpers.h"
using namespace unity::scopes;
using namespace gounityscopes::internal;
void destroy_canned_query(_CannedQuery *query) {
delete reinterpret_cast<CannedQuery*>(query);
}
_CannedQuery *new_canned_query(const StrData scope_id, const StrData query_str, const StrData department_id) {
return reinterpret_cast<_CannedQuery*>(
new CannedQuery(from_gostring(scope_id),
from_gostring(query_str),
from_gostring(department_id)));
}
char *canned_query_get_scope_id(_CannedQuery *query) {
return strdup(reinterpret_cast<CannedQuery*>(query)->scope_id().c_str());
}
char *canned_query_get_department_id(_CannedQuery *query) {
return strdup(reinterpret_cast<CannedQuery*>(query)->department_id().c_str());
}
void *canned_query_get_filter_state(_CannedQuery *query, int *length) {
std::string json_data;
try {
Variant v(reinterpret_cast<CannedQuery*>(query)->filter_state().serialize());
json_data = v.serialize_json();
} catch (...) {
return nullptr;
}
return as_bytes(json_data, length);
}
char *canned_query_get_query_string(_CannedQuery *query) {
return strdup(reinterpret_cast<CannedQuery*>(query)->query_string().c_str());
}
void canned_query_set_department_id(_CannedQuery *query, const StrData department_id) {
reinterpret_cast<CannedQuery*>(query)->set_department_id(from_gostring(department_id));
}
void canned_query_set_query_string(_CannedQuery *query, const StrData query_str) {
reinterpret_cast<CannedQuery*>(query)->set_query_string(from_gostring(query_str));
}
char *canned_query_to_uri(_CannedQuery *query) {
return strdup(reinterpret_cast<CannedQuery*>(query)->to_uri().c_str());
}