~drizzle-trunk/drizzle/development

1848.5.1 by Vijay Samuel
Merge pushed classes of drizzleslap out into separate classes.
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2010 Vijay Samuel
1848.5.2 by Vijay Samuel
Merge corrections to licensing information.
5
 *  Copyright (C) 2008 MySQL
1848.5.1 by Vijay Samuel
Merge pushed classes of drizzleslap out into separate classes.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
 */
21
1848.5.4 by Vijay Samuel
Merge added #ifndef tags
22
#ifndef CLIENT_STATEMENT_H
23
#define CLIENT_STATEMENT_H
24
1848.5.1 by Vijay Samuel
Merge pushed classes of drizzleslap out into separate classes.
25
#include "client_priv.h"
26
#include <string>
27
#include <iostream>
28
#include <cstdlib>
29
30
31
/* Types */
32
enum slap_query_t {
33
  SELECT_TYPE= 0,
34
  UPDATE_TYPE= 1,
35
  INSERT_TYPE= 2,
36
  UPDATE_TYPE_REQUIRES_PREFIX= 3,
37
  CREATE_TABLE_TYPE= 4,
38
  SELECT_TYPE_REQUIRES_PREFIX= 5,
39
  DELETE_TYPE_REQUIRES_PREFIX= 6
40
};
41
42
43
class Statement 
44
{
45
public:
46
  Statement(char *in_string,
47
            size_t in_length,
48
            slap_query_t in_type,
49
            Statement *in_next) :
50
    string(in_string),
51
    length(in_length),
52
    type(in_type),
53
    next(in_next)
54
  { }
55
56
  Statement() :
57
    string(NULL),
58
    length(0),
59
    type(),
60
    next(NULL)
61
  { }
62
63
  ~Statement()
64
  {
65
    if (string)
66
      free(string);
67
  }
68
   
69
  char *getString() const
70
  {
71
    return string;
72
  }
73
74
  size_t getLength() const
75
  {
76
    return length;
77
  }
78
79
  slap_query_t getType() const
80
  {
81
    return type;
82
  }
83
84
  Statement *getNext() const
85
  {
86
    return next;
87
  }
88
89
  void setString(char *in_string)
90
  {
91
    string= in_string;
92
  }
93
94
  void setString(size_t length_arg)
95
  {
96
    string= (char *)calloc(length_arg + 1, sizeof(char));
97
    length= length_arg;
98
  }
99
100
  void setString(size_t in_length, char in_char)
101
  {
102
    string[in_length]= in_char;
103
  }
104
105
  void setLength(size_t in_length)
106
  {
107
    length= in_length;
108
  }
109
110
  void setType(slap_query_t in_type)
111
  {
112
    type= in_type;
113
  }
114
115
  void setNext(Statement *in_next)
116
  {
117
    next= in_next;
118
  }
119
120
private:
121
  char *string;
122
  size_t length;
123
  slap_query_t type;
124
  Statement *next;
125
};
1848.5.4 by Vijay Samuel
Merge added #ifndef tags
126
127
#endif /* CLIENT_STATEMENT_H */