Drizzled Public API Documentation

copy_string.h
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 #pragma once
21 
22 #include <drizzled/charset.h>
23 #include <drizzled/item/field.h>
24 #include <drizzled/item/ident.h>
25 
26 namespace drizzled {
27 
28 class Item_copy_string : public Item
29 {
30  enum enum_field_types cached_field_type;
31 public:
32  Item *item;
33  Item_copy_string(Item *i) :item(i)
34  {
36  decimals=item->decimals;
37  max_length=item->max_length;
38  name=item->name;
39  cached_field_type= item->field_type();
40  }
41  enum Type type() const { return COPY_STR_ITEM; }
42  enum Item_result result_type () const { return STRING_RESULT; }
43  enum_field_types field_type() const { return cached_field_type; }
44  double val_real()
45  {
46  int err_not_used;
47  char *end_not_used;
48  return (null_value ? 0.0 :
49  my_strntod(str_value.charset(), (char*) str_value.ptr(),
50  str_value.length(), &end_not_used, &err_not_used));
51  }
52  int64_t val_int()
53  {
54  int err;
55  return null_value ? 0 : my_strntoll(str_value.charset(),str_value.ptr(),
56  str_value.length(),10, (char**) 0,
57  &err);
58  }
61  void make_field(SendField *field) { item->make_field(field); }
62  void copy();
63  int save_in_field(Field *field, bool)
64  {
65  return save_str_value_in_field(field, &str_value);
66  }
67  table_map used_tables() const { return (table_map) 1; }
68  bool const_item() const { return false; }
69  bool is_null() { return null_value; }
70 };
71 
72 } /* namespace drizzled */
73 
const char * name
Definition: item.h:110
TODO: Rename this file - func.h is stupid.
bool null_value
Definition: item.h:122
int save_str_value_in_field(Field *field, String *result)
Definition: item.cc:272
table_map used_tables() const
Definition: copy_string.h:67
bool maybe_null
Definition: item.h:121
type::Decimal * val_decimal(type::Decimal *)
Definition: copy_string.cc:46
bool const_item() const
Definition: copy_string.h:68
String * val_str(String *)
Definition: copy_string.cc:37
String str_value
Definition: item.h:107