Drizzled Public API Documentation

char.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/char.h>
23 
24 namespace drizzled
25 {
26 
28 {
29  assert(fixed == 1);
30  str->length(0);
31  str->set_charset(collation.collation);
32  for (uint32_t i=0 ; i < arg_count ; i++)
33  {
34  int32_t num=(int32_t) args[i]->val_int();
35  if (!args[i]->null_value)
36  {
37  char char_num= (char) num;
38  if (num&0xFF000000L) {
39  str->append((char)(num>>24));
40  goto b2;
41  } else if (num&0xFF0000L) {
42  b2: str->append((char)(num>>16));
43  goto b1;
44  } else if (num&0xFF00L) {
45  b1: str->append((char)(num>>8));
46  }
47  str->append(&char_num, 1);
48  }
49  }
50  str->realloc(str->length()); // Add end 0 (for Purify)
51  return check_well_formed_result(str);
52 }
53 
54 } /* namespace drizzled */