1 | /* |
---|
2 | * COPYRIGHT (c) 2009. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #ifndef __STRING_TO_A_TYPE_h__ |
---|
13 | #define __STRING_TO_A_TYPE_h__ |
---|
14 | |
---|
15 | /** |
---|
16 | * @brief Convert String to Unsigned Character (with validation) |
---|
17 | * |
---|
18 | * This method converts a string to an unsigned character with |
---|
19 | * range validation. |
---|
20 | * |
---|
21 | * @param[in] s is the string to convert |
---|
22 | * @param[in] n points to the variable to place the converted output in |
---|
23 | * @param[in] endptr is used to keep track of the position in the string |
---|
24 | * @param[in] base is the expected base of the number |
---|
25 | * |
---|
26 | * @return This method returns true on successful conversion and *n is |
---|
27 | * filled in. |
---|
28 | */ |
---|
29 | bool rtems_string_to_unsigned_char( |
---|
30 | const char *s, |
---|
31 | unsigned char *n, |
---|
32 | char **endptr, |
---|
33 | int base |
---|
34 | ); |
---|
35 | |
---|
36 | /** |
---|
37 | * @brief Convert String to Int (with validation) |
---|
38 | * |
---|
39 | * This method converts a string to an int with range validation. |
---|
40 | * |
---|
41 | * @param[in] s is the string to convert |
---|
42 | * @param[in] n points to the variable to place the converted output in |
---|
43 | * @param[in] endptr is used to keep track of the position in the string |
---|
44 | * @param[in] base is the expected base of the number |
---|
45 | * |
---|
46 | * @return This method returns true on successful conversion and *n is |
---|
47 | * filled in. |
---|
48 | */ |
---|
49 | bool rtems_string_to_int( |
---|
50 | const char *s, |
---|
51 | int *n, |
---|
52 | char **endptr, |
---|
53 | int base |
---|
54 | ); |
---|
55 | |
---|
56 | /** |
---|
57 | * @brief Convert String to Long (with validation) |
---|
58 | * |
---|
59 | * This method converts a string to a long with |
---|
60 | * range validation. |
---|
61 | * |
---|
62 | * @param[in] s is the string to convert |
---|
63 | * @param[in] n points to the variable to place the converted output in |
---|
64 | * @param[in] endptr is used to keep track of the position in the string |
---|
65 | * @param[in] base is the expected base of the number |
---|
66 | * |
---|
67 | * @return This method returns true on successful conversion and *n is |
---|
68 | * filled in. |
---|
69 | */ |
---|
70 | bool rtems_string_to_long( |
---|
71 | const char *s, |
---|
72 | long *n, |
---|
73 | char **endptr, |
---|
74 | int base |
---|
75 | ); |
---|
76 | |
---|
77 | /** |
---|
78 | * @brief Convert String to Unsigned Long (with validation) |
---|
79 | * |
---|
80 | * This method converts a string to an unsigned long with |
---|
81 | * range validation. |
---|
82 | * |
---|
83 | * @param[in] s is the string to convert |
---|
84 | * @param[in] n points to the variable to place the converted output in |
---|
85 | * @param[in] endptr is used to keep track of the position in the string |
---|
86 | * @param[in] base is the expected base of the number |
---|
87 | * |
---|
88 | * @return This method returns true on successful conversion and *n is |
---|
89 | * filled in. |
---|
90 | */ |
---|
91 | bool rtems_string_to_unsigned_long( |
---|
92 | const char *s, |
---|
93 | unsigned long *n, |
---|
94 | char **endptr, |
---|
95 | int base |
---|
96 | ); |
---|
97 | |
---|
98 | /** |
---|
99 | * @brief Convert String to Long Long (with validation) |
---|
100 | * |
---|
101 | * This method converts a string to a long long with |
---|
102 | * range validation. |
---|
103 | * |
---|
104 | * @param[in] s is the string to convert |
---|
105 | * @param[in] n points to the variable to place the converted output in |
---|
106 | * @param[in] endptr is used to keep track of the position in the string |
---|
107 | * @param[in] base is the expected base of the number |
---|
108 | * |
---|
109 | * @return This method returns true on successful conversion and *n is |
---|
110 | * filled in. |
---|
111 | */ |
---|
112 | bool rtems_string_to_long_long( |
---|
113 | const char *s, |
---|
114 | long long *n, |
---|
115 | char **endptr, |
---|
116 | int base |
---|
117 | ); |
---|
118 | |
---|
119 | /** |
---|
120 | * @brief Convert String to Unsigned Long Long (with validation) |
---|
121 | * |
---|
122 | * This method converts a string to an unsigned character with |
---|
123 | * range validation. |
---|
124 | * |
---|
125 | * @param[in] s is the string to convert |
---|
126 | * @param[in] n points to the variable to place the converted output in |
---|
127 | * @param[in] endptr is used to keep track of the position in the string |
---|
128 | * @param[in] base is the expected base of the number |
---|
129 | * |
---|
130 | * @return This method returns true on successful conversion and *n is |
---|
131 | * filled in. |
---|
132 | */ |
---|
133 | bool rtems_string_to_unsigned_long_long( |
---|
134 | const char *s, |
---|
135 | unsigned long long *n, |
---|
136 | char **endptr, |
---|
137 | int base |
---|
138 | ); |
---|
139 | |
---|
140 | /** |
---|
141 | * @brief Convert String to Float (with validation) |
---|
142 | * |
---|
143 | * This method converts a string to a float with range validation. |
---|
144 | * |
---|
145 | * @param[in] s is the string to convert |
---|
146 | * @param[in] n points to the variable to place the converted output in |
---|
147 | * @param[in] endptr is used to keep track of the position in the string |
---|
148 | * |
---|
149 | * @return This method returns true on successful conversion and *n is |
---|
150 | * filled in. |
---|
151 | */ |
---|
152 | bool rtems_string_to_float( |
---|
153 | const char *s, |
---|
154 | float *n, |
---|
155 | char **endptr |
---|
156 | ); |
---|
157 | |
---|
158 | /** |
---|
159 | * @brief Convert String to Double (with validation) |
---|
160 | * |
---|
161 | * This method converts a string to a double with range validation. |
---|
162 | * |
---|
163 | * @param[in] s is the string to convert |
---|
164 | * @param[in] n points to the variable to place the converted output in |
---|
165 | * @param[in] endptr is used to keep track of the position in the string |
---|
166 | * |
---|
167 | * @return This method returns true on successful conversion and *n is |
---|
168 | * filled in. |
---|
169 | */ |
---|
170 | bool rtems_string_to_double( |
---|
171 | const char *s, |
---|
172 | double *n, |
---|
173 | char **endptr |
---|
174 | ); |
---|
175 | |
---|
176 | #endif |
---|