~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/boolean.h

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#ifndef DRIZZLED_ITEM_BOOLEAN_H
21
 
#define DRIZZLED_ITEM_BOOLEAN_H
22
 
 
23
 
#include "drizzled/item/basic_constant.h"
24
 
 
25
 
namespace drizzled
26
 
{
27
 
 
28
 
namespace item
29
 
{
30
 
 
31
 
class Boolean: public Item_basic_constant
32
 
{
33
 
  bool value;
34
 
 
35
 
public:
36
 
  Boolean(const char *str_arg, bool arg) :
37
 
    Item_basic_constant(),
38
 
    value(arg)
39
 
  {
40
 
    max_length= value ? 4 : 5;
41
 
    fixed= true;
42
 
    name= (const_cast<char *>(str_arg));
43
 
  }
44
 
 
45
 
  Boolean(bool arg) :
46
 
    value(arg)
47
 
  {
48
 
    max_length= value ? 4 : 5;
49
 
    fixed= true;
50
 
 
51
 
    if (value)
52
 
    {
53
 
      name= const_cast<char *>("TRUE");
54
 
    }
55
 
    else
56
 
    {
57
 
      name= const_cast<char *>("FALSE");
58
 
    }
59
 
  }
60
 
 
61
 
  enum Type type() const { return BOOLEAN_ITEM; }
62
 
 
63
 
  virtual bool val_bool()
64
 
  {
65
 
    return value;
66
 
  }
67
 
 
68
 
  double val_real()
69
 
  {
70
 
    return value ? 1 : 0;
71
 
  }
72
 
 
73
 
  int64_t val_int() 
74
 
  {
75
 
    return value ? 1 : 0;
76
 
  }
77
 
 
78
 
  drizzled::String* val_str(drizzled::String *value_buffer)
79
 
  {
80
 
    value_buffer->realloc(5);
81
 
 
82
 
    if (value)
83
 
    {
84
 
      value_buffer->append("TRUE");
85
 
    }
86
 
    else
87
 
    {
88
 
      value_buffer->append("FALSE");
89
 
    }
90
 
 
91
 
    return value_buffer;
92
 
  }
93
 
 
94
 
  type::Decimal* val_decimal(type::Decimal *dec)
95
 
  {
96
 
    (void)dec;
97
 
    return 0;
98
 
  }
99
 
 
100
 
};
101
 
 
102
 
} /* namespace item */
103
 
} /* namespace drizzled */
104
 
 
105
 
#include "drizzled/item/true.h"
106
 
#include "drizzled/item/false.h"
107
 
 
108
 
#endif /* DRIZZLED_ITEM_BOOLEAN_H */