00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <drizzled/item/basic_constant.h>
00023
00024 namespace drizzled {
00025 namespace item {
00026
00027 class Boolean : public Item_basic_constant
00028 {
00029 bool value;
00030
00031 public:
00032 Boolean(const char *str_arg, bool arg) :
00033 value(arg)
00034 {
00035 max_length= value ? 4 : 5;
00036 fixed= true;
00037 name= str_arg;
00038 }
00039
00040 Boolean(bool arg) :
00041 value(arg)
00042 {
00043 max_length= value ? 4 : 5;
00044 fixed= true;
00045 name= value ? "TRUE" : "FALSE";
00046 }
00047
00048 enum Type type() const { return BOOLEAN_ITEM; }
00049
00050 Item_result result_type() const
00051 {
00052 return INT_RESULT;
00053 }
00054
00055 virtual bool val_bool()
00056 {
00057 return value;
00058 }
00059
00060 double val_real()
00061 {
00062 return value ? 1 : 0;
00063 }
00064
00065 int64_t val_int()
00066 {
00067 return value ? 1 : 0;
00068 }
00069
00070 drizzled::String* val_str(drizzled::String *value_buffer)
00071 {
00072 value_buffer->realloc(5);
00073
00074 if (value)
00075 {
00076 value_buffer->copy("TRUE", 4, default_charset());
00077 }
00078 else
00079 {
00080 value_buffer->copy("FALSE", 5, default_charset());
00081 }
00082
00083 return value_buffer;
00084 }
00085
00086 type::Decimal* val_decimal(type::Decimal*)
00087 {
00088 return 0;
00089 }
00090
00091 };
00092
00093 }
00094 }
00095
00096 #include <drizzled/item/true.h>
00097 #include <drizzled/item/false.h>
00098