-
Notifications
You must be signed in to change notification settings - Fork 17
/
c_error.cc
34 lines (28 loc) · 886 Bytes
/
c_error.cc
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
// Copyright 2016 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "c_error.h"
#include <string>
struct chai2010_cgo_Error_T {
int errCode;
std::string errText;
};
chai2010_cgo_Error_T* chai2010_cgo_Error_New(int errCode, const char* errText) {
auto p = new chai2010_cgo_Error_T();
p->errCode = errCode;
p->errText = errText? errText: "";
return p;
}
void chai2010_cgo_Error_Delete(chai2010_cgo_Error_T* p) {
delete p;
}
void chai2010_cgo_Error_SetError(chai2010_cgo_Error_T* p, int errCode, const char* errText) {
p->errCode = errCode;
p->errText = errText? errText: "";
}
int chai2010_cgo_Error_GetCode(chai2010_cgo_Error_T* p) {
return p->errCode;
}
const char* chai2010_cgo_Error_GetText(chai2010_cgo_Error_T* p) {
return p->errText.c_str();
}