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 {
00026
00027 namespace item
00028 {
00029
00030 class Boolean: public Item_basic_constant
00031 {
00032 bool value;
00033
00034 public:
00035 Boolean(const char *str_arg, bool arg) :
00036 Item_basic_constant(),
00037 value(arg)
00038 {
00039 max_length= value ? 4 : 5;
00040 fixed= true;
00041 name= (const_cast<char *>(str_arg));
00042 }
00043
00044 Boolean(bool arg) :
00045 value(arg)
00046 {
00047 max_length= value ? 4 : 5;
00048 fixed= true;
00049
00050 if (value)
00051 {
00052 name= const_cast<char *>("TRUE");
00053 }
00054 else
00055 {
00056 name= const_cast<char *>("FALSE");
00057 }
00058 }
00059
00060 enum Type type() const { return BOOLEAN_ITEM; }
00061
00062 virtual bool val_bool()
00063 {
00064 return value;
00065 }
00066
00067 double val_real()
00068 {
00069 return value ? 1 : 0;
00070 }
00071
00072 int64_t val_int()
00073 {
00074 return value ? 1 : 0;
00075 }
00076
00077 drizzled::String* val_str(drizzled::String *value_buffer)
00078 {
00079 value_buffer->realloc(5);
00080
00081 if (value)
00082 {
00083 value_buffer->append("TRUE");
00084 }
00085 else
00086 {
00087 value_buffer->append("FALSE");
00088 }
00089
00090 return value_buffer;
00091 }
00092
00093 type::Decimal* val_decimal(type::Decimal *dec)
00094 {
00095 (void)dec;
00096 return 0;
00097 }
00098
00099 };
00100
00101 }
00102 }
00103
00104 #include <drizzled/item/true.h>
00105 #include <drizzled/item/false.h>
00106