P99
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
p99_str.h
Go to the documentation of this file.
00001 /* This may look like nonsense, but it really is -*- mode: C -*-              */
00002 /*                                                                            */
00003 /* Except for parts copied from previous work and as explicitly stated below, */
00004 /* the authors and copyright holders for this work are as follows:            */
00005 /* (C) copyright  2010-2012 Jens Gustedt, INRIA, France                       */
00006 /* (C) copyright  2012 William Morris                                         */
00007 /*                                                                            */
00008 /* This file is free software; it is part of the P99 project.                 */
00009 /* You can redistribute it and/or modify it under the terms of the QPL as     */
00010 /* given in the file LICENSE. It is distributed without any warranty;         */
00011 /* without even the implied warranty of merchantability or fitness for a      */
00012 /* particular purpose.                                                        */
00013 /*                                                                            */
00014 /*
00015 ** p99_str.h
00016 **
00017 ** Made by Jens Gustedt
00018 ** Login   <gustedt@damogran.loria.fr>
00019 **
00020 ** Started on  Thu Oct  7 14:57:47 2010 Jens Gustedt
00021 ** Last update Thu Oct  7 14:57:47 2010 Jens Gustedt
00022 */
00023 
00024 #ifndef     P99_STR_H_
00025 # define    P99_STR_H_
00026 
00034 #include "p99_classification.h"
00035 
00036 #define P00_DEFINE_STR3(CODE)                                                                             \
00037 p99_inline                                                                                                \
00038 P99_BUILTIN_TYPE(CODE) P99_PASTE2(str2, CODE)(char const* p00_nptr, size_t* p00_pos, unsigned p00_base) { \
00039   char *p00_eptr;                                                                                         \
00040   P99_BUILTIN_TYPE(CODE) p00_ret = (strto ## CODE)(p00_nptr, (p00_pos ? &p00_eptr : 0), p00_base);        \
00041   if (p00_pos) *p00_pos = p00_eptr - p00_nptr;                                                            \
00042   return p00_ret;                                                                                         \
00043 }                                                                                                         \
00044 P99_MACRO_END(P00_DEFINE_STR3, CODE)
00045 
00046 #define P00_STR3_0(X) P00_DEFINE_STR3(X)
00047 #define P00_STR3_1(...) P99_SEP(P00_STR3_0, __VA_ARGS__)
00048 
00049 #ifndef P00_DOXYGEN
00050 P00_STR3_1(l, ll, ul, ull, uz, t, j, uj);
00051 #endif
00052 
00053 P00_C99_DEFARG_DOCU(str2l, long, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
00057 #define str2l(...) P99_CALL_DEFARG(str2l, 3, __VA_ARGS__)
00058 #define str2l_defarg_1() 0
00059 #define str2l_defarg_2() 0
00060 
00061 P00_C99_DEFARG_DOCU(str2ll, long long, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
00065 #define str2ll(...) P99_CALL_DEFARG(str2ll, 3, __VA_ARGS__)
00066 #define str2ll_defarg_1() 0
00067 #define str2ll_defarg_2() 0
00068 
00069 P00_C99_DEFARG_DOCU(str2ul, unsigned long, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
00073 #define str2ul(...) P99_CALL_DEFARG(str2ul, 3, __VA_ARGS__)
00074 #define str2ul_defarg_1() 0
00075 #define str2ul_defarg_2() 0
00076 
00077 P00_C99_DEFARG_DOCU(str2ull, unsigned long long, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
00081 #define str2ull(...) P99_CALL_DEFARG(str2ull, 3, __VA_ARGS__)
00082 #define str2ull_defarg_1() 0
00083 #define str2ull_defarg_2() 0
00084 
00085 P00_C99_DEFARG_DOCU(str2uz, size_t, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
00089 #define str2uz(...) P99_CALL_DEFARG(str2uz, 3, __VA_ARGS__)
00090 #define str2uz_defarg_1() 0
00091 #define str2uz_defarg_2() 0
00092 
00093 P00_C99_DEFARG_DOCU(str2t, ptrdiff_t, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
00097 #define str2t(...) P99_CALL_DEFARG(str2t, 3, __VA_ARGS__)
00098 #define str2t_defarg_1() 0
00099 #define str2t_defarg_2() 0
00100 
00101 P00_C99_DEFARG_DOCU(str2j, intmax_t, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
00105 #define str2j(...) P99_CALL_DEFARG(str2j, 3, __VA_ARGS__)
00106 #define str2j_defarg_1() 0
00107 #define str2j_defarg_2() 0
00108 
00109 P00_C99_DEFARG_DOCU(str2uj, uintmax_t, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
00113 #define str2uj(...) P99_CALL_DEFARG(str2uj, 3, __VA_ARGS__)
00114 #define str2uj_defarg_1() 0
00115 #define str2uj_defarg_2() 0
00116 
00117 #define P00_DEFINE_STR2(CODE)                                                            \
00118 p99_inline                                                                               \
00119 P99_BUILTIN_TYPE(CODE) P99_PASTE2(str2, CODE)(char const* p00_nptr, size_t* p00_pos) {   \
00120   char *p00_eptr;                                                                        \
00121   P99_BUILTIN_TYPE(CODE) p00_ret = (strto ## CODE)(p00_nptr, (p00_pos ? &p00_eptr : 0)); \
00122   if (p00_pos) *p00_pos = p00_eptr - p00_nptr;                                           \
00123   return p00_ret;                                                                        \
00124 }                                                                                        \
00125 P99_MACRO_END(P00_DEFINE_STR2, CODE)
00126 
00127 #define P00_STR2_0(X) P00_DEFINE_STR2(X)
00128 #define P00_STR2_1(...) P99_SEP(P00_STR2_0, __VA_ARGS__)
00129 
00130 P00_STR2_1(f, d, ld);
00131 
00132 P00_C99_DEFARG_DOCU(str2f, float, char const *p00_nptr, size_t *p00_pos)
00135 #define str2f(...) P99_CALL_DEFARG(str2f, 2, __VA_ARGS__)
00136 #define str2f_defarg_1() 0
00137 
00138 P00_C99_DEFARG_DOCU(str2d, double, char const *p00_nptr, size_t *p00_pos)
00141 #define str2d(...) P99_CALL_DEFARG(str2d, 2, __VA_ARGS__)
00142 #define str2d_defarg_1() 0
00143 
00144 P00_C99_DEFARG_DOCU(str2ld, long double, char const *p00_nptr, size_t *p00_pos)
00147 #define str2ld(...) P99_CALL_DEFARG(str2ld, 2, __VA_ARGS__)
00148 #define str2ld_defarg_1() 0
00149 
00150 
00151 
00152 #endif      /* !P99_STR_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines