Drizzled Public API Documentation

m_string.h
00001 /* Copyright (C) 2000 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 /* There may be prolems include all of theese. Try to test in
00017    configure with ones are needed? */
00018 
00019 #pragma once
00020 
00021 #include <strings.h>
00022 #include <cstring>
00023 #include <cstdlib>
00024 #include <cstddef>
00025 #include <cassert>
00026 #include <climits>
00027 #include <cctype>
00028 
00029 #include <drizzled/visibility.h>
00030 
00031 namespace drizzled {
00032 namespace internal {
00033 
00034 extern void bmove_upp(unsigned char *dst,const unsigned char *src,size_t len);
00035 
00036 /* Conversion routines */
00037 enum my_gcvt_arg_type
00038 {
00039   MY_GCVT_ARG_FLOAT,
00040   MY_GCVT_ARG_DOUBLE
00041 };
00042 
00043 DRIZZLED_API double my_strtod(const char *str, char **end, int *error);
00044 DRIZZLED_API double my_atof(const char *nptr);
00045 DRIZZLED_API size_t my_fcvt(double x, int precision, char *to, bool *error);
00046 DRIZZLED_API size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to, bool *error);
00047 
00048 #define NOT_FIXED_DEC (uint8_t)31
00049 
00050 /*
00051   The longest string my_fcvt can return is 311 + "precision" bytes.
00052   Here we assume that we never cal my_fcvt() with precision >= NOT_FIXED_DEC
00053   (+ 1 byte for the terminating '\0').
00054 */
00055 #define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
00056 
00057 /*
00058   We want to use the 'e' format in some cases even if we have enough space
00059   for the 'f' one just to mimic sprintf("%.15g") behavior for large integers,
00060   and to improve it for numbers < 10^(-4).
00061   That is, for |x| < 1 we require |x| >= 10^(-15), and for |x| > 1 we require
00062   it to be integer and be <= 10^DBL_DIG for the 'f' format to be used.
00063   We don't lose precision, but make cases like "1e200" or "0.00001" look nicer.
00064 */
00065 #define MAX_DECPT_FOR_F_FORMAT DBL_DIG
00066 
00067 extern char *llstr(int64_t value,char *buff);
00068 extern char *ullstr(int64_t value,char *buff);
00069 
00070 extern char *int2str(int32_t val, char *dst, int radix, int upcase);
00071 extern char *int10_to_str(int32_t val,char *dst,int radix);
00072 DRIZZLED_API int64_t my_strtoll10(const char *nptr, char **endptr, int *error);
00073 DRIZZLED_API char *int64_t2str(int64_t val,char *dst,int radix);
00074 DRIZZLED_API char *int64_t10_to_str(int64_t val,char *dst,int radix);
00075 
00076 
00085 static inline const unsigned char *
00086 skip_trailing_space(const unsigned char *ptr, size_t len)
00087 {
00088   const unsigned char *end= ptr + len;
00089 
00090   while (end > ptr && isspace(*--end))
00091     continue;
00092   return end+1;
00093 }
00094 
00095 } /* namespace internal */
00096 } /* namespace drizzled */
00097