~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/m_string.h

  • Committer: Brian Aker
  • Date: 2008-10-18 15:43:20 UTC
  • mto: (492.3.20 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081018154320-jc9jyij3mdf08abp
Updating tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* There may be prolems include all of theese. Try to test in
17
17
   configure with ones are needed? */
18
18
 
19
 
 
20
 
 
21
 
#ifndef DRIZZLED_INTERNAL_M_STRING_H
22
 
#define DRIZZLED_INTERNAL_M_STRING_H
23
 
 
 
19
/*  This is needed for the definitions of strchr... on solaris */
 
20
 
 
21
 
 
22
#ifndef _m_string_h
 
23
#define _m_string_h
 
24
 
 
25
#include <drizzled/global.h>
 
26
 
 
27
#ifndef __USE_GNU
 
28
#define __USE_GNU                               /* We want to use my_stpcpy */
 
29
#endif
24
30
#if defined(HAVE_STRINGS_H)
25
31
#include <strings.h>
26
32
#endif
30
36
 
31
37
#include <stdlib.h>
32
38
#include <stddef.h>
33
 
#include <cassert>
 
39
#include <stdbool.h>
 
40
#include <assert.h>
34
41
#include <limits.h>
35
42
#include <ctype.h>
36
43
 
39
46
#include <memory.h>
40
47
#endif
41
48
 
42
 
 
43
 
#include <drizzled/visibility.h>
44
 
 
45
 
namespace drizzled
46
 
{
47
 
namespace internal
48
 
{
 
49
#if defined(__cplusplus)
 
50
extern "C" {
 
51
#endif
 
52
 
 
53
/*
 
54
  my_str_malloc() and my_str_free() are assigned to implementations in
 
55
  strings/alloc.c, but can be overridden in the calling program.
 
56
 */
 
57
extern void *(*my_str_malloc)(size_t);
 
58
extern void (*my_str_free)(void *);
 
59
 
 
60
char *my_stpncpy(register char *dst, register const char *src, size_t n);
 
61
char *my_stpcpy(register char *dst, register const char *src);
 
62
 
 
63
#define strmov_overlapp(A,B) my_stpcpy(A,B)
 
64
#define strmake_overlapp(A,B,C) strmake(A,B,C)
49
65
 
50
66
extern void bmove_upp(unsigned char *dst,const unsigned char *src,size_t len);
51
67
 
56
72
extern  char *strfill(char * s,size_t len,char fill);
57
73
extern  char *strkey(char *dst,char *head,char *tail,char *flags);
58
74
extern  char *strmake(char *dst,const char *src,size_t length);
 
75
#ifndef strmake_overlapp
 
76
extern  char *strmake_overlapp(char *dst,const char *src, size_t length);
 
77
#endif
59
78
 
60
79
extern  char *strsuff(const char *src,const char *suffix);
61
80
extern  char *strxcat(char *dst,const char *src, ...);
62
81
extern  char *strxmov(char *dst,const char *src, ...);
63
82
extern  char *strxcpy(char *dst,const char *src, ...);
64
83
extern  char *strxncat(char *dst,size_t len, const char *src, ...);
 
84
extern  char *strxnmov(char *dst,size_t len, const char *src, ...);
65
85
extern  char *strxncpy(char *dst,size_t len, const char *src, ...);
66
86
 
 
87
/* Prototypes of normal stringfunctions (with may ours) */
 
88
 
 
89
#ifdef WANT_STRING_PROTOTYPES
 
90
extern char *strcat(char *, const char *);
 
91
extern char *strchr(const char *, char);
 
92
extern char *strrchr(const char *, char);
 
93
extern char *strcpy(char *, const char *);
 
94
#endif
 
95
 
 
96
#if !defined(__cplusplus)
 
97
#ifndef HAVE_STRPBRK
 
98
extern char *strpbrk(const char *, const char *);
 
99
#endif
 
100
#endif
 
101
extern int is_prefix(const char *, const char *);
 
102
 
67
103
/* Conversion routines */
68
104
typedef enum {
69
105
  MY_GCVT_ARG_FLOAT,
70
106
  MY_GCVT_ARG_DOUBLE
71
107
} my_gcvt_arg_type;
72
108
 
73
 
DRIZZLED_API double my_strtod(const char *str, char **end, int *error);
74
 
DRIZZLED_API double my_atof(const char *nptr);
75
 
DRIZZLED_API size_t my_fcvt(double x, int precision, char *to, bool *error);
76
 
DRIZZLED_API size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
77
 
                            bool *error);
 
109
double my_strtod(const char *str, char **end, int *error);
 
110
double my_atof(const char *nptr);
 
111
size_t my_fcvt(double x, int precision, char *to, bool *error);
 
112
size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
 
113
               bool *error);
78
114
 
79
 
#define NOT_FIXED_DEC (uint8_t)31
 
115
#define NOT_FIXED_DEC 31
80
116
 
81
117
/*
82
118
  The longest string my_fcvt can return is 311 + "precision" bytes.
101
137
  MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
102
138
*/
103
139
#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + cmax(5, MAX_DECPT_FOR_F_FORMAT))
104
 
 
 
140
  
105
141
 
106
142
extern char *llstr(int64_t value,char *buff);
107
143
extern char *ullstr(int64_t value,char *buff);
108
144
 
109
145
extern char *int2str(int32_t val, char *dst, int radix, int upcase);
110
146
extern char *int10_to_str(int32_t val,char *dst,int radix);
111
 
DRIZZLED_API int64_t my_strtoll10(const char *nptr, char **endptr, int *error);
112
 
DRIZZLED_API char *int64_t2str(int64_t val,char *dst,int radix);
113
 
DRIZZLED_API char *int64_t10_to_str(int64_t val,char *dst,int radix);
114
 
 
 
147
extern char *str2int(const char *src,int radix,long lower,long upper,
 
148
                         long *val);
 
149
int64_t my_strtoll10(const char *nptr, char **endptr, int *error);
 
150
extern char *int64_t2str(int64_t val,char *dst,int radix);
 
151
extern char *int64_t10_to_str(int64_t val,char *dst,int radix);
 
152
 
 
153
 
 
154
#if defined(__cplusplus)
 
155
}
 
156
#endif
 
157
 
 
158
/*
 
159
  LEX_STRING -- a pair of a C-string and its length.
 
160
*/
 
161
 
 
162
#ifndef _my_plugin_h
 
163
/* This definition must match the one given in mysql/plugin.h */
 
164
struct st_mysql_lex_string
 
165
{
 
166
  char *str;
 
167
  size_t length;
 
168
};
 
169
#endif
 
170
typedef struct st_mysql_lex_string LEX_STRING;
 
171
 
 
172
#define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1))
 
173
#define USTRING_WITH_LEN(X) ((unsigned char*) X), ((size_t) (sizeof(X) - 1))
 
174
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
115
175
 
116
176
/**
117
177
  Skip trailing space.
122
182
*/
123
183
 
124
184
static inline const unsigned char *
125
 
skip_trailing_space(const unsigned char *ptr, size_t len)
 
185
skip_trailing_space(const unsigned char *ptr,size_t len)
126
186
{
127
187
  const unsigned char *end= ptr + len;
128
188
 
131
191
  return end+1;
132
192
}
133
193
 
134
 
} /* namespace internal */
135
 
} /* namespace drizzled */
136
 
 
137
 
#endif /* DRIZZLED_INTERNAL_M_STRING_H */
 
194
#endif