~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
1 by brian
clean slate
15
16
/* There may be prolems include all of theese. Try to test in
17
   configure with ones are needed? */
18
19
/*  This is needed for the definitions of strchr... on solaris */
20
212.5.39 by Monty Taylor
Phew. Moved my_base and my_global.
21
1241.9.64 by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal.
22
#ifndef DRIZZLED_INTERNAL_M_STRING_H
23
#define DRIZZLED_INTERNAL_M_STRING_H
236.1.27 by Monty Taylor
Some cleanups/decoupling in mystring.
24
1 by brian
clean slate
25
#if defined(HAVE_STRINGS_H)
26
#include <strings.h>
27
#endif
28
#if defined(HAVE_STRING_H)
29
#include <string.h>
30
#endif
31
236.1.27 by Monty Taylor
Some cleanups/decoupling in mystring.
32
#include <stdlib.h>
33
#include <stddef.h>
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
34
#include <cassert>
236.1.27 by Monty Taylor
Some cleanups/decoupling in mystring.
35
#include <limits.h>
481.1.24 by Monty Taylor
Split a method out into innodb_plugin_extras. Innodb is the only thing that uses it. I imagine we probably want to do something totally different with this...
36
#include <ctype.h>
1 by brian
clean slate
37
38
/*  This is needed for the definitions of memcpy... on solaris */
39
#if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
40
#include <memory.h>
41
#endif
42
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
43
namespace drizzled
44
{
45
namespace internal
46
{
1 by brian
clean slate
47
236.1.27 by Monty Taylor
Some cleanups/decoupling in mystring.
48
extern void bmove_upp(unsigned char *dst,const unsigned char *src,size_t len);
49
50
extern	void bchange(unsigned char *dst,size_t old_len,const unsigned char *src,
1 by brian
clean slate
51
		     size_t new_len,size_t tot_len);
52
extern	char *strfield(char *src,int fields,int chars,int blanks,
53
			   int tabch);
154 by Brian Aker
Removed oddball types in my_global.h
54
extern	char *strfill(char * s,size_t len,char fill);
1 by brian
clean slate
55
extern	char *strkey(char *dst,char *head,char *tail,char *flags);
56
extern	char *strmake(char *dst,const char *src,size_t length);
57
58
extern	char *strsuff(const char *src,const char *suffix);
236.1.27 by Monty Taylor
Some cleanups/decoupling in mystring.
59
extern	char *strxcat(char *dst,const char *src, ...);
60
extern	char *strxmov(char *dst,const char *src, ...);
61
extern	char *strxcpy(char *dst,const char *src, ...);
62
extern	char *strxncat(char *dst,size_t len, const char *src, ...);
63
extern	char *strxncpy(char *dst,size_t len, const char *src, ...);
1 by brian
clean slate
64
65
/* Conversion routines */
66
typedef enum {
67
  MY_GCVT_ARG_FLOAT,
68
  MY_GCVT_ARG_DOUBLE
69
} my_gcvt_arg_type;
70
71
double my_strtod(const char *str, char **end, int *error);
72
double my_atof(const char *nptr);
236.1.27 by Monty Taylor
Some cleanups/decoupling in mystring.
73
size_t my_fcvt(double x, int precision, char *to, bool *error);
1 by brian
clean slate
74
size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
236.1.27 by Monty Taylor
Some cleanups/decoupling in mystring.
75
               bool *error);
1 by brian
clean slate
76
937.2.6 by Stewart Smith
make set_if_bigger typesafe for C and C++. Fix up everywhere.
77
#define NOT_FIXED_DEC (uint8_t)31
1 by brian
clean slate
78
79
/*
80
  The longest string my_fcvt can return is 311 + "precision" bytes.
81
  Here we assume that we never cal my_fcvt() with precision >= NOT_FIXED_DEC
82
  (+ 1 byte for the terminating '\0').
83
*/
84
#define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
85
86
/*
87
  We want to use the 'e' format in some cases even if we have enough space
88
  for the 'f' one just to mimic sprintf("%.15g") behavior for large integers,
89
  and to improve it for numbers < 10^(-4).
90
  That is, for |x| < 1 we require |x| >= 10^(-15), and for |x| > 1 we require
91
  it to be integer and be <= 10^DBL_DIG for the 'f' format to be used.
92
  We don't lose precision, but make cases like "1e200" or "0.00001" look nicer.
93
*/
94
#define MAX_DECPT_FOR_F_FORMAT DBL_DIG
95
96
/*
97
  The maximum possible field width for my_gcvt() conversion.
98
  (DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
99
  MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
100
*/
398.1.5 by Monty Taylor
Removed C++ includes and std namespace from global.h.
101
#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + cmax(5, MAX_DECPT_FOR_F_FORMAT))
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
102
1 by brian
clean slate
103
152 by Brian Aker
longlong replacement
104
extern char *llstr(int64_t value,char *buff);
105
extern char *ullstr(int64_t value,char *buff);
1 by brian
clean slate
106
492.1.9 by Monty
Fixed problem on 32-bit.
107
extern char *int2str(int32_t val, char *dst, int radix, int upcase);
108
extern char *int10_to_str(int32_t val,char *dst,int radix);
152 by Brian Aker
longlong replacement
109
int64_t my_strtoll10(const char *nptr, char **endptr, int *error);
110
extern char *int64_t2str(int64_t val,char *dst,int radix);
111
extern char *int64_t10_to_str(int64_t val,char *dst,int radix);
1 by brian
clean slate
112
113
114
/**
115
  Skip trailing space.
116
117
   @param     ptr   pointer to the input string
118
   @param     len   the length of the string
119
   @return          the last non-space character
120
*/
121
481.1.24 by Monty Taylor
Split a method out into innodb_plugin_extras. Innodb is the only thing that uses it. I imagine we probably want to do something totally different with this...
122
static inline const unsigned char *
520.4.30 by Monty Taylor
Moved LEX_STRING into drizzled/lex_string.h.
123
skip_trailing_space(const unsigned char *ptr, size_t len)
1 by brian
clean slate
124
{
236.1.27 by Monty Taylor
Some cleanups/decoupling in mystring.
125
  const unsigned char *end= ptr + len;
1 by brian
clean slate
126
481.1.22 by Monty Taylor
Collapsed over-optimized skip_trailing_spaces.
127
  while (end > ptr && isspace(*--end))
128
    continue;
129
  return end+1;
1 by brian
clean slate
130
}
131
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
132
} /* namespace internal */
133
} /* namespace drizzled */
134
1241.9.64 by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal.
135
#endif /* DRIZZLED_INTERNAL_M_STRING_H */