~2591kuldeep/libdrizzle/libdrizzle-binlogapi

« back to all changes in this revision

Viewing changes to libdrizzle-5.1/table_map_event.h

  • Committer: kuldeep
  • Date: 2013-09-19 22:27:25 UTC
  • Revision ID: kuldeep@kuldeep-laptop-20130919222725-xsb4tlxp0tp3mm2t
Adding Tested code on local environment, now we can access the new api functions within library

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (C) 2013 Drizzle Developer Group
 
3
 * Copyright (C) 2013 Kuldeep Porwal
 
4
 * All rights reserved.
 
5
 *
 
6
 * Use and distribution licensed under the BSD license.  See
 
7
 * the COPYING file in the parent directory for full text.
 
8
 *
 
9
 * summary: parse table map event
 
10
 *
 
11
 */
 
12
#include<cstring>
 
13
#include<inttypes.h>
 
14
 
 
15
#ifndef event_interface
 
16
#define event_interface
 
17
#include"event_interface.h"
 
18
#endif
 
19
using namespace std;
 
20
#ifndef HELPER
 
21
#define HELPER
 
22
 
 
23
#include"helper.h"
 
24
 
 
25
#endif
 
26
 
 
27
#ifndef TABLE_MAP
 
28
#define TABLE_MAP
 
29
//using namespace binlogevent;
 
30
namespace binlogevent
 
31
{
 
32
        class TableMapEvent : public Events 
 
33
        {
 
34
                public:
 
35
 
 
36
                        TableMapEvent() : table_id(-1),
 
37
                        flag(-1),
 
38
                        schema_name_len(-1),
 
39
                        schema_name(NULL),
 
40
                        table_name_len(-1),
 
41
                        table_name(NULL),
 
42
                        column_count(-1),
 
43
                        column_type_def(NULL),
 
44
                        column_meta_data(NULL)
 
45
                {
 
46
                }
 
47
 
 
48
                        ~TableMapEvent()
 
49
                        {
 
50
                        }
 
51
 
 
52
 
 
53
                        /**
 
54
                         * Get the raw data and call all the setters with
 
55
                         * appropriate value
 
56
                         *
 
57
                         * @param[in] data Raw data from binglog.
 
58
                         */
 
59
                        DRIZZLE_API
 
60
                        void initWithData(const unsigned char * data);
 
61
 
 
62
 
 
63
                        //getters
 
64
 
 
65
                        /**
 
66
                         * @retval timestamp of event.
 
67
                         */
 
68
                        DRIZZLE_API
 
69
                        uint32_t getTimestamp();
 
70
                        /**
 
71
                         * @retval type of event.
 
72
                         */
 
73
                        DRIZZLE_API
 
74
                        enum_event_type getType();
 
75
                        /**
 
76
                         * @retval server-id of the originating mysql-server. Used to filter out events in circular replication.
 
77
                         */
 
78
                        DRIZZLE_API
 
79
                        uint32_t getServerId();
 
80
                        /**
 
81
                         * @retval of position of the next event .
 
82
                         */
 
83
                        DRIZZLE_API
 
84
                        uint32_t getLogPos();
 
85
                        /**
 
86
                         * @retval Binlog Event Flag from header
 
87
                         */
 
88
                        DRIZZLE_API
 
89
                        uint16_t getFlagH();
 
90
                        
 
91
                        /**
 
92
                         * @retval numeric table id 
 
93
                         */
 
94
                        DRIZZLE_API
 
95
                        uint64_t getTableId();
 
96
                        /**
 
97
                         * @retval flag of post header 
 
98
                         */
 
99
                        DRIZZLE_API
 
100
                        uint16_t getFlagPh();
 
101
                        /**
 
102
                         * @retval length of the schema name 
 
103
                         */
 
104
                        DRIZZLE_API
 
105
                        int getSchemaNameLen();
 
106
                        /**
 
107
                         * @retval schema name 
 
108
                         */
 
109
                        DRIZZLE_API
 
110
                        char * getSchemaName();
 
111
                        /**
 
112
                         * @retval length of table name
 
113
                         */
 
114
                        DRIZZLE_API
 
115
                        int getTableNameLen();
 
116
                        /**
 
117
                         * @retval table name 
 
118
                         */
 
119
                        DRIZZLE_API
 
120
                        char * getTableName();
 
121
                        /**
 
122
                         * In funtion : conversion of length-encoded integer into its numeric value
 
123
                         * @retval number of columns in the table map  
 
124
                         */
 
125
                        DRIZZLE_API
 
126
                        uint64_t getColumnCount();
 
127
                        /**
 
128
                         * @retval array of column definitions, one byte per field type  
 
129
                         */
 
130
                        DRIZZLE_API
 
131
                         uint8_t * getColumnTypeDef();
 
132
                        
 
133
                         /**
 
134
                         * @retval enum {INT,STRING} as a type of column  
 
135
                         */
 
136
 
 
137
                        DRIZZLE_API
 
138
                         enum_col_type getColType(int colNo);
 
139
 
 
140
                        //setters
 
141
 
 
142
                        DRIZZLE_API
 
143
                        void setTableId(uint64_t value);
 
144
                        /**
 
145
                         * set flag_ph.
 
146
                         *
 
147
                         * @param[in] value Post header flag.
 
148
                         */
 
149
                        DRIZZLE_API
 
150
                        void setFlagPh(uint16_t value);
 
151
                        /**
 
152
                         * set schema_name_len.
 
153
                         *
 
154
                         * @param[in] value Length of the schema name. 
 
155
                         */
 
156
                        DRIZZLE_API
 
157
                        void setSchemaNameLen(uint8_t value);
 
158
                        /**
 
159
                         * set schema_name.
 
160
                         *
 
161
                         * @param[in] value Schema Name or Database name.
 
162
                         */
 
163
                        DRIZZLE_API
 
164
                        void setSchemaName(char *value);
 
165
                        /**
 
166
                         * set table_name_len.
 
167
                         *
 
168
                         * @param[in] value Table name length.
 
169
                         */
 
170
                        DRIZZLE_API
 
171
                        void setTableNameLen(uint8_t value);
 
172
                        /**
 
173
                         * set table_name.
 
174
                         *
 
175
                         * @param[in] value Table name.
 
176
                         */
 
177
                        DRIZZLE_API
 
178
                        void setTableName(char *value);
 
179
                        /**
 
180
                         * set column_count.
 
181
                         *
 
182
                         * @param[in] value Column count in table map.
 
183
                         */
 
184
                        DRIZZLE_API
 
185
                        void setColumnCount(uint64_t value);
 
186
                        /**
 
187
                         * set column_type_def.
 
188
                         *
 
189
                         * @param[in] value Array of column definitions, one byte per field type
 
190
                         */
 
191
                        DRIZZLE_API
 
192
                        void setColumnTypeDef(uint8_t * value);
 
193
 
 
194
 
 
195
 
 
196
                private:
 
197
                        uint64_t table_id;  
 
198
                        uint16_t flag; //post header
 
199
                        uint8_t schema_name_len;
 
200
                        char * schema_name;
 
201
                        uint8_t table_name_len;
 
202
                        char * table_name;
 
203
                        uint64_t column_count; 
 
204
                        uint8_t * column_type_def;
 
205
                        uint64_t * column_meta_data;
 
206
 
 
207
        }; // tablemapevent
 
208
} /*namespace binlogevent*/
 
209
#endif