Drizzled Public API Documentation

statement.h
00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Vijay Samuel
00005  *  Copyright (C) 2008 MySQL
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #pragma once
00023 
00024 #include "client_priv.h"
00025 #include <string>
00026 #include <iosfwd>
00027 #include <cstdlib>
00028 
00029 
00030 /* Types */
00031 enum slap_query_t {
00032   SELECT_TYPE= 0,
00033   UPDATE_TYPE= 1,
00034   INSERT_TYPE= 2,
00035   UPDATE_TYPE_REQUIRES_PREFIX= 3,
00036   CREATE_TABLE_TYPE= 4,
00037   SELECT_TYPE_REQUIRES_PREFIX= 5,
00038   DELETE_TYPE_REQUIRES_PREFIX= 6
00039 };
00040 
00041 
00042 class Statement 
00043 {
00044 public:
00045   Statement(char *in_string,
00046             size_t in_length,
00047             slap_query_t in_type,
00048             Statement *in_next) :
00049     string(in_string),
00050     length(in_length),
00051     type(in_type),
00052     next(in_next)
00053   { }
00054 
00055   Statement() :
00056     string(NULL),
00057     length(0),
00058     type(),
00059     next(NULL)
00060   { }
00061 
00062   ~Statement()
00063   {
00064     free(string);
00065   }
00066    
00067   char *getString() const
00068   {
00069     return string;
00070   }
00071 
00072   size_t getLength() const
00073   {
00074     return length;
00075   }
00076 
00077   slap_query_t getType() const
00078   {
00079     return type;
00080   }
00081 
00082   Statement *getNext() const
00083   {
00084     return next;
00085   }
00086 
00087   void setString(char *in_string)
00088   {
00089     string= in_string;
00090   }
00091 
00092   void setString(size_t length_arg)
00093   {
00094     string= (char *)calloc(length_arg + 1, sizeof(char));
00095     length= length_arg;
00096   }
00097 
00098   void setString(size_t in_length, char in_char)
00099   {
00100     string[in_length]= in_char;
00101   }
00102 
00103   void setLength(size_t in_length)
00104   {
00105     length= in_length;
00106   }
00107 
00108   void setType(slap_query_t in_type)
00109   {
00110     type= in_type;
00111   }
00112 
00113   void setNext(Statement *in_next)
00114   {
00115     next= in_next;
00116   }
00117 
00118 private:
00119   char *string;
00120   size_t length;
00121   slap_query_t type;
00122   Statement *next;
00123 };