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.c File Reference

This file contain functions that should be used directly by Native Channel Providers. More...

#include <jni.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <stdbool.h>
#include "slc_macros.h"
#include "sysutil_proto.h"
#include "aida_pva_jni_helper.h"
#include "aida_pva_server_helper.h"
#include "aida_pva_types_helper.h"

Go to the source code of this file.

Functions

int ascanf (JNIEnv *env, Arguments *arguments, const char *formatString,...)
 ascanf(), avscanf() More...
 
int avscanf (JNIEnv *env, Arguments *arguments, Value *value, const char *formatString,...)
 ascanf(), avscanf() More...
 
void tableAddColumn (JNIEnv *env, Table *table, Type type, void *data, bool ieeeFormat)
 Add a column of arbitrary type to a Table. More...
 
void tableAddField (JNIEnv *env, Table *table, char *fieldName)
 Add a dynamic field to a table. More...
 
void tableAddFixedWidthStringColumn (JNIEnv *env, Table *table, char *data, int width)
 This reads data from an allocated space that is rows * width with each string occupying width characters Though the strings are null terminated if there is space, there is no guarantee so an exact number of bytes is copied. More...
 
void tableAddLabel (JNIEnv *env, Table *table, char *labelName)
 Add a dynamic column to a table. More...
 
void tableAddSingleRowBooleanColumn (JNIEnv *env, Table *table, unsigned char data)
 Add a boolean column to a Table with only one row. More...
 
void tableAddSingleRowByteColumn (JNIEnv *env, Table *table, unsigned char data)
 Add a byte column to a Table with only one row. More...
 
void tableAddSingleRowDoubleColumn (JNIEnv *env, Table *table, double data, bool ieeeDouble)
 Add a double column to a Table with only one row. More...
 
void tableAddSingleRowFloatColumn (JNIEnv *env, Table *table, float data, bool ieeeFloat)
 Add a float column to a Table with only one row. More...
 
void tableAddSingleRowIntegerColumn (JNIEnv *env, Table *table, int data)
 Add a integer column to a Table with only one row. More...
 
void tableAddSingleRowLongColumn (JNIEnv *env, Table *table, long data)
 Add a long column to a Table with only one row. More...
 
void tableAddSingleRowShortColumn (JNIEnv *env, Table *table, short data)
 Add a short column to a Table with only one row. More...
 
void tableAddSingleRowStringColumn (JNIEnv *env, Table *table, char *data)
 Add a string column to a Table with only one row. More...
 
void tableAddStringColumn (JNIEnv *env, Table *table, char **data)
 Add a String column to the given Table. More...
 
Table tableCreate (JNIEnv *env, int rows, int columns)
 Make a Table for return to client. More...
 
Table tableCreateDynamic (JNIEnv *env, int rows, int columns)
 Make a Dynamic Table for return to client. More...
 

Detailed Description

This file contain functions that should be used directly by Native Channel Providers.

These functions provide all of the features related to processing of Arguments and Table that allow the Channel Provider to implement its service.

MEMBER=SLCLIBS:AIDA_PVALIB ATTRIBUTES=JNI

Definition in file aida_pva_types_helper.c.

Function Documentation

◆ ascanf()

int ascanf ( JNIEnv *  env,
Arguments arguments,
const char *  formatString,
  ... 
)

ascanf(), avscanf()

Argument Processing.

Synopsis

int ascanf(Arguments *arguments, const char *format, ...);
int avscanf(Arguments *arguments, Value *value, const char *format, ...);
int ascanf(JNIEnv *env, Arguments *arguments, const char *formatString,...)
ascanf(), avscanf()
int avscanf(JNIEnv *env, Arguments *arguments, Value *value, const char *formatString,...)
ascanf(), avscanf()
An Arguments structure stores all of the arguments passed from the request to the Native Channel Prov...
This special type represents a Value.

Details

Reads data from the given arguments and stores them according to parameter format into the locations given by the additional arguments, as if scanf() was used, but reading from arguments instead of the standard input (stdin).

See also
avscanf() for full details.
Parameters
envThe JNI environment. Used in all functions involving JNI
argumentsArguments that the function processes as its source to retrieve the data.
formatStringC string that contains a format string as described above
...Depending on the format string, the function may expect a sequence of additional arguments, containing pairs of names and pointers to allocated storage (except as indicated above), where the interpretation of the extracted data is stored with the appropriate type. There should be at least as many pairs of these arguments as the number of values stored by the format specifiers. Additional arguments are ignored by the function
Returns
EXIT_SUCCESS if all required arguments were read and no errors occurred, otherwise EXIT_FAILURE
Exceptions
MissingRequiredArgumentExceptionif one of the required arguments are missing

Definition at line 86 of file aida_pva_types_helper.c.

87{
88 va_list argp;
89 va_start(argp, formatString);
90 int status = vavscanf(env, arguments, NULL, formatString, argp);
91 va_end (argp);
92 return status;
93}

Referenced by aidaRequestBoolean(), aidaRequestBooleanArray(), aidaRequestByte(), aidaRequestByteArray(), aidaRequestDouble(), aidaRequestDoubleArray(), aidaRequestFloat(), aidaRequestFloatArray(), aidaRequestInteger(), aidaRequestIntegerArray(), aidaRequestLong(), aidaRequestLongArray(), aidaRequestShort(), aidaRequestShortArray(), aidaRequestString(), aidaRequestStringArray(), aidaRequestTable(), and aidaSetValue().

◆ avscanf()

int avscanf ( JNIEnv *  env,
Arguments arguments,
Value value,
const char *  formatString,
  ... 
)

ascanf(), avscanf()

Synopsis

int ascanf(Arguments *arguments, const char *format, ...);
int avscanf(Arguments *arguments, Value *value, const char *format, ...);

Details

Reads data from the given arguments and stores them according to parameter format into the locations given by the additional arguments, as if scanf() was used, but reading from arguments instead of the standard input (stdin).

The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier. For strings and arrays only the pointer needs to be pre-allocated.

The only space allocated by this function is for the strings or arrays. So callers should only free strings and arrays. Even if you provide a default value for a string the pointer will be allocated memory on exit from the function, so even then you need to free it.

Note
Only the provided pointer needs to be freed as only one allocation is made e.g.
Arguments arguments;
int *intArray;
ascanf(arguments "%da, "fooArray", &intArray);
// Do stuff
free(intArray);

String space is allocated as follows:

+------------------------+----------+----------+----------+---------+
| pointers to strings | string 1 | string 2 | string 3 | ... |
+------------------------+----------+----------+----------+---------+

Differences to scanf()


There are a number of differences from scanf() which are best described by example:

General differences

  1. Scan into simple variable/
    int n;
    ascanf("%d", "NPOS", &n);
    You must always provide the name of the variable and the pointer to the place to put the value in pairs
  2. Optional arguments. Optional arguments are specified with the o character before the format character.
    short flag = 10; // 10 is the default value
    ascanf("%ohd", "flag", &flag);

By default all arguments referenced by format specifications are considered required unless the format specification character is preceded by o. For optional arguments the pointer provided must point to the default value. In the case of arrays and strings this will be copied into allocated storage that will need to be freed as normal.

Argument names

  1. You can specify simple argument names to search for. These will simply find the named argument and extract its value.
    int simpleInt;
    ascanf(&arguments "%d, "simple", &simpleInt);
  2. You can also use dot and square brace notation to refer to complex arguments that are either arrays or complex objects. Values that are buried deep inside the json structures can be referenced in this way. e.g., given a variable named json and presented as:
    json='{"foo": {"bar": 0}}}'
    You can specify the name as "json.foo.bar" to retrieve the 0 value.
  3. Also given a variable named jsonArray and presented as
    jsonArray='[{"foo": 10}, {"bar": 20}]'
    You can specify the #p name as "jsonArray[1].bar" to retrieve the 20 value.
  4. Finally if you use the name "value", then the avscanf() function will use the supplied value parameter to get the data for that parameter
    Arguments arguments;
    Value value;
    int *intArray;
    avscanf(&arguments &value, "%da, "fooArray", &intArray);
    // Do stuff
    free(intArray);

Format Specifiers


Type specifiers

  • b : unsigned char * - interpret the input as a boolean, then extract a single byte into the corresponding variable.
    • The following translate to true
      • not 0 - integer, short, long,
      • not 0.0 - float, double
      • “true” - char string
      • “t” - char string
      • “yes” - char string
      • “y” - char string
      • !0 - short, int, long, float, or double
    • The following translate to false
      • 0 - integer, short, long,
      • 0.0 - float, double
      • “false” - char string
      • “f”- char string
      • “no”- char string
      • “n”- char string
      • 0 - short, int, long, float, or double
  • c : char * - extract a single character into the corresponding variable.
  • d : int * - extract an integer into the corresponding variable (see l & h below).
  • f : float * - extract a floating point number (see l below).
  • s : char * - extract a string of characters into allocated space and point the corresponding variable to it.
  • u : unsigned int * - extract an unsigned integer into the corresponding variable (see l & h below).

Required flag

  • o - optional precede the format with this to indicate that the argument is optional.

Prefixes

  • h - short * - preceding d will retrieve a short e.g. "%hd".
  • l - long *, double * - preceding d will retrieve a long eg. "%ld"; preceding f will retrieve a double eg. "%lf".

Suffixes

  • a - extract an array of the preceding type into a block of allocated space and point the corresponding variable to it. The variable will have an extra level of indirection than the non-array version. e.g.,
    int i;
    ascanf(..., "%d", &i);
    becomes
    int *ia, n;
    ascanf(..., "%da", &ia, &n);
    Also, you need to provide an extra parameter for each format containing an a suffix to hold the count of array elements found. The pointer will point to an int.
Parameters
envThe JNI environment. Used in all functions involving JNI
argumentsArguments that the function processes as its source to retrieve the data.
valueFor the avscanf() form this parameter holds the parsed Value given to the Channel Provider endpoint.
formatStringC string that contains a format string as described above
...Depending on the format string, the function may expect a sequence of additional arguments, containing pairs of names and pointers to allocated storage (except as indicated above), where the interpretation of the extracted data is stored with the appropriate type. There should be at least as many pairs of these arguments as the number of references in the format specifiers. Additional arguments are ignored by the function
Returns
EXIT_SUCCESS if all required arguments were read and no errors occurred, otherwise EXIT_FAILURE
Exceptions
MissingRequiredArgumentExceptionif one of the required arguments are missing

Definition at line 250 of file aida_pva_types_helper.c.

251{
252 va_list argp;
253 va_start(argp, formatString);
254 int status = vavscanf(env, arguments, value, formatString, argp);
255 va_end (argp);
256 return status;
257}

Referenced by aidaSetValue(), and aidaSetValueWithResponse().

◆ tableAddColumn()

void tableAddColumn ( JNIEnv *  env,
Table table,
Type  type,
void *  data,
bool  ieeeFormat 
)

Add a column of arbitrary type to a Table.

Add the given data to the column assuming that the data has a number of rows that corresponds to the Table's rowCount. Memory will be allocated for the data of the column so the data buffer presented can be freed up after calling this function.

Note
Don't call this to add strings to the Table. Use tableAddStringColumn() for that.

The framework will release all memory associated with a Table when you return from your API implementation.

Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
typethe type of this Table column.
datathe data to add to this column, a buffer of sizeof(type) * table->rowCount size.
ieeeFormattrue if the data provided is already in ieee format. If the data is not in ieee format, usually because it has been retrieved from some backend system, this function will convert it to ieee format unless this parameter is set to true.
See also
tableCreate(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a two column, two row Table, add data, and return.

int rows = 2, columns = 2;
float xData[rows] = { 1.0f, 2.0f }, yData[rows] = { 7.0f, 8.0f };
Table table = tableCreate(env, rows, columns);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, xData, true);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, yData, true);
return table;
#define ON_EXCEPTION_RETURN_(_r)
Check to see if an exception has been raised, and return the given return value.
@ AIDA_FLOAT_TYPE
Represents a float.
Table tableCreate(JNIEnv *env, int rows, int columns)
Make a Table for return to client.
void tableAddColumn(JNIEnv *env, Table *table, Type type, void *data, bool ieeeFormat)
Add a column of arbitrary type to a Table.
Table structure.
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Definition at line 755 of file aida_pva_types_helper.c.

756{
757 // Table full?
758 if (table->_currentColumn >= table->columnCount) {
760 "Internal Error: more columns added than table size");
761 return;
762 }
763
764 // No Data supplied ?
765 if (!data) {
767 "Internal Error: Attempt to add column with no data");
768 return;
769 }
770
771 // Correct type for tables
772 type = tableArrayTypeOf(type);
773
774 // Set column type, and allocate space
775 allocateTableColumn(env, table, type, tableElementSizeOfOf(type));
777
778 // Rest of processing for strings is done in addStringColumn
779 if (type == AIDA_STRING_ARRAY_TYPE) {
780 return;
781 }
782
783 if (!ieeeFormat) {
784 // Convert float values if float array
785 if (type == AIDA_FLOAT_ARRAY_TYPE) {
786 CONVERT_FROM_VMS_FLOAT(((float*)data), (int2u)table->rowCount)
787 }
788
789 // Convert double values if double array
790 if (type == AIDA_DOUBLE_ARRAY_TYPE) {
791 CONVERT_FROM_VMS_DOUBLE((double*)data, (int2u)table->rowCount)
792 }
793 }
794
795 // Add data to column
796 for (int row = 0; row < table->rowCount; row++) {
797 // add data and increment pointer based on type
798 switch (type) {
801 ((unsigned char*)(table->ppData[table->_currentColumn]))[row] = ((unsigned char*)data)[row];
802 break;
804 ((short*)(table->ppData[table->_currentColumn]))[row] = ((short*)data)[row];
805 break;
807 ((int*)(table->ppData[table->_currentColumn]))[row] = ((int*)data)[row];
808 break;
810 ((long*)(table->ppData[table->_currentColumn]))[row] = ((long*)data)[row];
811 break;
813 ((float*)(table->ppData[table->_currentColumn]))[row] = ((float*)data)[row];
814 break;
816 ((double*)(table->ppData[table->_currentColumn]))[row] = ((double*)data)[row];
817 break;
818 default:
820 "Internal Error: Call to tableAddColumn() un-supported type");
821 return;
822 }
823 }
824
825 table->_currentColumn++;
826}
#define CONVERT_FROM_VMS_FLOAT(_float, _count)
Convert in-place, floating point numbers from VMS to ieee format.
#define CONVERT_FROM_VMS_DOUBLE(_double, _count)
Convert in-place, doubles from VMS to ieee format.
#define ON_EXCEPTION_RETURN_VOID
Check to see if an exception has been raised, and return void,.
#define UNABLE_TO_GET_DATA_EXCEPTION
Use this string to signal Exceptions when trying to Get Data in aidaThrow()
void aidaThrowNonOsException(JNIEnv *env, char *exception, const char *message)
To log any non-OS exceptions and throw back to java.
@ AIDA_SHORT_ARRAY_TYPE
Represents a short array.
@ AIDA_FLOAT_ARRAY_TYPE
Represents a float array.
@ AIDA_BOOLEAN_ARRAY_TYPE
Represents a boolean array.
@ AIDA_INTEGER_ARRAY_TYPE
Represents an integer array.
@ AIDA_BYTE_ARRAY_TYPE
Represents a byte array.
@ AIDA_LONG_ARRAY_TYPE
Represents a long array.
@ AIDA_STRING_ARRAY_TYPE
Represents a string array.
@ AIDA_DOUBLE_ARRAY_TYPE
Represents a double array.
int columnCount
number of columns in table
void ** ppData
the data. an array of [rows][columns]
int rowCount
number of rows in table
int _currentColumn
For internal use by addColumn() etc.

References Table::_currentColumn, AIDA_BOOLEAN_ARRAY_TYPE, AIDA_BYTE_ARRAY_TYPE, AIDA_DOUBLE_ARRAY_TYPE, AIDA_FLOAT_ARRAY_TYPE, AIDA_INTEGER_ARRAY_TYPE, AIDA_LONG_ARRAY_TYPE, AIDA_SHORT_ARRAY_TYPE, AIDA_STRING_ARRAY_TYPE, aidaThrowNonOsException(), Table::columnCount, CONVERT_FROM_VMS_DOUBLE, CONVERT_FROM_VMS_FLOAT, ON_EXCEPTION_RETURN_VOID, Table::ppData, Table::rowCount, and UNABLE_TO_GET_DATA_EXCEPTION.

Referenced by aidaRequestTable(), aidaSetValueWithResponse(), tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowShortColumn(), and tableAddStringColumn().

◆ tableAddField()

void tableAddField ( JNIEnv *  env,
Table table,
char *  fieldName 
)

Add a dynamic field to a table.

See also
tableCreateDynamic
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
fieldNameThe name of the field to add

Definition at line 828 of file aida_pva_types_helper.c.

828 {
829 // Table full?
830 if (table->_currentField >= table->columnCount) {
832 "Internal Error: more fields added than table size");
833 return;
834 }
835
836 // No Data supplied ?
837 if (!fieldName || !*fieldName) {
839 "Internal Error: Attempt to add empty field name");
840 return;
841 }
842
843 ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID(env, table->ppFields[table->_currentField], fieldName, "table field names")
844 table->_currentField++;
845}
#define ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID(_env, _var, _string, _purpose)
Allocate memory for a string and copy the given string into this allocated space The specified variab...
char ** ppFields
the overridden field names. if null, not overridden. If not null then array of pointers to allocated ...
int _currentField
For internal use by addField() etc.

References Table::_currentField, aidaThrowNonOsException(), ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID, Table::columnCount, Table::ppFields, and UNABLE_TO_GET_DATA_EXCEPTION.

◆ tableAddFixedWidthStringColumn()

void tableAddFixedWidthStringColumn ( JNIEnv *  env,
Table table,
char *  data,
int  width 
)

This reads data from an allocated space that is rows * width with each string occupying width characters Though the strings are null terminated if there is space, there is no guarantee so an exact number of bytes is copied.

Add fixed-width string data to a column in the given Table.

Each string in the Table is allocated maximally.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a pointer to char buffer containing the fixed length strings. The strings are arranged in contiguous blocks width long.
widththe width of the strings
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 955 of file aida_pva_types_helper.c.

956{
957 tableAddColumn(env, table, AIDA_STRING_ARRAY_TYPE, data, false);
959
960 // allocate data for each string too
961 char** stringArray = table->ppData[table->_currentColumn];
962 char* dataPointer = (char*)data;
963 for (int row = 0; row < table->rowCount; row++, dataPointer += width) {
964 ALLOCATE_FIXED_LENGTH_STRING_AND_ON_ERROR_RETURN_VOID(env, stringArray[row], dataPointer, width + 1, "table strings")
965 stringArray[row][width] = 0x0;
966 }
967
968 table->_currentColumn++;
969}
#define ALLOCATE_FIXED_LENGTH_STRING_AND_ON_ERROR_RETURN_VOID(_env, _var, _string, _size, _purpose)
Allocate space for a fixed length string and copy date from the given string into the newly allocated...

References Table::_currentColumn, AIDA_STRING_ARRAY_TYPE, ALLOCATE_FIXED_LENGTH_STRING_AND_ON_ERROR_RETURN_VOID, ON_EXCEPTION_RETURN_VOID, Table::ppData, Table::rowCount, and tableAddColumn().

Referenced by aidaRequestTable(), and aidaSetValueWithResponse().

◆ tableAddLabel()

void tableAddLabel ( JNIEnv *  env,
Table table,
char *  labelName 
)

Add a dynamic column to a table.

See also
tableCreateDynamic
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
labelNamethe label name to add

Definition at line 847 of file aida_pva_types_helper.c.

847 {
848 // Table full?
849 if (table->_currentLabel >= table->columnCount) {
851 "Internal Error: more labels added than table size");
852 return;
853 }
854
855 // No Data supplied ?
856 if (!labelName || !*labelName) {
858 "Internal Error: Attempt to add empty label name");
859 return;
860 }
861
862 ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID(env, table->ppLabels[table->_currentLabel], labelName, "table label names")
863 table->_currentLabel++;
864}
char ** ppLabels
the overridden label names. if null, not overridden. If not null then array of pointers to allocated ...
int _currentLabel
For internal use by addLabel() etc.

References Table::_currentLabel, aidaThrowNonOsException(), ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID, Table::columnCount, Table::ppLabels, and UNABLE_TO_GET_DATA_EXCEPTION.

◆ tableAddSingleRowBooleanColumn()

void tableAddSingleRowBooleanColumn ( JNIEnv *  env,
Table table,
unsigned char  data 
)

Add a boolean column to a Table with only one row.

This function will allocate the required memory for the single unsigned char that is required.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a pointer to an unsigned char.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 996 of file aida_pva_types_helper.c.

997{
998 tableAddColumn(env, table, AIDA_BOOLEAN_TYPE, &data, false);
999}
@ AIDA_BOOLEAN_TYPE
Represents a boolean.

References AIDA_BOOLEAN_TYPE, and tableAddColumn().

Referenced by aidaRequestTable(), and aidaSetValueWithResponse().

◆ tableAddSingleRowByteColumn()

void tableAddSingleRowByteColumn ( JNIEnv *  env,
Table table,
unsigned char  data 
)

Add a byte column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, an unsigned char.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1025 of file aida_pva_types_helper.c.

1026{
1027 tableAddColumn(env, table, AIDA_BYTE_TYPE, &data, false);
1028}
@ AIDA_BYTE_TYPE
Represents a byte.

References AIDA_BYTE_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowDoubleColumn()

void tableAddSingleRowDoubleColumn ( JNIEnv *  env,
Table table,
double  data,
bool  ieeeDouble 
)

Add a double column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a double.
ieeeDoubleTrue if the data is in ieee format, otherwise the double precision floating point number is converted from VMS to ieee format.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowStringColumn(),

Definition at line 1175 of file aida_pva_types_helper.c.

1176{
1177 tableAddColumn(env, table, AIDA_DOUBLE_TYPE, &data, ieeeDouble);
1178}
@ AIDA_DOUBLE_TYPE
Represents a double.

References AIDA_DOUBLE_TYPE, and tableAddColumn().

Referenced by aidaRequestTable(), and aidaSetValueWithResponse().

◆ tableAddSingleRowFloatColumn()

void tableAddSingleRowFloatColumn ( JNIEnv *  env,
Table table,
float  data,
bool  ieeeFloat 
)

Add a float column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a float.
ieeeFloatTrue if the data is in ieee format, otherwise the given floating point number is converted from VMS to ieee format.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1144 of file aida_pva_types_helper.c.

1145{
1146 tableAddColumn(env, table, AIDA_FLOAT_TYPE, &data, ieeeFloat);
1147}

References AIDA_FLOAT_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowIntegerColumn()

void tableAddSingleRowIntegerColumn ( JNIEnv *  env,
Table table,
int  data 
)

Add a integer column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
datathe data to add to this column, an int
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1083 of file aida_pva_types_helper.c.

1084{
1085 tableAddColumn(env, table, AIDA_INTEGER_TYPE, &data, false);
1086}
@ AIDA_INTEGER_TYPE
Represents an integer.

References AIDA_INTEGER_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowLongColumn()

void tableAddSingleRowLongColumn ( JNIEnv *  env,
Table table,
long  data 
)

Add a long column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
datathe data to add to this column. A long value
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1113 of file aida_pva_types_helper.c.

1114{
1115 tableAddColumn(env, table, AIDA_LONG_TYPE, &data, false);
1116}
@ AIDA_LONG_TYPE
Represents a long.

References AIDA_LONG_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowShortColumn()

void tableAddSingleRowShortColumn ( JNIEnv *  env,
Table table,
short  data 
)

Add a short column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a short.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1054 of file aida_pva_types_helper.c.

1055{
1056 tableAddColumn(env, table, AIDA_SHORT_TYPE, &data, false);
1057}
@ AIDA_SHORT_TYPE
Represents a short.

References AIDA_SHORT_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowStringColumn()

void tableAddSingleRowStringColumn ( JNIEnv *  env,
Table table,
char *  data 
)

Add a string column to a Table with only one row.

This is a shortcut Table function that simplifies adding a string to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
datathe data to add to this column. A single string.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(),

Definition at line 1205 of file aida_pva_types_helper.c.

1206{
1207 tableAddStringColumn(env, table, &data);
1208}
void tableAddStringColumn(JNIEnv *env, Table *table, char **data)
Add a String column to the given Table.

References tableAddStringColumn().

Referenced by aidaRequestTable().

◆ tableAddStringColumn()

void tableAddStringColumn ( JNIEnv *  env,
Table table,
char **  data 
)

Add a String column to the given Table.

This reads data from a buffer that is itself a list of pointers to strings. We allocate just enough space to store the strings in our Table. This is allocated in one buffer so there is only one pointer to release.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the string column to.
datathe data to add to this column, a buffer of sizeof(char *) * table->rowCount size. This will contain the strings to be added to the Table.
See also
tableCreate(), tableAddColumn(), tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a single column, one row Table, add data, and return.

int rows = 1, columns = 1;
char* namesData[rows];
namesData[0] = "NAME";
Table table = tableCreate(env, rows, columns);
tableAddStringColumn(env, &table, namesData);
return table;
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Definition at line 912 of file aida_pva_types_helper.c.

913{
914 tableAddColumn(env, table, AIDA_STRING_ARRAY_TYPE, data, false);
916
917 // allocate data for each string too
918 char** stringArray = table->ppData[table->_currentColumn];
919 for (int row = 0; row < table->rowCount; row++, data++) {
920 ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID(env, stringArray[row], *data, "table strings")
921 }
922
923 table->_currentColumn++;
924}

References Table::_currentColumn, AIDA_STRING_ARRAY_TYPE, ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID, ON_EXCEPTION_RETURN_VOID, Table::ppData, Table::rowCount, and tableAddColumn().

Referenced by aidaRequestTable(), and tableAddSingleRowStringColumn().

◆ tableCreate()

Table tableCreate ( JNIEnv *  env,
int  rows,
int  columns 
)

Make a Table for return to client.

Table Handling.

This is the first call that needs to be made to return a Table. This will create a Table with the specified the number of rows and columns. You need to call tableAddColumn(), tableAddStringColumn(), or any of the other special tableAdd functions to add columns to the Table before returning it.

Parameters
envThe JNI environment. Used in all functions involving JNI.
rowsthe number of rows to create the Table with.
columnsthe number of columns to create the Table with,
Returns
the newly created Table
See also
tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a two column, two row Table, add data, and return.

int rows = 2, columns = 2;
float xData[rows] = { 1.0f, 2.0f }, yData[rows] = { 7.0f, 8.0f };
Table table = tableCreate(env, rows, columns);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, xData, true);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, yData, true);
return table;
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Definition at line 672 of file aida_pva_types_helper.c.

673{
674 Table table;
675 memset(&table, 0, sizeof(table));
676 table._currentColumn = 0; // Reset current column so that any addColumn() calls are correct
677 table.columnCount = 0;
678
679 if (rows <= 0) {
680 aidaThrowNonOsException(env, AIDA_INTERNAL_EXCEPTION, "Attempt to allocate a zero length table");
681 return table;
682 }
683
684 // Allocate space for the table columns and column types
685 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, table.ppData, columns * sizeof(void*), "table columns", table)
686 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, table.types, columns * sizeof(Type*), "table column types", table)
687 table.rowCount = rows;
688 table.columnCount = columns;
689 return table;
690}
#define AIDA_INTERNAL_EXCEPTION
Use this string to signal Internal Exceptions in aidaThrow()
#define ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(_env, _var, _size, _purpose, _r)
Allocate memory and on error return the given value.
Type
The definition of Aida Types.
Type * types
the scalar type of each column, one of BOOLEAN, BYTE, SHORT, INTEGER, LONG, FLOAT,...

References Table::_currentColumn, AIDA_INTERNAL_EXCEPTION, aidaThrowNonOsException(), ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, Table::columnCount, Table::ppData, Table::rowCount, and Table::types.

Referenced by aidaRequestTable(), aidaSetValueWithResponse(), and tableCreateDynamic().

◆ tableCreateDynamic()

Table tableCreateDynamic ( JNIEnv *  env,
int  rows,
int  columns 
)

Make a Dynamic Table for return to client.

This is the first call that needs to be made to return a Dynamic Table. This will create a Table with the specified the number of rows and columns. You need to call tableAddColumn(), tableAddStringColumn(), tableAddField(), tableAddLabel(), or any of the other special tableAdd functions to add columns to the Table before returning it. Calling tableAddField(), and tableAddLabel() are mandatory

Parameters
envThe JNI environment. Used in all functions involving JNI.
rowsthe number of rows to create the Table with.
columnsthe number of columns to create the Table with,
Returns
the newly created Table
See also
tableAddColumn(), tableAddField(), tableAddLabel(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a two column, two row Table, Set Field names, and labels, add data, and return.

int rows = 2, columns = 2;
float xData[rows] = { 1.0f, 2.0f }, yData[rows] = { 7.0f, 8.0f };
char *fields[columns] = { "field1", "field2" };
char *labels[columns] = { "label1", "label2" };
Table table = tableCreateDynamic(env, rows, columns);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, xData, true);
tableAddField(env, &table, fields[0]);
tableAddLabel(env, &table, labels[0]);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, yData, true);
tableAddField(env, &table, fields[1]);
tableAddLabel(env, &table, labels[1]);
return table;
void tableAddField(JNIEnv *env, Table *table, char *fieldName)
Add a dynamic field to a table.
void tableAddLabel(JNIEnv *env, Table *table, char *labelName)
Add a dynamic column to a table.
Table tableCreateDynamic(JNIEnv *env, int rows, int columns)
Make a Dynamic Table for return to client.
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Definition at line 692 of file aida_pva_types_helper.c.

692 {
693 Table table = tableCreate(env, rows, columns);
695
696 table._currentField = 0; // Reset current field so that any addField() calls are correct
697 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, table.ppFields, columns * sizeof(char*), "table fields", table)
698 table._currentLabel = 0; // Reset current label so that any addLabel() calls are correct
699 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, table.ppLabels, columns * sizeof(char*), "table fields", table)
700 return table;
701}

References Table::_currentField, Table::_currentLabel, ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ON_EXCEPTION_RETURN_, Table::ppFields, Table::ppLabels, and tableCreate().

Referenced by aidaRequestTable().