1
#ifndef INCLUDES_DRIZZLE_SQL_LIST_H
2
#define INCLUDES_DRIZZLE_SQL_LIST_H
3
/* Copyright (C) 2000-2003 MySQL AB
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#ifndef DRIZZLED_SQL_LIST_H
21
#define DRIZZLED_SQL_LIST_H
27
#include <drizzled/sql_alloc.h>
23
29
/** Struct to handle simple linked lists. */
24
30
typedef struct st_sql_list {
29
35
st_sql_list() {} /* Remove gcc warning */
30
36
inline void empty()
65
/* mysql standard class memory allocator */
69
static void *operator new(size_t size) throw ()
71
return sql_alloc(size);
73
static void *operator new[](size_t size)
75
return sql_alloc(size);
77
static void *operator new[](size_t size, MEM_ROOT *mem_root) throw ()
78
{ return alloc_root(mem_root, size); }
79
static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
80
{ return alloc_root(mem_root, size); }
81
static void operator delete(void *ptr __attribute__((unused)),
82
size_t size __attribute__((unused)))
84
static void operator delete(void *ptr __attribute__((unused)),
85
MEM_ROOT *mem_root __attribute__((unused)))
86
{ /* never called */ }
87
static void operator delete[](void *ptr __attribute__((unused)),
88
MEM_ROOT *mem_root __attribute__((unused)))
89
{ /* never called */ }
90
static void operator delete[](void *ptr __attribute__((unused)),
91
size_t size __attribute__((unused)))
95
inline Sql_alloc() :dummy(0) {}
96
inline ~Sql_alloc() {}
99
inline ~Sql_alloc() {}
106
72
Basic single linked list
107
73
Used for item and item_buffs.
167
133
list_copy_and_replace_each_value after creating a copy.
169
135
base_list(const base_list &rhs, MEM_ROOT *mem_root);
170
inline base_list(bool error __attribute__((unused))) { }
136
inline base_list(bool) { }
171
137
inline bool push_back(void *info)
173
139
if (((*last)=new list_node(info, &end_of_list)))
259
225
inline void swap(base_list &rhs)
261
swap_variables(list_node *, first, rhs.first);
262
swap_variables(list_node **, last, rhs.last);
263
swap_variables(uint, elements, rhs.elements);
227
std::swap(first, rhs.first);
228
std::swap(last, rhs.last);
229
std::swap(elements, rhs.elements);
265
231
inline list_node* last_node() { return *last; }
266
232
inline list_node* first_node() { return first;}
334
300
list_node **el,**prev,*current;
335
void sublist(base_list &ls, uint elm)
301
void sublist(base_list &ls, uint32_t elm)
338
304
ls.last= list->last;
339
305
ls.elements= elm;
343
309
:list(0), el(0), prev(0), current(0)
346
base_list_iterator(base_list &list_par)
312
base_list_iterator(base_list &list_par)
347
313
{ init(list_par); }
349
315
inline void init(base_list &list_par)
465
431
template <class T> class List_iterator_fast :public base_list_iterator
468
inline T *replace(T *a __attribute__((unused))) { return (T*) 0; }
469
inline T *replace(List<T> &a __attribute__((unused))) { return (T*) 0; }
434
inline T *replace(T *) { return (T*) 0; }
435
inline T *replace(List<T> &) { return (T*) 0; }
470
436
inline void remove(void) { }
471
inline void after(T *a __attribute__((unused))) { }
437
inline void after(T *a) { }
472
438
inline T** ref(void) { return (T**) 0; }
477
443
inline void init(List<T> &a) { base_list_iterator::init(a); }
478
444
inline T* operator++(int) { return (T*) base_list_iterator::next_fast(); }
479
445
inline void rewind(void) { base_list_iterator::rewind(); }
480
void sublist(List<T> &list_arg, uint el_arg)
446
void sublist(List<T> &list_arg, uint32_t el_arg)
482
448
base_list_iterator::sublist(list_arg, el_arg);
494
460
struct ilink **prev,*next;
495
461
static void *operator new(size_t size)
497
return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE | ME_FATALERROR));
463
return (void*)malloc((uint)size);
499
static void operator delete(void* ptr_arg,
500
size_t size __attribute__((unused)))
465
static void operator delete(void* ptr_arg, size_t)
502
my_free((uchar*)ptr_arg, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
467
free((unsigned char*)ptr_arg);
536
501
i_string_pair():key(0),val(0) { }
537
i_string_pair(const char* key_arg, const char* val_arg) :
502
i_string_pair(const char* key_arg, const char* val_arg) :
538
503
key(key_arg),val(val_arg) {}
606
571
I_List() :base_ilist() {}
607
572
inline void empty() { base_ilist::empty(); }
608
inline bool is_empty() { return base_ilist::is_empty(); }
573
inline bool is_empty() { return base_ilist::is_empty(); }
609
574
inline void append(T* a) { base_ilist::append(a); }
610
575
inline void push_back(T* a) { base_ilist::push_back(a); }
611
576
inline T* get() { return (T*) base_ilist::get(); }