~drizzle-trunk/drizzle/development

520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
21
2371.1.2 by Brian Aker
Remove the typedef on lexkey
22
#include <cstddef>
2440.2.9 by Olaf van der Spek
Refactor
23
#include <drizzled/util/data_ref.h>
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
24
2318.8.2 by Olaf van der Spek
lex_string_t -> LEX_STRING
25
namespace drizzled {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
26
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
27
/*
2371.1.2 by Brian Aker
Remove the typedef on lexkey
28
  lex_string_t -- a pair of a C-string and its length.
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
29
*/
30
31
/* This definition must match the one given in mysql/plugin.h */
2371.1.2 by Brian Aker
Remove the typedef on lexkey
32
struct lex_string_t
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
33
{
2318.8.6 by Olaf van der Spek
Add const
34
  const char* begin() const
35
  {
2433.1.1 by Olaf van der Spek
Refactor
36
    return data();
2318.8.6 by Olaf van der Spek
Add const
37
  }
38
39
  const char* end() const
40
  {
2433.1.1 by Olaf van der Spek
Refactor
41
    return data() + size();
2318.8.6 by Olaf van der Spek
Add const
42
  }
43
2430.2.1 by Olaf van der Spek
Add data(), size() and assign() to lex_string
44
  const char* data() const
45
  {
2430.1.8 by Olaf van der Spek
Use assign(), data() and size()
46
    return str_;
2430.2.1 by Olaf van der Spek
Add data(), size() and assign() to lex_string
47
  }
48
49
  size_t size() const
50
  {
2430.1.7 by Olaf van der Spek
Use size()
51
    return length_;
2430.2.1 by Olaf van der Spek
Add data(), size() and assign() to lex_string
52
  }
53
54
  void assign(const char* d, size_t s)
55
  {
2430.1.8 by Olaf van der Spek
Use assign(), data() and size()
56
    str_= const_cast<char*>(d);
2430.1.7 by Olaf van der Spek
Use size()
57
    length_ = s;
2430.2.1 by Olaf van der Spek
Add data(), size() and assign() to lex_string
58
  }
59
2440.2.9 by Olaf van der Spek
Refactor
60
  void operator=(str_ref v)
61
  {
62
    assign(v.data(), v.size());
63
  }
64
2430.1.8 by Olaf van der Spek
Use assign(), data() and size()
65
  char* str_;
2430.1.7 by Olaf van der Spek
Use size()
66
  size_t length_;
2371.1.2 by Brian Aker
Remove the typedef on lexkey
67
};
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
68
2371.1.2 by Brian Aker
Remove the typedef on lexkey
69
inline const lex_string_t &null_lex_string()
2114.4.5 by Brian Aker
Remove duplicate code around ident check.
70
{
2371.1.2 by Brian Aker
Remove the typedef on lexkey
71
  static lex_string_t tmp= { NULL, 0 };
2114.4.5 by Brian Aker
Remove duplicate code around ident check.
72
  return tmp;
73
}
74
2073.1.2 by Brian Aker
Basic DDL for catalog.
75
struct execute_string_t : public lex_string_t
1921.4.1 by Brian Aker
Adding in support for EXECUTE to have WITH NO RETURN.
76
{
1921.4.4 by Brian Aker
Fix for Solaris.
77
private:
1921.4.1 by Brian Aker
Adding in support for EXECUTE to have WITH NO RETURN.
78
  bool is_variable;
1921.4.4 by Brian Aker
Fix for Solaris.
79
public:
1921.4.1 by Brian Aker
Adding in support for EXECUTE to have WITH NO RETURN.
80
81
  bool isVariable() const
82
  {
83
    return is_variable;
84
  }
85
2430.2.1 by Olaf van der Spek
Add data(), size() and assign() to lex_string
86
  void set(const lex_string_t& s, bool is_variable_arg= false)
1921.4.4 by Brian Aker
Fix for Solaris.
87
  {
88
    is_variable= is_variable_arg;
2430.2.1 by Olaf van der Spek
Add data(), size() and assign() to lex_string
89
    static_cast<lex_string_t&>(*this) = s;
1921.4.1 by Brian Aker
Adding in support for EXECUTE to have WITH NO RETURN.
90
  }
91
92
};
93
2385.1.1 by Olaf van der Spek
Refactor lex_string_t
94
#define STRING_WITH_LEN(X) (X), (sizeof(X) - 1)
95
#define C_STRING_WITH_LEN(X) const_cast<char*>(X), (sizeof(X) - 1)
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
96
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
97
} /* namespace drizzled */
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
98