642.1.6
by Lee
move functions from item.cc/item.h to item directory |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
642.1.6
by Lee
move functions from item.cc/item.h to item directory |
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 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
20 |
#include <config.h> |
2154.2.4
by Brian Aker
This fixes 716459 |
21 |
|
2281.5.1
by Muhammad Umair
Merged charset declarations of global_charset_info.h and charset_info.h into charset.h header file. |
22 |
#include <drizzled/charset.h> |
2154.2.4
by Brian Aker
This fixes 716459 |
23 |
#include <drizzled/field.h> |
24 |
#include <drizzled/internal/m_string.h> |
|
642.1.6
by Lee
move functions from item.cc/item.h to item directory |
25 |
#include <drizzled/item/int.h> |
26 |
||
2318.7.19
by Olaf van der Spek
Refactor Items |
27 |
namespace drizzled { |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
28 |
|
642.1.6
by Lee
move functions from item.cc/item.h to item directory |
29 |
/**
|
30 |
Create an item from a string we KNOW points to a valid int64_t
|
|
31 |
end \\0 terminated number string.
|
|
32 |
This is always 'signed'. Unsigned values are created with Item_uint()
|
|
33 |
*/
|
|
34 |
||
35 |
Item_int::Item_int(const char *str_arg, uint32_t length) |
|
36 |
{
|
|
37 |
char *end_ptr= (char*) str_arg + length; |
|
38 |
int error; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
39 |
value= internal::my_strtoll10(str_arg, &end_ptr, &error); |
895
by Brian Aker
Completion (?) of uint conversion. |
40 |
max_length= (uint32_t) (end_ptr - str_arg); |
642.1.6
by Lee
move functions from item.cc/item.h to item directory |
41 |
name= (char*) str_arg; |
42 |
fixed= 1; |
|
43 |
}
|
|
44 |
||
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
45 |
type::Decimal *Item_int::val_decimal(type::Decimal *decimal_value) |
642.1.6
by Lee
move functions from item.cc/item.h to item directory |
46 |
{
|
2030.1.3
by Brian Aker
Second pass through function names. |
47 |
int2_class_decimal(E_DEC_FATAL_ERROR, value, unsigned_flag, decimal_value); |
642.1.6
by Lee
move functions from item.cc/item.h to item directory |
48 |
return decimal_value; |
49 |
}
|
|
50 |
||
51 |
String *Item_int::val_str(String *str) |
|
52 |
{
|
|
53 |
// following assert is redundant, because fixed=1 assigned in constructor
|
|
54 |
assert(fixed == 1); |
|
55 |
str->set(value, &my_charset_bin); |
|
56 |
return str; |
|
57 |
}
|
|
58 |
||
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
59 |
void Item_int::print(String *str) |
642.1.6
by Lee
move functions from item.cc/item.h to item directory |
60 |
{
|
61 |
// my_charset_bin is good enough for numbers
|
|
62 |
str_value.set(value, &my_charset_bin); |
|
63 |
str->append(str_value); |
|
64 |
}
|
|
65 |
||
66 |
int Item_int::save_in_field(Field *field, bool) |
|
67 |
{
|
|
68 |
int64_t nr=val_int(); |
|
69 |
if (null_value) |
|
70 |
return set_field_to_null(field); |
|
71 |
field->set_notnull(); |
|
72 |
return field->store(nr, unsigned_flag); |
|
73 |
}
|
|
74 |
||
75 |
bool Item_int::eq(const Item *arg, bool) const |
|
76 |
{
|
|
77 |
/* No need to check for null value as basic constant can't be NULL */
|
|
78 |
if (arg->basic_const_item() && arg->type() == type()) |
|
79 |
{
|
|
80 |
/*
|
|
81 |
We need to cast off const to call val_int(). This should be OK for
|
|
82 |
a basic constant.
|
|
83 |
*/
|
|
84 |
Item *item= (Item*) arg; |
|
85 |
return item->val_int() == value && item->unsigned_flag == unsigned_flag; |
|
86 |
}
|
|
87 |
return false; |
|
88 |
}
|
|
89 |
||
90 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
91 |
} /* namespace drizzled */ |