drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
m_string.h
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
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16/* There may be prolems include all of theese. Try to test in
17 configure with ones are needed? */
18
19#pragma once
20
21#include <strings.h>
22#include <cstring>
23#include <cstdlib>
24#include <cstddef>
25#include <cassert>
26#include <climits>
27#include <cctype>
28
29#include <drizzled/visibility.h>
30
31namespace drizzled {
32namespace internal {
33
34extern void bmove_upp(unsigned char *dst,const unsigned char *src,size_t len);
35
36/* Conversion routines */
37enum my_gcvt_arg_type
38{
39 MY_GCVT_ARG_FLOAT,
40 MY_GCVT_ARG_DOUBLE
41};
42
43DRIZZLED_API double my_strtod(const char *str, char **end, int *error);
44DRIZZLED_API double my_atof(const char *nptr);
45DRIZZLED_API size_t my_fcvt(double x, int precision, char *to, bool *error);
46DRIZZLED_API size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to, bool *error);
47
48#define NOT_FIXED_DEC (uint8_t)31
49
50/*
51 The longest string my_fcvt can return is 311 + "precision" bytes.
52 Here we assume that we never cal my_fcvt() with precision >= NOT_FIXED_DEC
53 (+ 1 byte for the terminating '\0').
54*/
55#define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
56
57/*
58 We want to use the 'e' format in some cases even if we have enough space
59 for the 'f' one just to mimic sprintf("%.15g") behavior for large integers,
60 and to improve it for numbers < 10^(-4).
61 That is, for |x| < 1 we require |x| >= 10^(-15), and for |x| > 1 we require
62 it to be integer and be <= 10^DBL_DIG for the 'f' format to be used.
63 We don't lose precision, but make cases like "1e200" or "0.00001" look nicer.
64*/
65#define MAX_DECPT_FOR_F_FORMAT DBL_DIG
66
67extern char *llstr(int64_t value,char *buff);
68extern char *ullstr(int64_t value,char *buff);
69
70extern char *int2str(int32_t val, char *dst, int radix, int upcase);
71extern char *int10_to_str(int32_t val,char *dst,int radix);
72DRIZZLED_API int64_t my_strtoll10(const char *nptr, char **endptr, int *error);
73DRIZZLED_API char *int64_t2str(int64_t val,char *dst,int radix);
74DRIZZLED_API char *int64_t10_to_str(int64_t val,char *dst,int radix);
75
76
84
85static inline const unsigned char *
86skip_trailing_space(const unsigned char *ptr, size_t len)
87{
88 const unsigned char *end= ptr + len;
89
90 while (end > ptr && isspace(*--end))
91 continue;
92 return end+1;
93}
94
95} /* namespace internal */
96} /* namespace drizzled */
97
TODO: Rename this file - func.h is stupid.
Visibility Control Macros.
#define DRIZZLED_API
Definition visibility.h:38