EV_parseFormattedValue

- Parse a text representation of anEV_AttrValue

SYNOPSIS

#include <$OV_HEADER/ecs/EV/value.h>

int32 EV_parseFormattedValue (const char *buf, EV_AttrValue **AV );

DESCRIPTION

This function parses a string into an EV_AttrValue structure that it allocates space for, and returns a pointer to it.

Parameters

const char *buf
The string to parse. The string must be in the form of an ECDL list. Even a single value must be formatted as a list.
EV_AttrValue **AV
The address of a pointer that is set to the location of the new structure. Storage is allocated on the heap. It is up to the calling function to free this storage using EV_deleteValue when it is no longer required (usually after a call to ANNO_sendResponse).

EXAMPLES

Build an annotation server response and send it to the engine.

recvFn(	ANNO_ConnectionId	conId,
	ANNO_RequestId	reqId,
	EV_AttrValue	*requestList)

{ time_t now; struct tm* tm = NULL; char* time_stamp = NULL; real64 salary; /* returned from the `database query' */ EV_AttrValue* responseList = NULL; char responseString[ MAX_BUF_SIZE ]; ... now = time(0); tm = gmtime(&now); time_stamp = (char*)malloc(23); sprintf(time_stamp, "%04d%02d%02d%02d%02d%02d.%06dZ", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, 0);

/* now make up and send the annotation response */ sprintf(responseString, "[ %s, %f ]", time_stamp, salary);

if((rv = EV_parseFormattedValue(responseString, &responseList)) < ECS_SUCCESS)

{ /* ** There were errors in converting the response string ** into an EV_AttrValue */ fprintf(stderr, "ERROR. Could not parse response.");

/* send null response so request is cleaned up */ ANNO_sendResponse(conId, reqId, NULL); rv = ECS_ERROR;

}

/* if everything went OK, or there are just warnings, ** send the response */

if(rv >= ECS_SUCCESS)

{ rv = ANNO_sendResponse(conId, reqId, responseList); }

if(responseList) { EV_deleteValue(responseList); }

...

RETURNS

ECS_SUCCESS
Succeeded.
ECS_ERROR
Parse failed.