~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.h

  • Committer: Monty Taylor
  • Date: 2010-11-25 01:53:19 UTC
  • mto: (1953.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1955.
  • Revision ID: mordred@inaugust.com-20101125015319-ia85msn25uemopgc
Re-enabled -Wformat and then cleaned up the carnage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
  /* Prevent use of these */
81
81
  Field(const Field&);
82
82
  void operator=(Field &);
83
 
 
84
83
public:
85
84
  unsigned char *ptr; /**< Position to field in record. Stores raw field value */
86
85
  unsigned char *null_ptr; /**< Byte where null_bit is */
141
140
  utype unireg_check;
142
141
  uint32_t field_length; /**< Length of this field in bytes */
143
142
  uint32_t flags;
144
 
private:
145
143
  uint16_t field_index; /**< Index of this Field in Table::fields array */
146
 
 
147
 
public:
148
 
 
149
 
  uint16_t position() const
150
 
  {
151
 
    return field_index;
152
 
  }
153
 
 
154
 
  void setPosition(uint32_t arg)
155
 
  {
156
 
    field_index= arg;
157
 
  }
158
 
 
159
144
  unsigned char null_bit; /**< Bit used to test null bit */
160
145
  /**
161
146
     If true, this field was created in create_tmp_field_from_item from a NULL
181
166
        utype unireg_check_arg,
182
167
        const char *field_name_arg);
183
168
  virtual ~Field() {}
184
 
 
185
 
  bool hasDefault() const
186
 
  {
187
 
    return not (flags & NO_DEFAULT_VALUE_FLAG);
188
 
  }
189
 
 
190
169
  /* Store functions returns 1 on overflow and -1 on fatal error */
191
170
  virtual int store(const char *to,
192
171
                    uint32_t length,
194
173
  virtual int store(double nr)=0;
195
174
  virtual int store(int64_t nr, bool unsigned_val)=0;
196
175
  virtual int store_decimal(const my_decimal *d)=0;
197
 
  int store_and_check(enum_check_fields check_level,
198
 
                      const char *to,
199
 
                      uint32_t length,
200
 
                      const CHARSET_INFO * const cs);
 
176
  int store(const char *to,
 
177
            uint32_t length,
 
178
            const CHARSET_INFO * const cs,
 
179
            enum_check_fields check_level);
201
180
  /**
202
181
    This is called when storing a date in a string.
203
182
 
205
184
      Needs to be changed if/when we want to support different time formats.
206
185
  */
207
186
  virtual int store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type t_type);
208
 
  virtual double val_real()=0;
209
 
  virtual int64_t val_int()=0;
 
187
  virtual double val_real(void)=0;
 
188
  virtual int64_t val_int(void)=0;
210
189
  virtual my_decimal *val_decimal(my_decimal *);
211
 
  String *val_str_internal(String *str)
 
190
  inline String *val_str(String *str)
212
191
  {
213
192
    return val_str(str, str);
214
193
  }
322
301
  virtual uint32_t key_length() const;
323
302
  virtual enum_field_types type() const =0;
324
303
  virtual enum_field_types real_type() const;
325
 
  virtual int cmp_max(const unsigned char *a, const unsigned char *b, uint32_t max_len);
 
304
  inline  int cmp(const unsigned char *str) { return cmp(ptr,str); }
 
305
  virtual int cmp_max(const unsigned char *a, const unsigned char *b,
 
306
                      uint32_t max_len);
326
307
  virtual int cmp(const unsigned char *,const unsigned char *)=0;
327
 
  int cmp_internal(const unsigned char *str) { return cmp(ptr,str); }
328
308
  virtual int cmp_binary(const unsigned char *a,const unsigned char *b,
329
309
                         uint32_t max_length=UINT32_MAX);
330
310
  virtual int cmp_offset(uint32_t row_offset);
376
356
                               uint32_t new_null_bit);
377
357
  /** This is used to generate a field in Table from TableShare */
378
358
  Field *clone(memory::Root *mem_root, Table *new_table);
379
 
  void move_field(unsigned char *ptr_arg,unsigned char *null_ptr_arg,unsigned char null_bit_arg)
 
359
  inline void move_field(unsigned char *ptr_arg,unsigned char *null_ptr_arg,unsigned char null_bit_arg)
380
360
  {
381
361
    ptr= ptr_arg;
382
362
    null_ptr= null_ptr_arg;
383
363
    null_bit= null_bit_arg;
384
364
  }
385
 
  void move_field(unsigned char *ptr_arg) { ptr=ptr_arg; }
 
365
  inline void move_field(unsigned char *ptr_arg) { ptr=ptr_arg; }
386
366
  virtual void move_field_offset(ptrdiff_t ptr_diff)
387
367
  {
388
368
    ptr= ADD_TO_PTR(ptr,ptr_diff, unsigned char*);
440
420
  {
441
421
    set_image(buff,length, &my_charset_bin);
442
422
  }
443
 
  int64_t val_int_offset(uint32_t row_offset)
 
423
  inline int64_t val_int_offset(uint32_t row_offset)
444
424
  {
445
425
    ptr+=row_offset;
446
426
    int64_t tmp=val_int();
448
428
    return tmp;
449
429
  }
450
430
 
451
 
  int64_t val_int_internal(const unsigned char *new_ptr)
 
431
  inline int64_t val_int(const unsigned char *new_ptr)
452
432
  {
453
433
    unsigned char *old_ptr= ptr;
454
434
    int64_t return_value;
457
437
    ptr= old_ptr;
458
438
    return return_value;
459
439
  }
460
 
 
461
 
  String *val_str_internal(String *str, const unsigned char *new_ptr)
 
440
  inline String *val_str(String *str, const unsigned char *new_ptr)
462
441
  {
463
442
    unsigned char *old_ptr= ptr;
464
443
    ptr= const_cast<unsigned char*>(new_ptr);
465
 
    val_str_internal(str);
 
444
    val_str(str);
466
445
    ptr= old_ptr;
467
446
    return str;
468
447
  }
571
550
    return max_length;
572
551
  }
573
552
 
574
 
  uint32_t offset(const unsigned char *record)
 
553
  inline uint32_t offset(const unsigned char *record)
575
554
  {
576
555
    return (uint32_t) (ptr - record);
577
556
  }
669
648
                            const uint32_t code,
670
649
                            double nr,
671
650
                            enum enum_drizzle_timestamp_type ts_type);
672
 
  bool check_overflow(int op_result)
 
651
  inline bool check_overflow(int op_result)
673
652
  {
674
653
    return (op_result == E_DEC_OVERFLOW);
675
654
  }
707
686
                                  bool unsigned_flag,
708
687
                                  int *err);
709
688
  /* The max. number of characters */
710
 
  uint32_t char_length() const
 
689
  inline uint32_t char_length() const
711
690
  {
712
691
    return field_length / charset()->mbmaxlen;
713
692
  }
714
693
 
715
 
  enum column_format_type column_format() const
 
694
  inline enum column_format_type column_format() const
716
695
  {
717
696
    return (enum column_format_type)
718
697
      ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
741
720
  void setWriteSet(bool arg= true);
742
721
};
743
722
 
744
 
std::ostream& operator<<(std::ostream& output, const Field &field);
745
 
 
746
723
} /* namespace drizzled */
747
724
 
748
725
/** @TODO Why is this in the middle of the file???*/