574.3.10
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 |
*
|
|
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.
|
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
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
|
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
21 |
|
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
22 |
#include <drizzled/function/str/strfunc.h> |
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
23 |
|
2281.4.16
by Olaf van der Spek
Return void |
24 |
namespace drizzled { |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
25 |
|
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
26 |
class Item_func_conv_charset :public Item_str_func |
27 |
{
|
|
28 |
bool use_cached_value; |
|
29 |
public: |
|
30 |
bool safe; |
|
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
31 |
const charset_info_st *conv_charset; // keep it public |
32 |
Item_func_conv_charset(Item *a, const charset_info_st * const cs) :Item_str_func(a) |
|
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
33 |
{ conv_charset= cs; use_cached_value= 0; safe= 0; } |
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
34 |
Item_func_conv_charset(Item *a, const charset_info_st * const cs, bool cache_if_const) |
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
35 |
:Item_str_func(a) |
36 |
{
|
|
37 |
assert(args[0]->fixed); |
|
38 |
conv_charset= cs; |
|
39 |
if (cache_if_const && args[0]->const_item()) |
|
40 |
{
|
|
41 |
String tmp, *str= args[0]->val_str(&tmp); |
|
2281.4.16
by Olaf van der Spek
Return void |
42 |
if (!str) |
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
43 |
null_value= 1; |
2281.4.16
by Olaf van der Spek
Return void |
44 |
else
|
2281.6.2
by Olaf van der Spek
Return void |
45 |
str_value.copy(str->ptr(), str->length(), conv_charset); |
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
46 |
use_cached_value= 1; |
47 |
str_value.mark_as_const(); |
|
2281.6.2
by Olaf van der Spek
Return void |
48 |
safe= true; |
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
49 |
}
|
50 |
else
|
|
51 |
{
|
|
2281.4.16
by Olaf van der Spek
Return void |
52 |
use_cached_value= false; |
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
53 |
/*
|
54 |
Conversion from and to "binary" is safe.
|
|
55 |
Conversion to Unicode is safe.
|
|
56 |
Other kind of conversions are potentially lossy.
|
|
57 |
*/
|
|
58 |
safe= (args[0]->collation.collation == &my_charset_bin || |
|
59 |
cs == &my_charset_bin || |
|
60 |
(cs->state & MY_CS_UNICODE)); |
|
61 |
}
|
|
62 |
}
|
|
63 |
String *val_str(String *); |
|
64 |
void fix_length_and_dec(); |
|
65 |
const char *func_name() const { return "convert"; } |
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
66 |
virtual void print(String *str); |
574.3.10
by Lee
moving functions from item_strfunc to functions/str directory |
67 |
};
|
68 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
69 |
} /* namespace drizzled */ |
70 |