P99
p99_str.h
Go to the documentation of this file.
1 /* This may look like nonsense, but it really is -*- mode: C -*- */
2 /* */
3 /* Except for parts copied from previous work and as explicitly stated below, */
4 /* the authors and copyright holders for this work are as follows: */
5 /* (C) copyright 2010-2012 Jens Gustedt, INRIA, France */
6 /* (C) copyright 2012 William Morris */
7 /* */
8 /* This file is free software; it is part of the P99 project. */
9 /* You can redistribute it and/or modify it under the terms of the QPL as */
10 /* given in the file LICENSE. It is distributed without any warranty; */
11 /* without even the implied warranty of merchantability or fitness for a */
12 /* particular purpose. */
13 /* */
14 /*
15 ** p99_str.h
16 **
17 ** Made by Jens Gustedt
18 ** Login <gustedt@damogran.loria.fr>
19 **
20 ** Started on Thu Oct 7 14:57:47 2010 Jens Gustedt
21 ** Last update Thu Oct 7 14:57:47 2010 Jens Gustedt
22 */
23 
24 #ifndef P99_STR_H_
25 # define P99_STR_H_
26 
34 #include "p99_classification.h"
35 
36 #define P00_DEFINE_STR3(CODE) \
37 p99_inline \
38 P99_BUILTIN_TYPE(CODE) P99_PASTE2(str2, CODE)(char const* p00_nptr, size_t* p00_pos, unsigned p00_base) { \
39  char *p00_eptr; \
40  P99_BUILTIN_TYPE(CODE) p00_ret = (strto ## CODE)(p00_nptr, (p00_pos ? &p00_eptr : 0), p00_base); \
41  if (p00_pos) *p00_pos = p00_eptr - p00_nptr; \
42  return p00_ret; \
43 } \
44 P99_MACRO_END(P00_DEFINE_STR3, CODE)
45 
46 #define P00_STR3_0(X) P00_DEFINE_STR3(X)
47 #define P00_STR3_1(...) P99_SEP(P00_STR3_0, __VA_ARGS__)
48 
49 #ifndef P00_DOXYGEN
50 P00_STR3_1(l, ll, ul, ull, uz, t, j, uj);
51 #endif
52 
53 P00_C99_DEFARG_DOCU(str2l, long, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
57 #define str2l(...) P99_CALL_DEFARG(str2l, 3, __VA_ARGS__)
58 #define str2l_defarg_1() 0
59 #define str2l_defarg_2() 0
60 
61 P00_C99_DEFARG_DOCU(str2ll, long long, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
65 #define str2ll(...) P99_CALL_DEFARG(str2ll, 3, __VA_ARGS__)
66 #define str2ll_defarg_1() 0
67 #define str2ll_defarg_2() 0
68 
69 P00_C99_DEFARG_DOCU(str2ul, unsigned long, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
73 #define str2ul(...) P99_CALL_DEFARG(str2ul, 3, __VA_ARGS__)
74 #define str2ul_defarg_1() 0
75 #define str2ul_defarg_2() 0
76 
77 P00_C99_DEFARG_DOCU(str2ull, unsigned long long, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
81 #define str2ull(...) P99_CALL_DEFARG(str2ull, 3, __VA_ARGS__)
82 #define str2ull_defarg_1() 0
83 #define str2ull_defarg_2() 0
84 
85 P00_C99_DEFARG_DOCU(str2uz, size_t, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
89 #define str2uz(...) P99_CALL_DEFARG(str2uz, 3, __VA_ARGS__)
90 #define str2uz_defarg_1() 0
91 #define str2uz_defarg_2() 0
92 
93 P00_C99_DEFARG_DOCU(str2t, ptrdiff_t, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
97 #define str2t(...) P99_CALL_DEFARG(str2t, 3, __VA_ARGS__)
98 #define str2t_defarg_1() 0
99 #define str2t_defarg_2() 0
100 
101 P00_C99_DEFARG_DOCU(str2j, intmax_t, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
105 #define str2j(...) P99_CALL_DEFARG(str2j, 3, __VA_ARGS__)
106 #define str2j_defarg_1() 0
107 #define str2j_defarg_2() 0
108 
109 P00_C99_DEFARG_DOCU(str2uj, uintmax_t, char const *p00_nptr, size_t *p00_pos, unsigned p00_base)
113 #define str2uj(...) P99_CALL_DEFARG(str2uj, 3, __VA_ARGS__)
114 #define str2uj_defarg_1() 0
115 #define str2uj_defarg_2() 0
116 
117 #define P00_DEFINE_STR2(CODE) \
118 p99_inline \
119 P99_BUILTIN_TYPE(CODE) P99_PASTE2(str2, CODE)(char const* p00_nptr, size_t* p00_pos) { \
120  char *p00_eptr; \
121  P99_BUILTIN_TYPE(CODE) p00_ret = (strto ## CODE)(p00_nptr, (p00_pos ? &p00_eptr : 0)); \
122  if (p00_pos) *p00_pos = p00_eptr - p00_nptr; \
123  return p00_ret; \
124 } \
125 P99_MACRO_END(P00_DEFINE_STR2, CODE)
126 
127 #define P00_STR2_0(X) P00_DEFINE_STR2(X)
128 #define P00_STR2_1(...) P99_SEP(P00_STR2_0, __VA_ARGS__)
129 
130 P00_STR2_1(f, d, ld);
131 
132 P00_C99_DEFARG_DOCU(str2f, float, char const *p00_nptr, size_t *p00_pos)
135 #define str2f(...) P99_CALL_DEFARG(str2f, 2, __VA_ARGS__)
136 #define str2f_defarg_1() 0
137 
138 P00_C99_DEFARG_DOCU(str2d, double, char const *p00_nptr, size_t *p00_pos)
141 #define str2d(...) P99_CALL_DEFARG(str2d, 2, __VA_ARGS__)
142 #define str2d_defarg_1() 0
143 
144 P00_C99_DEFARG_DOCU(str2ld, long double, char const *p00_nptr, size_t *p00_pos)
147 #define str2ld(...) P99_CALL_DEFARG(str2ld, 2, __VA_ARGS__)
148 #define str2ld_defarg_1() 0
149 
150 
151 
152 #endif /* !P99_STR_H_ */
classification of different types of token sequences
d
Definition: p99_str.h:130
#define str2ull(...)
Definition: p99_str.h:81
#define str2j(...)
#define str2ll(...)
Definition: p99_str.h:65
#define str2l(...)
uintmax_t
Definition: p99_str.h:109
ld
Definition: p99_str.h:130
#define str2d(...)
Definition: p99_str.h:141
ptrdiff_t
Definition: p99_str.h:93
f
Definition: p99_str.h:130
#define str2uj(...)
Definition: p99_str.h:113
#define str2f(...)
#define str2ld(...)
#define str2t(...)
Definition: p99_str.h:97
#define str2uz(...)
#define str2ul(...)