drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
item/int.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/item/num.h>
23#include <drizzled/util/test.h>
24
25namespace drizzled {
26
27class Item_int : public Item_num
28{
29public:
30 int64_t value;
31
32 Item_int(int32_t i,uint32_t length= MY_INT32_NUM_DECIMAL_DIGITS) :
33 value((int64_t) i)
34 { max_length=length; fixed= 1; }
35
36 Item_int(int64_t i,uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS) :
37 value(i)
38 { max_length=length; fixed= 1; }
39
40 Item_int(uint64_t i, uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS) :
41 value((int64_t)i)
42 { max_length=length; fixed=1; }
43
44 Item_int(const char *str_arg,int64_t i,uint32_t length) :
45 value(i)
46 { max_length= length; name= const_cast<char *>(str_arg); fixed= 1; }
47
48 Item_int(const char *str_arg, uint32_t length=64);
49
50 enum Type type() const { return INT_ITEM; }
51
52 enum Item_result result_type () const { return INT_RESULT; }
53
54 enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
55
56 int64_t val_int() { assert(fixed == 1); return value; }
57
58 double val_real() { assert(fixed == 1); return (double) value; }
59
61
63
64 int save_in_field(Field *field, bool no_conversions);
65
66 bool basic_const_item() const { return 1; }
67
68 Item *clone_item() { return new Item_int(name,value,max_length); }
69
70 virtual void print(String *str);
71
72 Item_num *neg() { value= -value; return this; }
73
74 uint32_t decimal_precision() const
75 { return (uint32_t)(max_length - test(value < 0)); }
76
77 bool eq(const Item *, bool binary_cmp) const;
78};
79
80} /* namespace drizzled */
81
virtual void print(String *str)
Definition item/int.cc:59
type::Decimal * val_decimal(type::Decimal *)
Definition item/int.cc:45
bool basic_const_item() const
Definition item/int.h:66
String * val_str(String *)
Definition item/int.cc:51
double val_real()
Definition item/int.h:58
int64_t val_int()
Definition item/int.h:56
bool eq(const Item *, bool binary_cmp) const
Definition item/int.cc:75
bool fixed
Definition item.h:122
const char * name
Definition item.h:112
TODO: Rename this file - func.h is stupid.