~drizzle-trunk/drizzle/development

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
 *
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.8 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
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
20
#include <config.h>
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
21
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
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
24
namespace drizzled
25
{
26
574.3.8 by Lee
moving functions from item_strfunc to functions/str directory
27
String *Item_str_conv::val_str(String *str)
28
{
29
  assert(fixed == 1);
30
  String *res;
31
  if (!(res=args[0]->val_str(str)))
32
  {
971.6.11 by Eric Day
Removed purecov messages.
33
    null_value=1;
34
    return 0;
574.3.8 by Lee
moving functions from item_strfunc to functions/str directory
35
  }
36
  null_value=0;
37
  if (multiply == 1)
38
  {
39
    uint32_t len;
40
    res= copy_if_not_alloced(str,res,res->length());
41
    len= converter(collation.collation, (char*) res->ptr(), res->length(),
42
                                        (char*) res->ptr(), res->length());
43
    assert(len <= res->length());
44
    res->length(len);
45
  }
46
  else
47
  {
48
    uint32_t len= res->length() * multiply;
49
    tmp_value.alloc(len);
50
    tmp_value.set_charset(collation.collation);
51
    len= converter(collation.collation, (char*) res->ptr(), res->length(),
52
                                        (char*) tmp_value.ptr(), len);
53
    tmp_value.length(len);
54
    res= &tmp_value;
55
  }
56
  return res;
57
}
58
59
void Item_func_lcase::fix_length_and_dec()
60
{
61
  collation.set(args[0]->collation);
62
  multiply= collation.collation->casedn_multiply;
63
  converter= collation.collation->cset->casedn;
64
  max_length= args[0]->max_length * multiply;
65
}
66
67
void Item_func_ucase::fix_length_and_dec()
68
{
69
  collation.set(args[0]->collation);
70
  multiply= collation.collation->caseup_multiply;
71
  converter= collation.collation->cset->caseup;
72
  max_length= args[0]->max_length * multiply;
73
}
74
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
75
} /* namespace drizzled */