~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/str.h

  • Committer: Monty Taylor
  • Date: 2008-10-16 09:12:23 UTC
  • mto: (511.1.6 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016091223-17ngih0qu9vssjs3
We pass -Wunused-macros now!

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef DRIZZLED_FIELD_STR_H
22
 
#define DRIZZLED_FIELD_STR_H
23
 
 
24
 
#include <drizzled/field.h>
25
 
 
26
 
namespace drizzled
27
 
{
28
 
 
29
 
typedef struct charset_info_st CHARSET_INFO;
 
21
#ifndef DRIZZLE_SERVER_FIELD_STR
 
22
#define DRIZZLE_SERVER_FIELD_STR
30
23
 
31
24
/* base class for all string related classes */
32
25
 
34
27
protected:
35
28
  const CHARSET_INFO *field_charset;
36
29
  enum Derivation field_derivation;
37
 
  int  report_if_important_data(const char *ptr, const char *end);
38
30
public:
39
 
  Field_str(unsigned char *ptr_arg,
40
 
            uint32_t len_arg,
41
 
            unsigned char *null_ptr_arg,
42
 
            unsigned char null_bit_arg,
43
 
            const char *field_name_arg,
44
 
            const CHARSET_INFO * const charset);
 
31
  Field_str(unsigned char *ptr_arg,uint32_t len_arg, unsigned char *null_ptr_arg,
 
32
            unsigned char null_bit_arg, utype unireg_check_arg,
 
33
            const char *field_name_arg, const CHARSET_INFO * const charset);
45
34
  Item_result result_type () const { return STRING_RESULT; }
46
35
  uint32_t decimals() const { return NOT_FIXED_DEC; }
47
 
 
48
 
  using Field::store;
49
36
  int  store(double nr);
50
37
  int  store(int64_t nr, bool unsigned_val)=0;
51
38
  int  store_decimal(const my_decimal *);
52
39
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const cs)=0;
53
 
 
54
40
  uint32_t size_of() const { return sizeof(*this); }
55
41
  const CHARSET_INFO *charset(void) const { return field_charset; }
56
 
  void set_charset(const CHARSET_INFO * const charset_arg)
57
 
  { field_charset= charset_arg; }
 
42
  void set_charset(const CHARSET_INFO * const charset_arg) { field_charset= charset_arg; }
58
43
  enum Derivation derivation(void) const { return field_derivation; }
59
44
  virtual void set_derivation(enum Derivation derivation_arg)
60
45
  { field_derivation= derivation_arg; }
61
46
  bool binary() const { return field_charset == &my_charset_bin; }
62
47
  uint32_t max_display_length() { return field_length; }
63
 
  friend class CreateField;
 
48
  friend class Create_field;
64
49
  my_decimal *val_decimal(my_decimal *);
65
50
  virtual bool str_needs_quotes() { return true; }
66
 
  uint32_t max_data_length() const;
 
51
  bool compare_str_field_flags(Create_field *new_field, uint32_t flags);
 
52
  uint32_t is_equal(Create_field *new_field);
67
53
};
68
54
 
69
 
/*
70
 
  Report "not well formed" or "cannot convert" error
71
 
  after storing a character string info a field.
72
 
 
73
 
  SYNOPSIS
74
 
    check_string_copy_error()
75
 
    field                    - Field
76
 
    well_formed_error_pos    - where not well formed data was first met
77
 
    cannot_convert_error_pos - where a not-convertable character was first met
78
 
    end                      - end of the string
79
 
    cs                       - character set of the string
80
 
 
81
 
  NOTES
82
 
    As of version 5.0 both cases return the same error:
83
 
 
84
 
      "Invalid string value: 'xxx' for column 't' at row 1"
85
 
 
86
 
  Future versions will possibly introduce a new error message:
87
 
 
88
 
      "Cannot convert character string: 'xxx' for column 't' at row 1"
89
 
 
90
 
  RETURN
91
 
    false - If errors didn't happen
92
 
    true  - If an error happened
93
 
*/
94
 
 
95
 
bool check_string_copy_error(Field_str *field,
96
 
                             const char *well_formed_error_pos,
97
 
                             const char *cannot_convert_error_pos,
98
 
                             const char *end,
99
 
                             const CHARSET_INFO * const cs);
100
 
 
101
 
 
102
 
} /* namespace drizzled */
103
 
 
104
 
#endif /* DRIZZLED_FIELD_STR_H */
 
55
#endif