drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
item/boolean.h
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
*
4
* Copyright (C) 2010 Brian Aker
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/basic_constant.h>
23
24
namespace
drizzled
{
25
namespace
item {
26
27
class
Boolean :
public
Item_basic_constant
28
{
29
bool
value;
30
31
public
:
32
Boolean(
const
char
*str_arg,
bool
arg) :
33
value(arg)
34
{
35
max_length= value ? 4 : 5;
36
fixed
=
true
;
37
name
= str_arg;
38
}
39
40
Boolean(
bool
arg) :
41
value(arg)
42
{
43
max_length= value ? 4 : 5;
44
fixed
=
true
;
45
name
= value ?
"TRUE"
:
"FALSE"
;
46
}
47
48
enum
Type type()
const
{
return
BOOLEAN_ITEM; }
49
50
Item_result result_type()
const
51
{
52
return
INT_RESULT;
53
}
54
55
virtual
bool
val_bool
()
56
{
57
return
value;
58
}
59
60
double
val_real
()
61
{
62
return
value ? 1 : 0;
63
}
64
65
int64_t
val_int
()
66
{
67
return
value ? 1 : 0;
68
}
69
70
drizzled::String
*
val_str
(
drizzled::String
*value_buffer)
71
{
72
value_buffer->realloc(5);
73
74
if
(value)
75
{
76
value_buffer->copy(
"TRUE"
, 4, default_charset());
77
}
78
else
79
{
80
value_buffer->copy(
"FALSE"
, 5, default_charset());
81
}
82
83
return
value_buffer;
84
}
85
86
type::Decimal
*
val_decimal
(
type::Decimal
*)
87
{
88
return
0;
89
}
90
91
};
92
93
}
/* namespace item */
94
}
/* namespace drizzled */
95
96
#include <drizzled/item/true.h>
97
#include <drizzled/item/false.h>
98
drizzled::Item_basic_constant
Definition
basic_constant.h:27
drizzled::Item::fixed
bool fixed
Definition
item.h:122
drizzled::Item::name
const char * name
Definition
item.h:112
drizzled::String
Definition
sql_string.h:58
drizzled::item::Boolean::val_bool
virtual bool val_bool()
Definition
item/boolean.h:55
drizzled::item::Boolean::val_decimal
type::Decimal * val_decimal(type::Decimal *)
Definition
item/boolean.h:86
drizzled::item::Boolean::val_str
drizzled::String * val_str(drizzled::String *value_buffer)
Definition
item/boolean.h:70
drizzled::item::Boolean::val_int
int64_t val_int()
Definition
item/boolean.h:65
drizzled::item::Boolean::val_real
double val_real()
Definition
item/boolean.h:60
drizzled::type::Decimal
Definition
type/decimal.h:184
drizzled
TODO: Rename this file - func.h is stupid.
Definition
abort_exception.h:27
← Back to Drizzle docs
drizzled
item
boolean.h
Generated by
1.15.0