drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
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
26namespace drizzled {
27
28class Item_copy_string : public Item
29{
30 enum enum_field_types cached_field_type;
31public:
32 Item *item;
33 Item_copy_string(Item *i) :item(i)
34 {
35 null_value= maybe_null= item->maybe_null;
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
type::Decimal * val_decimal(type::Decimal *)
table_map used_tables() const
Definition copy_string.h:67
String * val_str(String *)
int save_str_value_in_field(Field *field, String *result)
Definition item.cc:272
bool null_value
Definition item.h:124
const char * name
Definition item.h:112
bool maybe_null
Definition item.h:123
String str_value
Definition item.h:109
TODO: Rename this file - func.h is stupid.