Print to String

The -genPrtToStr option causes functions to be generated that print the contents of variables of generated types to a given text buffer. This buffer can then be used to output the information to other mediums such as a file or window display.

It is possible to specify the name of a .c or .cpp file as an argument to this option to specify the name of the file to which these functions will be written. This is an optional argument. If not specified, the functions are written to separate files for each module in the source file. The format of the name of each file is <module>PrtToStr.c. If an output filename is specified after the –genPrtToStr qualifier, all functions are written to that file.

The calling sequence for each generated print-to-string function is as follows:

   asn1PrtToStr_<name> (const char* name, <name>* pvalue,
                        char* buffer, int bufSize)

The name and pvalue arguments are the same as they were in the -print case.

The buffer and bufSize arguments are used to describe the memory buffer the text is to be written into. These arguments specify a fixed-size buffer. If the generated text is larger than the given buffer size, as much text as possible is written to the buffer and a –1 status value is returned. If the buffer is large enough to hold the text output, all text is written to the buffer and a zero status is returned.

For C++, a toString method is generated in the control class that calls the generated print-to-string function. In addition to the name argument, this method also takes a buffer and bufSize argument to describe the buffer to which the text is to be written.