drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
str.h
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#pragma once
22
23#include <drizzled/field.h>
24
25#include <drizzled/visibility.h>
26
27namespace drizzled
28{
29
30/* base class for all string related classes */
31
32class DRIZZLED_API Field_str :
33 public Field
34{
35protected:
36 const charset_info_st *field_charset;
37 enum Derivation field_derivation;
38 int report_if_important_data(const char *ptr, const char *end);
39public:
40 Field_str(unsigned char *ptr_arg,
41 uint32_t len_arg,
42 unsigned char *null_ptr_arg,
43 unsigned char null_bit_arg,
44 const char *field_name_arg,
45 const charset_info_st * const charset);
46 Item_result result_type () const { return STRING_RESULT; }
47 uint32_t decimals() const { return NOT_FIXED_DEC; }
48
49 using Field::store;
50 int store(double nr);
51 int store(int64_t nr, bool unsigned_val)=0;
52 int store_decimal(const type::Decimal *);
53 int store(const char *to,uint32_t length, const charset_info_st * const cs)=0;
54
55 uint32_t size_of() const { return sizeof(*this); }
56 const charset_info_st *charset(void) const { return field_charset; }
57 void set_charset(const charset_info_st * const charset_arg)
58 { field_charset= charset_arg; }
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; }
64 friend class CreateField;
65 type::Decimal *val_decimal(type::Decimal *) const;
66 virtual bool str_needs_quotes() { return true; }
67 uint32_t max_data_length() const;
68};
69
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
96bool 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,
100 const charset_info_st * const cs);
101
102
103} /* namespace drizzled */
104
int store_decimal(const type::Decimal *)
Definition str.cc:102
uint32_t max_data_length() const
Definition str.cc:202
int store(double nr)
Definition str.cc:124
unsigned char * ptr
Definition field.h:73
Field(unsigned char *ptr_arg, uint32_t length_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg, utype unireg_check_arg, const char *field_name_arg)
This is used as a table name when the table structure is not set up.
Definition field.cc:892
uint32_t field_length
Definition field.h:131
TODO: Rename this file - func.h is stupid.
Derivation
Definition enum.h:39
Visibility Control Macros.
#define DRIZZLED_API
Definition visibility.h:38