Drizzled Public API Documentation

lex_string.h

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <stddef.h>
00023 
00024 namespace drizzled
00025 {
00026 
00027 /*
00028   LEX_STRING -- a pair of a C-string and its length.
00029 */
00030 
00031 /* This definition must match the one given in mysql/plugin.h */
00032 typedef struct lex_string_t
00033 {
00034   char *str;
00035   size_t length;
00036 } LEX_STRING;
00037 
00038 inline const LEX_STRING &null_lex_string()
00039 {
00040   static LEX_STRING tmp= { NULL, 0 };
00041   return tmp;
00042 }
00043 
00044 #define NULL_LEX_STRING null_lex_string()
00045 
00046 struct execute_string_t : public lex_string_t
00047 {
00048 private:
00049   bool is_variable;
00050 public:
00051 
00052   bool isVariable() const
00053   {
00054     return is_variable;
00055   }
00056 
00057   void set(const lex_string_t& ptr, bool is_variable_arg= false)
00058   {
00059     is_variable= is_variable_arg;
00060     str= ptr.str;
00061     length= ptr.length;
00062   }
00063 
00064 };
00065 
00066 
00067 #define STRING_WITH_LEN(X) (X), (static_cast<size_t>((sizeof(X) - 1)))
00068 #define C_STRING_WITH_LEN(X) (const_cast<char *>((X))), (static_cast<size_t>((sizeof(X) - 1)))
00069 
00070 } /* namespace drizzled */
00071