source: branches/profile/ARBDB/gb_ts.h

Last change on this file was 9838, checked in by westram, 11 years ago
  • reintegrated branch 'db'
    • GBDATA now is a base class of GBENTRY (new) and GBCONTAINER
      • moved code into classes GBENTRY, GBCONTAINER and GB_MAIN_TYPE
      • several functions now exist 2 (or 3) times (for GBENTRY and GBCONTAINER, and some for GBDATA as well)
      • several functions changed their interface (caller has to explicitely pass GBENTRY or GBCONTAINER)
    • dropped support for ARB DB-version 0
  • adds:
File size: 2.1 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : gb_ts.h                                           //
4//   Purpose   : gb_transaction_save                               //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef GB_TS_H
12#define GB_TS_H
13
14#ifndef GB_DATA_H
15#include "gb_data.h"
16#endif
17
18
19struct GB_INTern_strings2 {
20    char          data[SIZOFINTERN];
21    unsigned char memsize;
22    unsigned char size;
23};
24
25struct GB_INTern2 {
26    char data[SIZOFINTERN];
27};
28
29struct gb_extern_data2 {
30    char *data;
31    long  memsize;
32    long  size;
33};
34
35union gb_data_base_type_union2 {
36    GB_INTern_strings2 istr;
37    GB_INTern2         in;
38    gb_extern_data2    ex;
39};
40
41struct gb_transaction_save {
42    gb_flag_types            flags;
43    gb_flag_types2           flags2;
44    gb_data_base_type_union2 info;
45    short                    refcount;              // number of references to this object
46
47    bool stored_external() const { return flags2.extern_data; }
48};
49
50inline GB_TYPES GB_TYPE_TS(gb_transaction_save *ts)   { return GB_TYPES(ts->flags.type); }
51inline long GB_GETSIZE_TS(gb_transaction_save *ts)    { return ts->stored_external() ? ts->info.ex.size     : ts->info.istr.size; }
52inline long GB_GETMEMSIZE_TS(gb_transaction_save *ts) { return ts->stored_external() ? ts->info.ex.memsize  : ts->info.istr.memsize; }
53inline char *GB_GETDATA_TS(gb_transaction_save *ts)   { return ts->stored_external() ? ts->info.ex.data     : &(ts->info.istr.data[0]); }
54
55inline void GB_FREE_TRANSACTION_SAVE(GBDATA *gbd) {
56    if (gbd->ext && gbd->ext->old) {
57        gb_del_ref_gb_transaction_save(gbd->ext->old);
58        gbd->ext->old = NULL;
59    }
60}
61
62#else
63#error gb_ts.h included twice
64#endif // GB_TS_H
Note: See TracBrowser for help on using the repository browser.