574.3.8
by Lee
moving functions from item_strfunc to functions/str directory |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
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 |
||
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
20 |
#include "config.h" |
574.3.8
by Lee
moving functions from item_strfunc to functions/str directory |
21 |
#include CSTDINT_H
|
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
22 |
#include <drizzled/function/str/str_conv.h> |
574.3.8
by Lee
moving functions from item_strfunc to functions/str directory |
23 |
|
24 |
String *Item_str_conv::val_str(String *str) |
|
25 |
{
|
|
26 |
assert(fixed == 1); |
|
27 |
String *res; |
|
28 |
if (!(res=args[0]->val_str(str))) |
|
29 |
{
|
|
971.6.11
by Eric Day
Removed purecov messages. |
30 |
null_value=1; |
31 |
return 0; |
|
574.3.8
by Lee
moving functions from item_strfunc to functions/str directory |
32 |
}
|
33 |
null_value=0; |
|
34 |
if (multiply == 1) |
|
35 |
{
|
|
36 |
uint32_t len; |
|
37 |
res= copy_if_not_alloced(str,res,res->length()); |
|
38 |
len= converter(collation.collation, (char*) res->ptr(), res->length(), |
|
39 |
(char*) res->ptr(), res->length()); |
|
40 |
assert(len <= res->length()); |
|
41 |
res->length(len); |
|
42 |
}
|
|
43 |
else
|
|
44 |
{
|
|
45 |
uint32_t len= res->length() * multiply; |
|
46 |
tmp_value.alloc(len); |
|
47 |
tmp_value.set_charset(collation.collation); |
|
48 |
len= converter(collation.collation, (char*) res->ptr(), res->length(), |
|
49 |
(char*) tmp_value.ptr(), len); |
|
50 |
tmp_value.length(len); |
|
51 |
res= &tmp_value; |
|
52 |
}
|
|
53 |
return res; |
|
54 |
}
|
|
55 |
||
56 |
void Item_func_lcase::fix_length_and_dec() |
|
57 |
{
|
|
58 |
collation.set(args[0]->collation); |
|
59 |
multiply= collation.collation->casedn_multiply; |
|
60 |
converter= collation.collation->cset->casedn; |
|
61 |
max_length= args[0]->max_length * multiply; |
|
62 |
}
|
|
63 |
||
64 |
void Item_func_ucase::fix_length_and_dec() |
|
65 |
{
|
|
66 |
collation.set(args[0]->collation); |
|
67 |
multiply= collation.collation->caseup_multiply; |
|
68 |
converter= collation.collation->cset->caseup; |
|
69 |
max_length= args[0]->max_length * multiply; |
|
70 |
}
|
|
71 |