~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.cc

  • Committer: Monty Taylor
  • Date: 2009-12-25 02:36:12 UTC
  • mfrom: (1253 build)
  • mto: (1253.2.3 out-of-tree)
  • mto: This revision was merged to the branch mainline in revision 1258.
  • Revision ID: mordred@inaugust.com-20091225023612-7hekryz87dtus3ph
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include "config.h"
19
19
 
20
 
#include <mysys/my_sys.h>
21
 
#include <mystrings/m_string.h>
 
20
#include "drizzled/internal/my_sys.h"
 
21
#include "drizzled/internal/m_string.h"
 
22
#include "drizzled/charset.h"
22
23
 
23
24
#include <algorithm>
24
25
 
 
26
#include "drizzled/sql_string.h"
 
27
 
25
28
using namespace std;
26
29
 
27
 
/*
28
 
  The following extern declarations are ok as these are interface functions
29
 
  required by the string function
30
 
*/
31
 
 
32
 
extern unsigned char* sql_alloc(unsigned size);
33
 
extern void sql_element_free(void *ptr);
34
 
 
35
 
#include "sql_string.h"
36
 
 
37
30
/*****************************************************************************
38
31
** String functions
39
32
*****************************************************************************/
40
33
 
 
34
String::String()
 
35
  : Ptr(0),
 
36
    str_length(0),
 
37
    Alloced_length(0),
 
38
    alloced(0),
 
39
    str_charset(&my_charset_bin)
 
40
{ }
 
41
 
 
42
String::String(uint32_t length_arg)
 
43
  : Ptr(0),
 
44
    str_length(0),
 
45
    Alloced_length(0),
 
46
    alloced(0),
 
47
    str_charset(&my_charset_bin)
 
48
{
 
49
  (void) real_alloc(length_arg);
 
50
}
 
51
 
 
52
String::String(const char *str, const CHARSET_INFO * const cs)
 
53
  : Ptr(const_cast<char*>(str)),
 
54
    str_length(static_cast<uint32_t>(strlen(str))),
 
55
    Alloced_length(0),
 
56
    alloced(0),
 
57
    str_charset(cs)
 
58
{ }
 
59
 
 
60
String::String(const char *str, uint32_t len, const CHARSET_INFO * const cs)
 
61
  : Ptr(const_cast<char*>(str)),
 
62
    str_length(len),
 
63
    Alloced_length(0),
 
64
    alloced(0),
 
65
    str_charset(cs)
 
66
{ }
 
67
 
 
68
String::String(char *str,uint32_t len, const CHARSET_INFO * const cs)
 
69
  : Ptr(str),
 
70
    str_length(len),
 
71
    Alloced_length(len),
 
72
    alloced(0),
 
73
    str_charset(cs)
 
74
{ }
 
75
 
 
76
String::String(const String &str)
 
77
  : Ptr(str.Ptr),
 
78
    str_length(str.str_length),
 
79
    Alloced_length(str.Alloced_length),
 
80
    alloced(0),
 
81
    str_charset(str.str_charset)
 
82
{ }
 
83
 
 
84
void *String::operator new(size_t size, MEM_ROOT *mem_root)
 
85
{
 
86
  return alloc_root(mem_root, static_cast<uint32_t>(size));
 
87
}
 
88
 
41
89
String::~String() { free(); }
42
90
 
43
91
bool String::real_alloc(uint32_t arg_length)
725
773
  return !(s1 == s2);
726
774
}
727
775
 
 
776
bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
 
777
                             char *end)
 
778
{
 
779
  return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;
 
780
}