ARB
arbdbpp.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : arbdbpp.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include "gb_local.h"
12 
13 void GB_transaction::init(GBDATA *gb_main, bool initial) {
14  ta_main = gb_main;
15  ta_open = false;
16  ta_err = NULp;
17 
18  if (ta_main) {
19  ta_err = initial ? GB_begin_transaction(ta_main) : GB_push_transaction(ta_main);
20  if (!ta_err) {
21  ta_open = true;
22  }
23  }
24  else {
25  ta_err = "NULp-Transaction";
26  }
27 }
28 
30  return close(error.deliver());
31 }
33  // abort transaction if error is set
34 
35  if (error) {
36  if (ta_err) {
37  ta_err = GBS_global_string("%s\n(previous error: %s)", error, ta_err);
38  }
39  else {
40  ta_err = error;
41  }
42  }
43 
44 #if defined(WARN_TODO)
45 #warning check for exported error here (when GB_export_error gets redesigned)
46 #endif
47 
48  if (ta_open) {
49  ta_err = GB_end_transaction(ta_main, ta_err);
50  ta_open = false;
51  }
52 
53  return ta_err;
54 }
55 
57  if (ta_open) {
59  if (error) {
60  fprintf(stderr, "Error while closing transaction: %s\n", error);
61  gb_assert(0); // you need to manually use close()
62  }
63  }
64 }
65 
GB_ERROR GB_begin_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2516
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
Definition: arbdb.cxx:2549
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
GB_ERROR GB_push_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2482
GB_ERROR deliver() const
Definition: arb_error.h:114
static void error(const char *msg)
Definition: mkptypes.cxx:96
#define gb_assert(cond)
Definition: arbdbt.h:11
GB_ERROR close(GB_ERROR error)
Definition: arbdbpp.cxx:32
#define NULp
Definition: cxxforward.h:97
GBDATA * gb_main
Definition: adname.cxx:33