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 
00020 
00021 #pragma once
00022 
00023 #if defined(HAVE_STRINGS_H)
00024 #include <strings.h>
00025 #endif
00026 #if defined(HAVE_STRING_H)
00027 #include <string.h>
00028 #endif
00029 
00030 #include <stdlib.h>
00031 #include <stddef.h>
00032 #include <cassert>
00033 #include <limits.h>
00034 #include <ctype.h>
00035 
00036 /*  This is needed for the definitions of memcpy... on solaris */
00037 #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
00038 #include <memory.h>
00039 #endif
00040 
00041 
00042 #include <drizzled/visibility.h>
00043 
00044 namespace drizzled
00045 {
00046 namespace internal
00047 {
00048 
00049 extern void bmove_upp(unsigned char *dst,const unsigned char *src,size_t len);
00050 
00051 extern  void bchange(unsigned char *dst,size_t old_len,const unsigned char *src,
00052          size_t new_len,size_t tot_len);
00053 extern  char *strfield(char *src,int fields,int chars,int blanks,
00054          int tabch);
00055 extern  char *strfill(char * s,size_t len,char fill);
00056 extern  char *strkey(char *dst,char *head,char *tail,char *flags);
00057 extern  char *strmake(char *dst,const char *src,size_t length);
00058 
00059 extern  char *strsuff(const char *src,const char *suffix);
00060 extern  char *strxcat(char *dst,const char *src, ...);
00061 extern  char *strxmov(char *dst,const char *src, ...);
00062 extern  char *strxcpy(char *dst,const char *src, ...);
00063 extern  char *strxncat(char *dst,size_t len, const char *src, ...);
00064 extern  char *strxncpy(char *dst,size_t len, const char *src, ...);
00065 
00066 /* Conversion routines */
00067 typedef enum {
00068   MY_GCVT_ARG_FLOAT,
00069   MY_GCVT_ARG_DOUBLE
00070 } my_gcvt_arg_type;
00071 
00072 DRIZZLED_API double my_strtod(const char *str, char **end, int *error);
00073 DRIZZLED_API double my_atof(const char *nptr);
00074 DRIZZLED_API size_t my_fcvt(double x, int precision, char *to, bool *error);
00075 DRIZZLED_API size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
00076                             bool *error);
00077 
00078 #define NOT_FIXED_DEC (uint8_t)31
00079 
00080 /*
00081   The longest string my_fcvt can return is 311 + "precision" bytes.
00082   Here we assume that we never cal my_fcvt() with precision >= NOT_FIXED_DEC
00083   (+ 1 byte for the terminating '\0').
00084 */
00085 #define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
00086 
00087 /*
00088   We want to use the 'e' format in some cases even if we have enough space
00089   for the 'f' one just to mimic sprintf("%.15g") behavior for large integers,
00090   and to improve it for numbers < 10^(-4).
00091   That is, for |x| < 1 we require |x| >= 10^(-15), and for |x| > 1 we require
00092   it to be integer and be <= 10^DBL_DIG for the 'f' format to be used.
00093   We don't lose precision, but make cases like "1e200" or "0.00001" look nicer.
00094 */
00095 #define MAX_DECPT_FOR_F_FORMAT DBL_DIG
00096 
00097 /*
00098   The maximum possible field width for my_gcvt() conversion.
00099   (DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
00100   MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
00101 */
00102 #define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + cmax(5, MAX_DECPT_FOR_F_FORMAT))
00103 
00104 
00105 extern char *llstr(int64_t value,char *buff);
00106 extern char *ullstr(int64_t value,char *buff);
00107 
00108 extern char *int2str(int32_t val, char *dst, int radix, int upcase);
00109 extern char *int10_to_str(int32_t val,char *dst,int radix);
00110 DRIZZLED_API int64_t my_strtoll10(const char *nptr, char **endptr, int *error);
00111 DRIZZLED_API char *int64_t2str(int64_t val,char *dst,int radix);
00112 DRIZZLED_API char *int64_t10_to_str(int64_t val,char *dst,int radix);
00113 
00114 
00123 static inline const unsigned char *
00124 skip_trailing_space(const unsigned char *ptr, size_t len)
00125 {
00126   const unsigned char *end= ptr + len;
00127 
00128   while (end > ptr && isspace(*--end))
00129     continue;
00130   return end+1;
00131 }
00132 
00133 } /* namespace internal */
00134 } /* namespace drizzled */
00135