~drizzle-trunk/drizzle/development

483.1.5 by Lee
clean up code for Field_str
1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 MySQL
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
20
21
#ifndef DRIZZLE_SERVER_FIELD_STR
22
#define DRIZZLE_SERVER_FIELD_STR
23
584.5.1 by Monty Taylor
Removed field includes from field.h.
24
#include <drizzled/field.h>
25
26
typedef struct charset_info_st CHARSET_INFO;
27
483.1.5 by Lee
clean up code for Field_str
28
/* base class for all string related classes */
29
30
class Field_str :public Field {
31
protected:
32
  const CHARSET_INFO *field_charset;
33
  enum Derivation field_derivation;
1034.1.3 by Brian Aker
Collapse field classes (this does change enum/time decimal conversion
34
  int  report_if_important_data(const char *ptr, const char *end);
483.1.5 by Lee
clean up code for Field_str
35
public:
1119.9.12 by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp.
36
  Field_str(unsigned char *ptr_arg,
37
            uint32_t len_arg,
584.5.1 by Monty Taylor
Removed field includes from field.h.
38
            unsigned char *null_ptr_arg,
1119.9.12 by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp.
39
            unsigned char null_bit_arg,
40
            const char *field_name_arg,
41
            const CHARSET_INFO * const charset);
483.1.5 by Lee
clean up code for Field_str
42
  Item_result result_type () const { return STRING_RESULT; }
43
  uint32_t decimals() const { return NOT_FIXED_DEC; }
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
44
45
  using Field::store;
483.1.5 by Lee
clean up code for Field_str
46
  int  store(double nr);
47
  int  store(int64_t nr, bool unsigned_val)=0;
48
  int  store_decimal(const my_decimal *);
49
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const cs)=0;
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
50
483.1.5 by Lee
clean up code for Field_str
51
  uint32_t size_of() const { return sizeof(*this); }
52
  const CHARSET_INFO *charset(void) const { return field_charset; }
584.5.1 by Monty Taylor
Removed field includes from field.h.
53
  void set_charset(const CHARSET_INFO * const charset_arg)
54
  { field_charset= charset_arg; }
483.1.5 by Lee
clean up code for Field_str
55
  enum Derivation derivation(void) const { return field_derivation; }
56
  virtual void set_derivation(enum Derivation derivation_arg)
57
  { field_derivation= derivation_arg; }
58
  bool binary() const { return field_charset == &my_charset_bin; }
59
  uint32_t max_display_length() { return field_length; }
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
60
  friend class CreateField;
483.1.5 by Lee
clean up code for Field_str
61
  my_decimal *val_decimal(my_decimal *);
62
  virtual bool str_needs_quotes() { return true; }
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
63
  bool compare_str_field_flags(CreateField *new_field, uint32_t flags);
64
  uint32_t is_equal(CreateField *new_field);
1034.1.3 by Brian Aker
Collapse field classes (this does change enum/time decimal conversion
65
  uint32_t max_data_length() const;
483.1.5 by Lee
clean up code for Field_str
66
};
67
584.5.1 by Monty Taylor
Removed field includes from field.h.
68
/*
69
  Report "not well formed" or "cannot convert" error
70
  after storing a character string info a field.
71
72
  SYNOPSIS
73
    check_string_copy_error()
74
    field                    - Field
75
    well_formed_error_pos    - where not well formed data was first met
76
    cannot_convert_error_pos - where a not-convertable character was first met
77
    end                      - end of the string
78
    cs                       - character set of the string
79
80
  NOTES
81
    As of version 5.0 both cases return the same error:
82
83
      "Invalid string value: 'xxx' for column 't' at row 1"
84
85
  Future versions will possibly introduce a new error message:
86
87
      "Cannot convert character string: 'xxx' for column 't' at row 1"
88
89
  RETURN
90
    false - If errors didn't happen
91
    true  - If an error happened
92
*/
93
94
bool check_string_copy_error(Field_str *field,
95
                             const char *well_formed_error_pos,
96
                             const char *cannot_convert_error_pos,
97
                             const char *end,
98
                             const CHARSET_INFO * const cs);
99
100
483.1.5 by Lee
clean up code for Field_str
101
#endif