~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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
21
#pragma once
483.1.5 by Lee
clean up code for Field_str
22
584.5.1 by Monty Taylor
Removed field includes from field.h.
23
#include <drizzled/field.h>
24
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
25
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
26
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
27
namespace drizzled
28
{
29
483.1.5 by Lee
clean up code for Field_str
30
/* base class for all string related classes */
31
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
32
class DRIZZLED_API Field_str :
33
  public Field
34
{
483.1.5 by Lee
clean up code for Field_str
35
protected:
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
36
  const charset_info_st *field_charset;
483.1.5 by Lee
clean up code for Field_str
37
  enum Derivation field_derivation;
1034.1.3 by Brian Aker
Collapse field classes (this does change enum/time decimal conversion
38
  int  report_if_important_data(const char *ptr, const char *end);
483.1.5 by Lee
clean up code for Field_str
39
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.
40
  Field_str(unsigned char *ptr_arg,
41
            uint32_t len_arg,
584.5.1 by Monty Taylor
Removed field includes from field.h.
42
            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.
43
            unsigned char null_bit_arg,
44
            const char *field_name_arg,
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
45
            const charset_info_st * const charset);
483.1.5 by Lee
clean up code for Field_str
46
  Item_result result_type () const { return STRING_RESULT; }
47
  uint32_t decimals() const { return NOT_FIXED_DEC; }
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
48
49
  using Field::store;
483.1.5 by Lee
clean up code for Field_str
50
  int  store(double nr);
51
  int  store(int64_t nr, bool unsigned_val)=0;
2030.1.4 by Brian Aker
Change my_decimal to Decimal
52
  int  store_decimal(const type::Decimal *);
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
53
  int  store(const char *to,uint32_t length, const charset_info_st * const cs)=0;
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
54
483.1.5 by Lee
clean up code for Field_str
55
  uint32_t size_of() const { return sizeof(*this); }
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
56
  const charset_info_st *charset(void) const { return field_charset; }
57
  void set_charset(const charset_info_st * const charset_arg)
584.5.1 by Monty Taylor
Removed field includes from field.h.
58
  { field_charset= charset_arg; }
483.1.5 by Lee
clean up code for Field_str
59
  enum Derivation derivation(void) const { return field_derivation; }
60
  virtual void set_derivation(enum Derivation derivation_arg)
61
  { field_derivation= derivation_arg; }
62
  bool binary() const { return field_charset == &my_charset_bin; }
63
  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.
64
  friend class CreateField;
2181.2.1 by Brian Aker
Protect all of the val_* methods from modification.
65
  type::Decimal *val_decimal(type::Decimal *) const;
483.1.5 by Lee
clean up code for Field_str
66
  virtual bool str_needs_quotes() { return true; }
1034.1.3 by Brian Aker
Collapse field classes (this does change enum/time decimal conversion
67
  uint32_t max_data_length() const;
483.1.5 by Lee
clean up code for Field_str
68
};
69
584.5.1 by Monty Taylor
Removed field includes from field.h.
70
/*
71
  Report "not well formed" or "cannot convert" error
72
  after storing a character string info a field.
73
74
  SYNOPSIS
75
    check_string_copy_error()
76
    field                    - Field
77
    well_formed_error_pos    - where not well formed data was first met
78
    cannot_convert_error_pos - where a not-convertable character was first met
79
    end                      - end of the string
80
    cs                       - character set of the string
81
82
  NOTES
83
    As of version 5.0 both cases return the same error:
84
85
      "Invalid string value: 'xxx' for column 't' at row 1"
86
87
  Future versions will possibly introduce a new error message:
88
89
      "Cannot convert character string: 'xxx' for column 't' at row 1"
90
91
  RETURN
92
    false - If errors didn't happen
93
    true  - If an error happened
94
*/
95
96
bool check_string_copy_error(Field_str *field,
97
                             const char *well_formed_error_pos,
98
                             const char *cannot_convert_error_pos,
99
                             const char *end,
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
100
                             const charset_info_st * const cs);
584.5.1 by Monty Taylor
Removed field includes from field.h.
101
102
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
103
} /* namespace drizzled */
104