|
|
Using a VIEW Typed Buffer
There are two kinds of VIEW typed buffers. The first, FML VIEW, is a C structure generated from an FML buffer. The second is simply an independent C structure.
The reason for converting FML buffers into C structures and back again (and the purpose of the FML VIEW typed buffers) is that while FML buffers provide data-independence and convenience, they incur processing overhead because they must be manipulated using FML function calls. C structures, while not providing flexibility, offer the performance required for lengthy manipulations of buffer data. If you need to perform a significant amount of data manipulation, you can improve performance by transferring fielded buffer data to C structures, operating on the data using normal C functions, and then converting the data back to the FML buffer for storage or message transmission.
For more information on the FML typed buffer and FML file conversion, refer to the BEA Tuxedo ATMI FML Function Reference.
To use VIEW typed buffers, you must perform the following steps:
Setting Environment Variables for a VIEW Typed Buffer
To use a VIEW typed buffer in an application, you must set the following environment variables.
Environment Variables for a VIEW Typed Buffer
Creating a View Description File To use a VIEW typed buffer, you must define the C record in a view description file. The view description file includes, a view for each entry, a view that describes the characteristic C structure mapping and the potential FML conversion pattern. The name of the view corresponds to the name of the C language structure. The following format is used for each structure in the view description file: $ /* View structure */ The following table describes the fields that must be specified in the view description file for each C structure.
VIEW viewname
type cname fbname count flag size null
You can include a comment line by prefixing it with the # or $ character. Lines prefixed by a $ sign are included in the .h file.
The following listing is an excerpt from an example view description file based on an FML buffer. In this case, the fbname field must be specified and match that which appears in the corresponding field table file. Note that the CARRAY1 field includes an occurrence count of 2 and sets the C flag to indicate that an additional count element should be created. In addition, the L flag is set to establish a length element that indicates the number of characters with which the application populates the CARRAY1 field.
View Description File for FML VIEW
$ /* View structure */
VIEW MYVIEW
#type cname fbname count flag size null
float float1 FLOAT1 1 - - 0.0
double double1 DOUBLE1 1 - - 0.0
long long1 LONG1 1 - - 0
short short1 SHORT1 1 - - 0
int int1 INT1 1 - - 0
dec_t dec1 DEC1 1 - 9,16 0
char char1 CHAR1 1 - - '\0'
string string1 STRING1 1 - 20 '\0'
carray carray1 CARRAY1 2 CL 20 '\0'
END
The following listing illustrates the same view description file for an independent VIEW.
View Description File for an Independent View
$ /* View data structure */
VIEW MYVIEW
#type cname fbname count flag size null
float float1 - 1 - - -
double double1 - 1 - - -
long long1 - 1 - - -
short short1 - 1 - - -
int int1 - 1 - - -
dec_t dec1 - 1 - 9,16 -
char char1 - 1 - - -
string string1 - 1 - 20 -
carray carray1 - 2 CL 20 -
END
Note that the format is similar to the FML-dependent view, except that the fbname and null fields are not relevant and are ignored by the viewc compiler. You must include a value (for example, a dash) as a placeholder in these fields.
Executing the VIEW Compiler
To compile a VIEW typed buffer, run the viewc command, specifying the name of the view description file as an argument. To specify an independent VIEW, use the -n option. You can optionally specify a directory in which the resulting output file should be written. By default, the output file is written to the current directory.
For example, for an FML-dependent VIEW, the compiler is invoked as follows:
viewc myview.v
Note: To compile a VIEW32 typed buffer, run the viewc32 command.
For an independent VIEW, use the -n option on the command line, as follows:
viewc -n myview.v
The output of the viewc command includes:
Note: On case-insensitive platforms (for example, Microsoft Windows), the extension used for the names of such files is vv; for example, myview.vv.
The following listing provides an example of the header file created by viewc.
Header File Created Using the VIEW Compiler
struct MYVIEW {
float float1;
double double1;
long long1;
short short1;
int int1;
dec_t dec1;
char char1;
char string1[20];
unsigned short L_carray1[2]; /* length array of carray1 */
short C_carray1; /* count of carray1 */
char carray1[2][20];
};
The same header file is created for FML-dependent and independent VIEWs.
In order to use a VIEW typed buffer in client programs or service subroutines, you must specify the header file in the application #include statements.
See Also
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|