EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
epicsStdlib.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 /* epicsStdlib.h */
11 /* Author: Eric Norum */
12 
13 #ifndef INC_epicsStdlib_H
14 #define INC_epicsStdlib_H
15 
30 #include <stdlib.h>
31 #include <limits.h>
32 
33 #include "libComAPI.h"
34 #include "osdStrtod.h"
35 #include "epicsTypes.h"
36 #include "errMdef.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
43 #define S_stdlib_noConversion (M_stdlib | 1) /* No digits to convert */
44 
45 #define S_stdlib_extraneous (M_stdlib | 2) /* Extraneous characters */
46 
47 #define S_stdlib_underflow (M_stdlib | 3) /* Too small to represent */
48 
49 #define S_stdlib_overflow (M_stdlib | 4) /* Too large to represent */
50 
51 #define S_stdlib_badBase (M_stdlib | 5) /* Number base not supported */
52 
62 LIBCOM_API int
63  epicsParseLong(const char *str, long *to, int base, char **units);
64 
69 LIBCOM_API int
70  epicsParseULong(const char *str, unsigned long *to, int base, char **units);
71 
76 LIBCOM_API int
77  epicsParseLLong(const char *str, long long *to, int base, char **units);
78 
83 LIBCOM_API int
84  epicsParseULLong(const char *str, unsigned long long *to, int base, char **units);
85 
94 LIBCOM_API int
95  epicsParseDouble(const char *str, double *to, char **units);
96 
101 LIBCOM_API int
102  epicsParseFloat(const char *str, float *to, char **units);
103 
108 LIBCOM_API int
109  epicsParseInt8(const char *str, epicsInt8 *to, int base, char **units);
110 
115 LIBCOM_API int
116  epicsParseUInt8(const char *str, epicsUInt8 *to, int base, char **units);
117 
122 LIBCOM_API int
123  epicsParseInt16(const char *str, epicsInt16 *to, int base, char **units);
124 
129 LIBCOM_API int
130  epicsParseUInt16(const char *str, epicsUInt16 *to, int base, char **units);
131 
136 LIBCOM_API int
137  epicsParseInt32(const char *str, epicsInt32 *to, int base, char **units);
138 
143 LIBCOM_API int
144  epicsParseUInt32(const char *str, epicsUInt32 *to, int base, char **units);
145 
150 LIBCOM_API int
151  epicsParseInt64(const char *str, epicsInt64 *to, int base, char **units);
152 
157 LIBCOM_API int
158  epicsParseUInt64(const char *str, epicsUInt64 *to, int base, char **units);
159 
161 #define epicsParseFloat32(str, to, units) epicsParseFloat(str, to, units)
162 
163 #define epicsParseFloat64(str, to, units) epicsParseDouble(str, to, units)
164 
165 /* These macros return 1 if successful, 0 on failure.
166  * This is analogous to the return value from sscanf()
167  */
168 
173 #define epicsScanLong(str, to, base) (!epicsParseLong(str, to, base, NULL))
174 
179 #define epicsScanULong(str, to, base) (!epicsParseULong(str, to, base, NULL))
180 
185 #define epicsScanLLong(str, to, base) (!epicsParseLLong(str, to, base, NULL))
186 
191 #define epicsScanULLong(str, to, base) (!epicsParseULLong(str, to, base, NULL))
192 
197 #define epicsScanFloat(str, to) (!epicsParseFloat(str, to, NULL))
198 
203 #define epicsScanDouble(str, to) (!epicsParseDouble(str, to, NULL))
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 
209 #endif /* INC_epicsStdlib_H */
LIBCOM_API int epicsParseInt32(const char *str, epicsInt32 *to, int base, char **units)
Convert a string to an epicsInt32 type.
The core data types used by epics.
LIBCOM_API int epicsParseLLong(const char *str, long long *to, int base, char **units)
Convert a string to a long long type.
LIBCOM_API int epicsParseULLong(const char *str, unsigned long long *to, int base, char **units)
Convert a string to a unsigned long long type.
LIBCOM_API int epicsParseUInt8(const char *str, epicsUInt8 *to, int base, char **units)
Convert a string to an epicsUInt8 type.
LIBCOM_API int epicsParseInt64(const char *str, epicsInt64 *to, int base, char **units)
Convert a string to an epicsInt64 type.
LIBCOM_API int epicsParseUInt32(const char *str, epicsUInt32 *to, int base, char **units)
Convert a string to an epicsUInt32 type.
LIBCOM_API int epicsParseInt8(const char *str, epicsInt8 *to, int base, char **units)
Convert a string to an epicsInt8 type.
LIBCOM_API int epicsParseULong(const char *str, unsigned long *to, int base, char **units)
Convert a string to a unsigned long type.
LIBCOM_API int epicsParseUInt64(const char *str, epicsUInt64 *to, int base, char **units)
Convert a string to an epicsUInt64 type.
LIBCOM_API int epicsParseFloat(const char *str, float *to, char **units)
Convert a string to a float type.
LIBCOM_API int epicsParseInt16(const char *str, epicsInt16 *to, int base, char **units)
Convert a string to an epicsInt16 type.
LIBCOM_API int epicsParseUInt16(const char *str, epicsUInt16 *to, int base, char **units)
Convert a string to an epicsUInt16 type.
LIBCOM_API int epicsParseDouble(const char *str, double *to, char **units)
Convert a string to a double type.
LIBCOM_API int epicsParseLong(const char *str, long *to, int base, char **units)
Convert a string to a long type.