Accelerator Independent Data Access / PVAccess 2.0
AIDA-PVA is the latest version of the AIDA framework. Built on top of EPICS 7 it enables client applications to programmatically access and manage any device or database on the SLAC Network using simple channel names.
Loading...
Searching...
No Matches
aida_pva_types_helper.h File Reference

The Header File for the Native Channel Provider AIDA-PVA type related functions. More...

#include "aida_pva.h"

Go to the source code of this file.

Macros

#define ARRAY_TARGET(_cType)   &((_cType *)(*arrayPtr))[i]
 Used internally to formulate a correctly cast pointer to the array being constructed. More...
 
#define ASCANF_SET_ARRAY(_format, _cType, _jsonType, _typeName)
 Macro used internally to set an array for ascanf() and avscanf(). More...
 
#define ASCANF_SET_BOOLEAN(_targetBoolean)
 Macro used internally to set a scalar boolean for ascanf() and avscanf(). More...
 
#define ASCANF_SET_BOOLEAN_ARRAY   ASCANF_SET_BOOLEAN_OR_BYTE_ARRAY(unsigned char, ASCANF_SET_BOOLEAN)
 Macro used to internally for setting a boolean array for ascanf() and avscanf(). More...
 
#define ASCANF_SET_BOOLEAN_OR_BYTE_ARRAY(_cType, _setMacro)
 Macro used internally for setting a boolean array or a byte array for ascanf() and avscanf(). More...
 
#define ASCANF_SET_BYTE(_targetByte)
 Macro used internally to set a scalar byte for ascanf() and avscanf(). More...
 
#define ASCANF_SET_BYTE_ARRAY   ASCANF_SET_BOOLEAN_OR_BYTE_ARRAY(unsigned char, ASCANF_SET_BYTE)
 Macro used internally for setting a byte array for ascanf() and avscanf(). More...
 
#define ASCANF_SET_SCALAR(_format, _cType, _jsonType, _typeName, _target)
 Macro used internally to set a scalar value for ascanf() and avscanf(). More...
 
#define ASCANF_SET_STRING(_targetString)
 Macro used internally to set a string for ascanf() and avscanf(). More...
 
#define ASCANF_SET_STRING_ARRAY
 Macro used internally to set a string array for ascanf() and avscanf(). More...
 
#define FORMAT_BOOLEAN   'b'
 boolean format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_BYTE   'c'
 byte format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_FLOAT   'f'
 float format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_INTEGER   'd'
 int format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_OPTIONAL_FLAG   'o'
 optional format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_PREFIX_LONG   'l'
 long format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_PREFIX_SHORT   'h'
 short format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_STRING   's'
 string format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_SUFFIX_ARRAY   'a'
 array format definition character for ascanf() and avscanf(). More...
 
#define FORMAT_UNSIGNED_INTEGER   'u'
 unsigned int format definition character for ascanf() and avscanf(). More...
 
#define MAX_FORMAT   8
 Maximum length of s single format specifier for ascanf() and avscanf(). More...
 
#define MAX_FORMAT_SPECIFIERS   20
 Maximum number of permitted format specifiers for ascanf() and avscanf(). More...
 
#define MIN_FLOAT_ALLOCATIONS   100
 Minimum number of floating point allocations. More...
 

Detailed Description

The Header File for the Native Channel Provider AIDA-PVA type related functions.

CMS=C_INC

Definition in file aida_pva_types_helper.h.

Macro Definition Documentation

◆ ARRAY_TARGET

#define ARRAY_TARGET (   _cType)    &((_cType *)(*arrayPtr))[i]

Used internally to formulate a correctly cast pointer to the array being constructed.

Definition at line 74 of file aida_pva_types_helper.h.

◆ ASCANF_SET_ARRAY

#define ASCANF_SET_ARRAY (   _format,
  _cType,
  _jsonType,
  _typeName 
)
Value:
{ \
ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, *arrayPtr, arrayCount * sizeof(_cType), "array arguments", EXIT_FAILURE) \
for (int i = 0; i < arrayCount; i++) { \
jsonRoot = arrayRoot->u.array.values[i]; \
ASCANF_SET_SCALAR(_format, _cType, _jsonType, _typeName, ARRAY_TARGET(_cType)) \
} \
}
#define ARRAY_TARGET(_cType)
Used internally to formulate a correctly cast pointer to the array being constructed.

Macro used internally to set an array for ascanf() and avscanf().

Definition at line 187 of file aida_pva_types_helper.h.

◆ ASCANF_SET_BOOLEAN

#define ASCANF_SET_BOOLEAN (   _targetBoolean)

Macro used internally to set a scalar boolean for ascanf() and avscanf().

Definition at line 103 of file aida_pva_types_helper.h.

◆ ASCANF_SET_BOOLEAN_ARRAY

#define ASCANF_SET_BOOLEAN_ARRAY   ASCANF_SET_BOOLEAN_OR_BYTE_ARRAY(unsigned char, ASCANF_SET_BOOLEAN)

Macro used to internally for setting a boolean array for ascanf() and avscanf().

Definition at line 211 of file aida_pva_types_helper.h.

◆ ASCANF_SET_BOOLEAN_OR_BYTE_ARRAY

#define ASCANF_SET_BOOLEAN_OR_BYTE_ARRAY (   _cType,
  _setMacro 
)
Value:
{ \
ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, *arrayPtr, arrayCount * sizeof(_cType), "array arguments", EXIT_FAILURE) \
for (int i = 0; i < arrayCount; i++) { \
jsonRoot = arrayRoot->u.array.values[i]; \
_setMacro(ARRAY_TARGET(_cType)) \
} \
}

Macro used internally for setting a boolean array or a byte array for ascanf() and avscanf().

Definition at line 199 of file aida_pva_types_helper.h.

◆ ASCANF_SET_BYTE

#define ASCANF_SET_BYTE (   _targetByte)
Value:
{ \
unsigned char* ptr = (unsigned char*)(_targetByte); \
if (!valueShouldBeJson) { \
*ptr = *stringValue; \
} else { \
if (jsonRoot->type == json_integer) { \
*ptr = (int)(jsonRoot->u.integer & 0XFF) ; \
} else if (jsonRoot->type == json_string && jsonRoot->u.string.length == 1) { \
*ptr = *jsonRoot->u.string.ptr; \
} else { \
PRINT_ERROR_FREE_MEMORY_AND_RETURN_(AIDA_INTERNAL_EXCEPTION, "can't convert argument to byte: <json>", EXIT_FAILURE) \
} \
} \
}
#define AIDA_INTERNAL_EXCEPTION
Use this string to signal Internal Exceptions in aidaThrow()

Macro used internally to set a scalar byte for ascanf() and avscanf().

Definition at line 142 of file aida_pva_types_helper.h.

◆ ASCANF_SET_BYTE_ARRAY

#define ASCANF_SET_BYTE_ARRAY   ASCANF_SET_BOOLEAN_OR_BYTE_ARRAY(unsigned char, ASCANF_SET_BYTE)

Macro used internally for setting a byte array for ascanf() and avscanf().

Definition at line 216 of file aida_pva_types_helper.h.

◆ ASCANF_SET_SCALAR

#define ASCANF_SET_SCALAR (   _format,
  _cType,
  _jsonType,
  _typeName,
  _target 
)
Value:
{ \
_cType* ptr = (_cType*)(_target); \
if (!valueShouldBeJson) { \
if ( sscanf(stringValue, _format, ptr) == 0 ) { \
SPRINTF_ERROR_FREE_MEMORY_AND_RETURN_(AIDA_INTERNAL_EXCEPTION, "can't convert argument \"%s\" to " _typeName, stringValue, EXIT_FAILURE) \
}\
} else { \
if (jsonRoot->type == json_integer) { \
*ptr = (_cType)jsonRoot->u.integer; \
} else if (jsonRoot->type == json_double) { \
*ptr = (_cType)(jsonRoot->u.dbl); \
} else if (jsonRoot->type == json_string) { \
if ( sscanf(jsonRoot->u.string.ptr, _format, ptr) == 0 ) { \
SPRINTF_ERROR_FREE_MEMORY_AND_RETURN_(AIDA_INTERNAL_EXCEPTION, "can't convert argument \"%s\" to " _typeName, jsonRoot->u.string.ptr, EXIT_FAILURE) \
} \
} else if (isRequired) { \
PRINT_ERROR_FREE_MEMORY_AND_RETURN_(AIDA_INTERNAL_EXCEPTION, "can't convert argument to " _typeName ": <json>", EXIT_FAILURE) \
}\
}\
}

Macro used internally to set a scalar value for ascanf() and avscanf().

Definition at line 78 of file aida_pva_types_helper.h.

◆ ASCANF_SET_STRING

#define ASCANF_SET_STRING (   _targetString)
Value:
{ \
char** ptr = (char**)(_targetString); \
if (!valueShouldBeJson) { \
*ptr = stringValue; \
} else { \
if (aidaType == AIDA_STRING_TYPE) { \
ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, nextStringPosition, jsonRoot->u.string.length+1, "string arguments", EXIT_FAILURE) \
}\
if (jsonRoot->type == json_string) { \
strcpy(nextStringPosition, jsonRoot->u.string.ptr); \
} else if (jsonRoot->type == json_integer) { \
sprintf(nextStringPosition, "%ld", jsonRoot->u.integer); \
} else if (jsonRoot->type == json_double) { \
sprintf(nextStringPosition, "%g", jsonRoot->u.dbl); \
} else { \
PRINT_ERROR_FREE_MEMORY_AND_RETURN_(AIDA_INTERNAL_EXCEPTION, "can't convert argument to string: <json>", EXIT_FAILURE) \
} \
*ptr = nextStringPosition; \
nextStringPosition+=strlen(nextStringPosition)+1; \
} \
}
@ AIDA_STRING_TYPE
Represents a string.

Macro used internally to set a string for ascanf() and avscanf().

Definition at line 161 of file aida_pva_types_helper.h.

◆ ASCANF_SET_STRING_ARRAY

#define ASCANF_SET_STRING_ARRAY
Value:
{ \
size_t pointerSpace = arrayCount * sizeof(char*); \
ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, *arrayPtr, pointerSpace + totalStingLengthOf(arrayRoot) + arrayCount + 1, "string array arguments", EXIT_FAILURE) \
nextStringPosition = ((char*)*arrayPtr) + pointerSpace; \
for (int i = 0; i < arrayCount; i++) { \
jsonRoot = arrayRoot->u.array.values[i]; \
ASCANF_SET_STRING(ARRAY_TARGET(char *)) \
} \
}

Macro used internally to set a string array for ascanf() and avscanf().

Allocates a string array by allocating a single block of memory. First part of block is list of character pointers into the last part of block which holds the strings. To free the memory simply free the pointer to the first char *.

Definition at line 223 of file aida_pva_types_helper.h.

◆ FORMAT_BOOLEAN

#define FORMAT_BOOLEAN   'b'

boolean format definition character for ascanf() and avscanf().

Definition at line 42 of file aida_pva_types_helper.h.

◆ FORMAT_BYTE

#define FORMAT_BYTE   'c'

byte format definition character for ascanf() and avscanf().

Definition at line 38 of file aida_pva_types_helper.h.

◆ FORMAT_FLOAT

#define FORMAT_FLOAT   'f'

float format definition character for ascanf() and avscanf().

Definition at line 30 of file aida_pva_types_helper.h.

◆ FORMAT_INTEGER

#define FORMAT_INTEGER   'd'

int format definition character for ascanf() and avscanf().

Definition at line 22 of file aida_pva_types_helper.h.

◆ FORMAT_OPTIONAL_FLAG

#define FORMAT_OPTIONAL_FLAG   'o'

optional format definition character for ascanf() and avscanf().

Definition at line 47 of file aida_pva_types_helper.h.

◆ FORMAT_PREFIX_LONG

#define FORMAT_PREFIX_LONG   'l'

long format definition character for ascanf() and avscanf().

Definition at line 56 of file aida_pva_types_helper.h.

◆ FORMAT_PREFIX_SHORT

#define FORMAT_PREFIX_SHORT   'h'

short format definition character for ascanf() and avscanf().

Definition at line 52 of file aida_pva_types_helper.h.

◆ FORMAT_STRING

#define FORMAT_STRING   's'

string format definition character for ascanf() and avscanf().

Definition at line 34 of file aida_pva_types_helper.h.

◆ FORMAT_SUFFIX_ARRAY

#define FORMAT_SUFFIX_ARRAY   'a'

array format definition character for ascanf() and avscanf().

Definition at line 61 of file aida_pva_types_helper.h.

◆ FORMAT_UNSIGNED_INTEGER

#define FORMAT_UNSIGNED_INTEGER   'u'

unsigned int format definition character for ascanf() and avscanf().

Definition at line 26 of file aida_pva_types_helper.h.

◆ MAX_FORMAT

#define MAX_FORMAT   8

Maximum length of s single format specifier for ascanf() and avscanf().

Definition at line 70 of file aida_pva_types_helper.h.

◆ MAX_FORMAT_SPECIFIERS

#define MAX_FORMAT_SPECIFIERS   20

Maximum number of permitted format specifiers for ascanf() and avscanf().

Definition at line 66 of file aida_pva_types_helper.h.

◆ MIN_FLOAT_ALLOCATIONS

#define MIN_FLOAT_ALLOCATIONS   100

Minimum number of floating point allocations.

When allocating space for floating point numbers the framework allocates in batches and then reallocates if the batch is full. This is the minimum batch size.

Definition at line 17 of file aida_pva_types_helper.h.