Drizzled Public API Documentation

str_conv.cc
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, Inc.
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 
20 #include <config.h>
21 
22 #include <drizzled/function/str/str_conv.h>
23 
24 namespace drizzled
25 {
26 
28 {
29  assert(fixed == 1);
30  String *res;
31  if (!(res=args[0]->val_str(str)))
32  {
33  null_value=1;
34  return 0;
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 
75 } /* namespace drizzled */
bool fixed
Definition: item.h:120
String * val_str(String *)
Definition: str_conv.cc:27
bool null_value
Definition: item.h:122