theSq3Lite 10.0
Loading...
Searching...
No Matches
Sq3Call_cc.cc
Go to the documentation of this file.
1
9/* LABEL-NO */
10
11#define META_FILE_NAME "Sq3Call_cc.cc"
12
13/*****************************************************************************/
14/* */
15/* context */
16/* */
17/*****************************************************************************/
18
19#include "private_cc.hh"
20
21namespace ccsq3lite {
22
23 using namespace std;
24
25/*
26 void Sq3LiteExecCallbackC::NsClassAttributeFree ( NsClassAttributeFreeF_ARGS )
27 {
28 delete static_cast<Sq3LiteExecCallbackC*>(cfg->fClassAttributeData);
29
30 cfg->fClassAttributeData = NULL;
31 cfg->fClassAttributeCall = NULL;
32 cfg->fClassAttributeFree = NULL;
33 }
34*/
35
36 // ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
37 // routine returns SQLITE_ABORT without invoking the callback again and
38 // without running any subsequent SQL statements.
40 {
42 // if NULL than callback is disabled → require attribute "callback-null"
43 // return "1" force sqlite3-abort-error
44 auto mycall = static_cast<Sq3LiteExecCallbackC* const> (callV1);
45 //MkRtSetup_X(lite);
46 if (mycall->self == NULL || !mycall->self->Check()) return 1;
47
48 try {
49 // https://stackoverflow.com/questions/58381828/c-assign-char-to-an-array-of-strings
50 std::vector<std::string> valsV( vals, vals+num );
51 std::vector<std::string> colsV( cols, cols+num );
52
53 switch (mycall->type) {
55 //(self->*mycall->mycall.LiteExecCB)(valsV,colsV);
56 (*mycall->call.LiteExecCB)(valsV,colsV);
57 break;
59 (mycall->call.LiteExecIF->callback)(valsV,colsV);
60 break;
61 default:
62 MkExceptionC::Catch(mycall->self,"Sq3LiteExecCallbackC::Call → callback-data-type-error");
63 goto error;
64 }
65 } catch (const MkExceptionC& ex) {
66 MkExceptionC::Catch(mycall->self,ex);
67 goto error;
68 } catch (const exception& ex) {
69 MkExceptionC::Catch(mycall->self,ex);
70 goto error;
71 } catch (...) {
72 MkExceptionC::Catch(mycall->self,"Sq3LiteExecCallbackC::Call → unknown 'C++' exception in callback");
73 goto error;
74 // http://groups.google.com/group/comp.programming.threads/browse_thread/thread/652bcf186fbbf697/f63757846514e5e5
75 // throw;
76 }
77
78 // everything is OK
79 return 0;
80error:
82 return 1;
83 }
84
86 {
87 // if NULL than callback is disabled → require attribute "callback-null"
88 // return "1" force sqlite3-abort-error
89 if (callV2 == NULL) return MK_ERROR;
90 auto mycall = static_cast<Sq3LiteExecV2CallbackC* const> (callV2);
91 if (mycall == NULL ) return MK_ERROR;
92 //MkRtSetup_X(lite);
93 if (mycall->self == NULL || !mycall->self->Check()) return MK_ERROR;
94
95 try {
96 // https://stackoverflow.com/questions/58381828/c-assign-char-to-an-array-of-strings
97 MkBufferListC valsR(vals);
98 MkBufferListC colsR(cols);
99
100 switch (mycall->type) {
102 (*mycall->call.LiteExecV2CB)(valsR,colsR);
103 break;
105 (mycall->call.LiteExecV2IF->callback)(valsR,colsR);
106 break;
107 default:
108 MkExceptionC::Catch(mycall->self,"Sq3LiteExecV2CallbackC::Call → callback-data-type-error");
109 goto error;
110 }
111 } catch (const MkExceptionC& ex) {
112 MkExceptionC::Catch(mycall->self,ex);
113 goto error;
114 } catch (const exception& ex) {
115 MkExceptionC::Catch(mycall->self,ex);
116 goto error;
117 } catch (...) {
118 MkExceptionC::Catch(mycall->self,"Sq3LiteExecV2CallbackC::Call → unknown 'C++' exception in callback");
119 goto error;
120 // http://groups.google.com/group/comp.programming.threads/browse_thread/thread/652bcf186fbbf697/f63757846514e5e5
121 // throw;
122 }
123
124error:
125 return MkErrorStack_0E_Check();
126 }
127
128} // END - namespace "ccsq3lite"
129
130// vim: iskeyword-=:
#define MkErrorStack_0_NULL()
#define MkErrorStack_0E_Check()
static MK_ERR Catch(MK_MNGN const expobj, std::exception const *exception, MK_STRN const callfunc=__builtin_FUNCTION())
#define Sq3LiteExecV2CB_ret
#define Sq3Fupu_Sq3LiteExec_callback_call_check
#define Sq3Fupu_Sq3LiteExec_callback_call_args
#define Sq3Fupu_Sq3LiteExec_callback_call_ret
#define Sq3LiteExecV2CB_args
namespace for the CcSq3Lite "C++"-API
infrastructur to use the CcLcConfig specific callback …
Definition Sq3Call_cc.hh:16
static Sq3Fupu_Sq3LiteExec_callback_call_ret Call(Sq3Fupu_Sq3LiteExec_callback_call_args)
Definition Sq3Call_cc.cc:39
infrastructur to use the CcLcConfig specific callback …
Definition Sq3Call_cc.hh:59
static Sq3LiteExecV2CB_ret Call(Sq3LiteExecV2CB_args)
Definition Sq3Call_cc.cc:85