EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
epicsStdlib.h File Reference

Functions to convert strings to primitive types. More...

#include <stdlib.h>
#include <limits.h>
#include "libComAPI.h"
#include "osdStrtod.h"
#include "epicsTypes.h"
#include "errMdef.h"
Include dependency graph for epicsStdlib.h:

Go to the source code of this file.

Macros

#define S_stdlib_noConversion   (M_stdlib | 1) /* No digits to convert */
 
#define S_stdlib_extraneous   (M_stdlib | 2) /* Extraneous characters */
 
#define S_stdlib_underflow   (M_stdlib | 3) /* Too small to represent */
 
#define S_stdlib_overflow   (M_stdlib | 4) /* Too large to represent */
 
#define S_stdlib_badBase   (M_stdlib | 5) /* Number base not supported */
 
#define epicsParseFloat32(str, to, units)   epicsParseFloat(str, to, units)
 
#define epicsParseFloat64(str, to, units)   epicsParseDouble(str, to, units)
 
#define epicsScanLong(str, to, base)   (!epicsParseLong(str, to, base, NULL))
 
#define epicsScanULong(str, to, base)   (!epicsParseULong(str, to, base, NULL))
 
#define epicsScanLLong(str, to, base)   (!epicsParseLLong(str, to, base, NULL))
 
#define epicsScanULLong(str, to, base)   (!epicsParseULLong(str, to, base, NULL))
 
#define epicsScanFloat(str, to)   (!epicsParseFloat(str, to, NULL))
 
#define epicsScanDouble(str, to)   (!epicsParseDouble(str, to, NULL))
 

Functions

LIBCOM_API int epicsParseLong (const char *str, long *to, int base, char **units)
 Convert a string to a long type. More...
 
LIBCOM_API int epicsParseULong (const char *str, unsigned long *to, int base, char **units)
 Convert a string to a unsigned long type. More...
 
LIBCOM_API int epicsParseLLong (const char *str, long long *to, int base, char **units)
 Convert a string to a long long type. More...
 
LIBCOM_API int epicsParseULLong (const char *str, unsigned long long *to, int base, char **units)
 Convert a string to a unsigned long long type. More...
 
LIBCOM_API int epicsParseDouble (const char *str, double *to, char **units)
 Convert a string to a double type. More...
 
LIBCOM_API int epicsParseFloat (const char *str, float *to, char **units)
 Convert a string to a float type. More...
 
LIBCOM_API int epicsParseInt8 (const char *str, epicsInt8 *to, int base, char **units)
 Convert a string to an epicsInt8 type. More...
 
LIBCOM_API int epicsParseUInt8 (const char *str, epicsUInt8 *to, int base, char **units)
 Convert a string to an epicsUInt8 type. More...
 
LIBCOM_API int epicsParseInt16 (const char *str, epicsInt16 *to, int base, char **units)
 Convert a string to an epicsInt16 type. More...
 
LIBCOM_API int epicsParseUInt16 (const char *str, epicsUInt16 *to, int base, char **units)
 Convert a string to an epicsUInt16 type. More...
 
LIBCOM_API int epicsParseInt32 (const char *str, epicsInt32 *to, int base, char **units)
 Convert a string to an epicsInt32 type. More...
 
LIBCOM_API int epicsParseUInt32 (const char *str, epicsUInt32 *to, int base, char **units)
 Convert a string to an epicsUInt32 type. More...
 
LIBCOM_API int epicsParseInt64 (const char *str, epicsInt64 *to, int base, char **units)
 Convert a string to an epicsInt64 type. More...
 
LIBCOM_API int epicsParseUInt64 (const char *str, epicsUInt64 *to, int base, char **units)
 Convert a string to an epicsUInt64 type. More...
 

Detailed Description

These routines convert a string into an integer of the indicated type and number base, or into a floating point type. The units pointer argument may be NULL, but if not it will be left pointing to the first non-whitespace character following the numeric string, or to the terminating zero byte.

The return value from these routines is a status code, zero meaning OK. For the macro functions beginning with epicsScan the return code is 0 or 1 (0=failure or 1=success, similar to the sscanf() function).

Definition in file epicsStdlib.h.

Macro Definition Documentation

#define S_stdlib_noConversion   (M_stdlib | 1) /* No digits to convert */

Return code for No digits to convert

Definition at line 43 of file epicsStdlib.h.

#define S_stdlib_extraneous   (M_stdlib | 2) /* Extraneous characters */

Return code for Extraneous characters

Definition at line 45 of file epicsStdlib.h.

#define S_stdlib_underflow   (M_stdlib | 3) /* Too small to represent */

Return code for Too small to represent

Definition at line 47 of file epicsStdlib.h.

#define S_stdlib_overflow   (M_stdlib | 4) /* Too large to represent */

Return code for Too large to represent

Definition at line 49 of file epicsStdlib.h.

#define S_stdlib_badBase   (M_stdlib | 5) /* Number base not supported */

Return code for Number base not supported

Definition at line 51 of file epicsStdlib.h.

#define epicsParseFloat32 (   str,
  to,
  units 
)    epicsParseFloat(str, to, units)

Macro utilizing epicsParseFloat to convert

Definition at line 161 of file epicsStdlib.h.

#define epicsParseFloat64 (   str,
  to,
  units 
)    epicsParseDouble(str, to, units)

Macro utilizing epicsParseDouble to convert

Definition at line 163 of file epicsStdlib.h.

#define epicsScanLong (   str,
  to,
  base 
)    (!epicsParseLong(str, to, base, NULL))

Macro utilizing epicsParseLong to convert

Returns
0=failure, 1=success

Definition at line 173 of file epicsStdlib.h.

#define epicsScanULong (   str,
  to,
  base 
)    (!epicsParseULong(str, to, base, NULL))

Macro utilizing epicsParseULong to convert

Returns
0=failure, 1=success

Definition at line 179 of file epicsStdlib.h.

#define epicsScanLLong (   str,
  to,
  base 
)    (!epicsParseLLong(str, to, base, NULL))

Macro utilizing epicsParseLLong to convert

Returns
0=failure, 1=success

Definition at line 185 of file epicsStdlib.h.

#define epicsScanULLong (   str,
  to,
  base 
)    (!epicsParseULLong(str, to, base, NULL))

Macro utilizing epicsParseULLong to convert

Returns
0=failure, 1=success

Definition at line 191 of file epicsStdlib.h.

#define epicsScanFloat (   str,
  to 
)    (!epicsParseFloat(str, to, NULL))

Macro utilizing epicsParseFloat to convert

Returns
0=failure, 1=success

Definition at line 197 of file epicsStdlib.h.

#define epicsScanDouble (   str,
  to 
)    (!epicsParseDouble(str, to, NULL))

Macro utilizing epicsParseDouble to convert

Returns
0=failure, 1=success

Definition at line 203 of file epicsStdlib.h.

Function Documentation

LIBCOM_API int epicsParseLong ( const char *  str,
long *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseULong ( const char *  str,
unsigned long *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseLLong ( const char *  str,
long long *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseULLong ( const char *  str,
unsigned long long *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseDouble ( const char *  str,
double *  to,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseFloat ( const char *  str,
float *  to,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseInt8 ( const char *  str,
epicsInt8 *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseUInt8 ( const char *  str,
epicsUInt8 *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseInt16 ( const char *  str,
epicsInt16 *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseUInt16 ( const char *  str,
epicsUInt16 *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseInt32 ( const char *  str,
epicsInt32 *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseUInt32 ( const char *  str,
epicsUInt32 *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseInt64 ( const char *  str,
epicsInt64 *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)
LIBCOM_API int epicsParseUInt64 ( const char *  str,
epicsUInt64 *  to,
int  base,
char **  units 
)
Parameters
strPointer to a constant character array
toPointer to the specified type (this will be set during the conversion)
baseThe number base to use
unitsPointer to a char * (this will be set with the units string)
Returns
Status code (0=OK, see macro definitions for possible errors)