1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
#include "DataBuffer.hpp"
21
typedef DataBuffer<7> RopeBase;
22
typedef DataBuffer<7>::DataBufferPool RopePool;
25
RopeHandle() { m_hash = 0; }
28
RopeBase::Head m_head;
30
Uint32 hashValue() const { return m_hash; }
33
class ConstRope : private RopeBase {
35
ConstRope(RopePool& thePool, const RopeHandle& handle)
36
: RopeBase(thePool), src(handle)
38
this->head = src.m_head;
47
void copy(char* buf) const;
49
int compare(const char * s) const { return compare(s, strlen(s) + 1); }
50
int compare(const char *, size_t len) const;
53
const RopeHandle & src;
56
class Rope : private RopeBase {
58
Rope(RopePool& thePool, RopeHandle& handle)
59
: RopeBase(thePool), src(handle)
61
this->head = src.m_head;
66
src.m_head = this->head;
73
void copy(char* buf) const;
75
int compare(const char * s) const { return compare(s, strlen(s) + 1); }
76
int compare(const char *, size_t len) const;
78
bool assign(const char * s) { return assign(s, strlen(s) + 1);}
79
bool assign(const char * s, size_t l) { return assign(s, l, hash(s, l));}
80
bool assign(const char *, size_t len, Uint32 hash);
84
static Uint32 hash(const char * str, Uint32 len);
100
return head.used == 0;
105
ConstRope::size() const {
111
ConstRope::empty() const {
112
return head.used == 0;