~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/int64_t.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 01:02:23 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321010223-j8cph7eeyt1u3xol
Fixed function object to ensure it correctly returns a boolean type since
memcmp returns an integer. Added some more comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef DRIZZLE_SERVER_FIELD_INT_64_T
22
22
#define DRIZZLE_SERVER_FIELD_INT_64_T
23
23
 
 
24
#include <drizzled/field/num.h>
 
25
 
24
26
class Field_int64_t :public Field_num {
25
27
public:
26
 
  Field_int64_t(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
27
 
              unsigned char null_bit_arg,
28
 
              enum utype unireg_check_arg, const char *field_name_arg,
29
 
              bool zero_arg, bool unsigned_arg)
 
28
 
 
29
  using Field::val_int;
 
30
  using Field::val_str;
 
31
  using Field::cmp;
 
32
  using Field::store;
 
33
  using Field::pack;
 
34
  using Field::unpack;
 
35
 
 
36
  Field_int64_t(unsigned char *ptr_arg, uint32_t len_arg,
 
37
                unsigned char *null_ptr_arg,
 
38
                unsigned char null_bit_arg,
 
39
                enum utype unireg_check_arg, const char *field_name_arg,
 
40
                bool zero_arg, bool unsigned_arg)
30
41
    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
31
 
               unireg_check_arg, field_name_arg,
32
 
               0, zero_arg,unsigned_arg)
 
42
               unireg_check_arg, field_name_arg,
 
43
               0, zero_arg,unsigned_arg)
33
44
    {}
34
45
  Field_int64_t(uint32_t len_arg,bool maybe_null_arg,
35
 
                 const char *field_name_arg,
36
 
                  bool unsigned_arg)
 
46
                const char *field_name_arg,
 
47
                bool unsigned_arg)
37
48
    :Field_num((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0,0,
38
 
               NONE, field_name_arg,0,0,unsigned_arg)
 
49
               NONE, field_name_arg,0,0,unsigned_arg)
39
50
    {}
40
51
  enum Item_result result_type () const { return INT_RESULT; }
41
52
  enum_field_types type() const { return DRIZZLE_TYPE_LONGLONG;}
52
63
  double val_real(void);
53
64
  int64_t val_int(void);
54
65
  String *val_str(String*,String *);
55
 
  bool send_binary(Protocol *protocol);
56
66
  int cmp(const unsigned char *,const unsigned char *);
57
67
  void sort_string(unsigned char *buff,uint32_t length);
58
68
  uint32_t pack_length() const { return 8; }
60
70
  bool can_be_compared_as_int64_t() const { return true; }
61
71
  uint32_t max_display_length() { return 20; }
62
72
  virtual unsigned char *pack(unsigned char* to, const unsigned char *from,
63
 
                      uint32_t max_length __attribute__((unused)),
64
 
                      bool low_byte_first __attribute__((unused)))
65
 
  {
66
 
    int64_t val;
67
 
#ifdef WORDS_BIGENDIAN
68
 
    if (table->s->db_low_byte_first)
69
 
      val = sint8korr(from);
70
 
    else
71
 
#endif
72
 
      int64_tget(val, from);
73
 
 
74
 
#ifdef WORDS_BIGENDIAN
75
 
    if (low_byte_first)
76
 
      int8store(to, val);
77
 
    else
78
 
#endif
79
 
      int64_tstore(to, val);
80
 
    return to + sizeof(val);
81
 
  }
 
73
                              uint32_t max_length,
 
74
                              bool low_byte_first);
82
75
 
83
76
  virtual const unsigned char *unpack(unsigned char* to, const unsigned char *from,
84
 
                              uint32_t param_data __attribute__((unused)),
85
 
                              bool low_byte_first __attribute__((unused)))
86
 
  {
87
 
    int64_t val;
88
 
#ifdef WORDS_BIGENDIAN
89
 
    if (low_byte_first)
90
 
      val = sint8korr(from);
91
 
    else
92
 
#endif
93
 
      int64_tget(val, from);
 
77
                              uint32_t param_data,
 
78
                              bool low_byte_first);
94
79
 
95
 
#ifdef WORDS_BIGENDIAN
96
 
    if (table->s->db_low_byte_first)
97
 
      int8store(to, val);
98
 
    else
99
 
#endif
100
 
      int64_tstore(to, val);
101
 
    return from + sizeof(val);
102
 
  }
103
80
};
104
81
 
105
82
#endif