~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/long.h

Merge of Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/* - mode: c++ c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2008 MySQL
21
21
#ifndef DRIZZLE_SERVER_FIELD_LONG
22
22
#define DRIZZLE_SERVER_FIELD_LONG
23
23
 
 
24
#include <drizzled/field/num.h>
 
25
 
24
26
class Field_long :public Field_num {
25
27
public:
26
 
  Field_long(uchar *ptr_arg, uint32_t len_arg, uchar *null_ptr_arg,
27
 
             uchar null_bit_arg,
 
28
 
 
29
  using Field::val_int;
 
30
  using Field::val_str;
 
31
  using Field::cmp;
 
32
  using Field::pack;
 
33
  using Field::store;
 
34
  using Field::unpack;
 
35
 
 
36
  Field_long(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
 
37
             unsigned char null_bit_arg,
28
38
             enum utype unireg_check_arg, const char *field_name_arg,
29
39
             bool zero_arg, bool unsigned_arg)
30
40
    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
33
43
    {}
34
44
  Field_long(uint32_t len_arg,bool maybe_null_arg, const char *field_name_arg,
35
45
             bool unsigned_arg)
36
 
    :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
 
46
    :Field_num((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0,0,
37
47
               NONE, field_name_arg,0,0,unsigned_arg)
38
48
    {}
39
49
  enum Item_result result_type () const { return INT_RESULT; }
40
50
  enum_field_types type() const { return DRIZZLE_TYPE_LONG;}
41
51
  enum ha_base_keytype key_type() const
42
52
    { return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
43
 
  int store(const char *to,uint length, const CHARSET_INFO * const charset);
 
53
  int store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
44
54
  int store(double nr);
45
55
  int store(int64_t nr, bool unsigned_val);
46
56
  int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
47
57
  double val_real(void);
48
58
  int64_t val_int(void);
49
 
  bool send_binary(Protocol *protocol);
50
59
  String *val_str(String*,String *);
51
 
  int cmp(const uchar *,const uchar *);
52
 
  void sort_string(uchar *buff,uint length);
 
60
  int cmp(const unsigned char *,const unsigned char *);
 
61
  void sort_string(unsigned char *buff,uint32_t length);
53
62
  uint32_t pack_length() const { return 4; }
54
63
  void sql_type(String &str) const;
55
64
  uint32_t max_display_length() { return MY_INT32_NUM_DECIMAL_DIGITS; }
56
 
  virtual uchar *pack(uchar* to, const uchar *from,
57
 
                      uint max_length __attribute__((unused)),
58
 
                      bool low_byte_first __attribute__((unused)))
59
 
  {
60
 
    int32_t val;
61
 
#ifdef WORDS_BIGENDIAN
62
 
    if (table->s->db_low_byte_first)
63
 
      val = sint4korr(from);
64
 
    else
65
 
#endif
66
 
      longget(val, from);
67
 
 
68
 
#ifdef WORDS_BIGENDIAN
69
 
    if (low_byte_first)
70
 
      int4store(to, val);
71
 
    else
72
 
#endif
73
 
      longstore(to, val);
74
 
    return to + sizeof(val);
75
 
  }
76
 
 
77
 
  virtual const uchar *unpack(uchar* to, const uchar *from,
78
 
                              uint param_data __attribute__((unused)),
79
 
                              bool low_byte_first __attribute__((unused)))
80
 
  {
81
 
    int32_t val;
82
 
#ifdef WORDS_BIGENDIAN
83
 
    if (low_byte_first)
84
 
      val = sint4korr(from);
85
 
    else
86
 
#endif
87
 
      longget(val, from);
88
 
 
89
 
#ifdef WORDS_BIGENDIAN
90
 
    if (table->s->db_low_byte_first)
91
 
      int4store(to, val);
92
 
    else
93
 
#endif
94
 
      longstore(to, val);
95
 
    return from + sizeof(val);
96
 
  }
 
65
  virtual unsigned char *pack(unsigned char* to, const unsigned char *from,
 
66
                      uint32_t max_length,
 
67
                      bool low_byte_first);
 
68
 
 
69
  virtual const unsigned char *unpack(unsigned char* to, const unsigned char *from,
 
70
                              uint32_t param_data,
 
71
                              bool low_byte_first);
97
72
};
98
73
 
99
74
#endif