C OUTPUT
The C formatter getter and setter shall expose and replace the calling thread's variable-output callback. The supplied callback shall be callable, return normally and return a borrowed NUL-terminated representation, or null to signal failure. The default callback shall use the native letter-and-quotient naming convention.
Direct variable output and object output containing a variable shall use that callback. A null callback result shall make the enclosing C output operation report PPL_STDIO_ERROR and notify the installed error handler. Failed formatting shall not be reported as successful output with the variable silently omitted.
The valid-use and result-category conditions in 🔗 1. C handles, arguments and successful outcomes shall apply.
A missing variable can change the meaning of a displayed constraint or expression.
Public header: <ppl_c.h>.
int ppl_io_print_variable(ppl_dimension_type var); int ppl_io_fprint_variable(FILE *stream, ppl_dimension_type var); int ppl_io_asprint_variable(char **strp, ppl_dimension_type var); int ppl_io_set_variable_output_function( ppl_io_variable_output_function_type *p); int ppl_io_get_variable_output_function( ppl_io_variable_output_function_type **pp);
Check default and custom names, borrowed callback strings, null callback results in direct and composite output, and errno/error-handler propagation.
interfaces/C/ppl_c_header.h; interfaces/C/ppl_c_implementation_common.cc; interfaces/C/tests/ccontractsspec1.cc; interfaces/C/tests/cerrorsspec1.cc.
The ppl_io_print_T and ppl_io_fprint_T families shall write the native human-readable representation to standard output or the supplied live FILE. ppl_io_asprint_T shall allocate a NUL-terminated buffer containing that representation, store its address and transfer ownership to the caller for free. On a reported allocation or I/O failure no completed representation shall be promised; partial external stream output may already exist. Formatting shall remain distinct from reloadable serialization. Buffered C streams remain subject to the caller's later flushing and closing errors.
The valid-use and result-category conditions in 🔗 1. C handles, arguments and successful outcomes shall apply.
A C client needs explicit buffer ownership and observable write failures.
Public header: <ppl_c.h>.
/* T ranges over exposed C object types. */ int ppl_io_print_T(ppl_const_T_t x); int ppl_io_fprint_T(FILE *file, ppl_const_T_t x); int ppl_io_asprint_T(char **result, ppl_const_T_t x);
Compare buffered and file output, exercise callback and writable-stream failures, inject allocation failure and release every successful buffer.
interfaces/C/ppl_c_header.h; interfaces/C/ppl_c_implementation_common_defs.hh; interfaces/C/tests/ccontractsspec1.cc; interfaces/C/tests/cerrorsspec1.cc.
ppl_io_wrap_string shall apply native byte-oriented line wrapping through the first NUL byte, with the supplied indentation and preferred line lengths. Its successful result shall be a caller-owned NUL-terminated malloc buffer released with free. Preferred widths shall guide separator selection without splitting unbroken words. Native C++ exceptions and failure to allocate the final C buffer shall produce null and the corresponding error-handler notification. Successful wrapping shall preserve the native text and separator rules.
The valid-use and result-category conditions in 🔗 1. C handles, arguments and successful outcomes shall apply.
The pointer-returning utility must still contain failures at the C boundary.
Public header: <ppl_c.h>.
char *ppl_io_wrap_string(const char *src, unsigned indent_depth, unsigned preferred_first_line_length, unsigned preferred_line_length);
Compare exact text for empty input, commas, newlines, indentation and long words; inject string construction and final-buffer allocation failures.
interfaces/C/ppl_c_header.h; interfaces/C/ppl_c_implementation_common.cc; interfaces/C/tests/ccontractsspec1.cc; interfaces/C/tests/cerrorsspec1.cc.
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000202 C object ownership and borrowed access (Specifies)
- PPL-LLR-000203 C boundary error reporting (Specifies)
- PPL-LLR-000214 Mathematical consistency of corresponding binding operations (Specifies)
- PPL-LLR-000446 Reloadable textual representations (Specifies)
For types with ASCII operations, ppl_T_ascii_dump shall write the native reloadable representation to a live FILE. ppl_T_ascii_load shall replace the mutable owned object's value when the native loader succeeds. A native false result or detected stream failure shall report PPL_STDIO_ERROR and notify the error handler. Loading supports trusted records written by the corresponding native dumper in a compatible build. Native failure-state guarantees shall apply. A failed load may leave a partially replaced object whose ownership permits destruction. Rollback and further queries shall not be assumed. Borrowed objects shall not be loaded into.
The valid-use and result-category conditions in 🔗 1. C handles, arguments and successful outcomes shall apply.
C serialization must expose the native parser outcome without changing ownership.
Public header: <ppl_c.h>.
/* T ranges over types exposing the native operations. */ int ppl_T_ascii_dump(ppl_const_T_t x, FILE *file); int ppl_T_ascii_load(ppl_T_t x, FILE *file);
Round-trip descriptor, system, optimizer and generated-domain values through files, test malformed and truncated input and populated destinations, and verify destruction after rejected loads.
interfaces/C/ppl_c_header.h; interfaces/C/ppl_c_implementation_common_defs.hh; interfaces/C/tests/ccontractsspec1.cc; interfaces/C/tests/cerrorsspec1.cc.