tpf_dfdl_getData: Retrieve the data stream associated with a DFDL description

This function retrieves the data stream that is used with a DFDL API handle. The data stream is set for the API handle by using the tpf_dfdl_setData function.

Last updated

  • Changed in 2022 (information only; no code change).
  • Changed for PUT14 (information only; no code change).
  • Added for PUT11.

Format

LIBS := DFDL

#include <tpf/cdfdl.h>

void tpf_dfdl_getData(DFDLHandle   dfdlhdl, 
                      void         **buffer, 
                      unsigned int *length);
dfdlhdl
A DFDL API handle that is associated with the DFDL structure that describes the binary data.
buffer
A pointer to a buffer area that will contain the address of a data stream on return.
length
A pointer to an area that will contain the length of the data stream that is returned.

Normal return

None.

Error return

None.

Exceptions

If an error occurs, one of the following exceptions is issued:
  • std::bad_alloc
  • std::invalid_argument
  • std::length_error
  • std::logic_error
  • std::runtime_error

Programming considerations

  • You must initialize the DFDL API handle by calling the tpf_dfdl_initialize_handle or tpf_dfdl_createChildHandle function.
  • If an exception is issued, the values that are returned for the buffer and the length parameters might be changed.

Example

The following example writes the data that is associated with a DFDL API handle to a socket:
#include <sys/socket.h>
#include <tpf/cdfdl.h>

⋮

void *buf;
unsigned int len;
int nbytes;

try {
     tpf_dfdl_getData(dfdlhdl, &buf, &len); 	
     nbytes = write(sock, buf, (int) len); 
} 
catch (...) { 	
      // handle error 
}