Copyright (C) Kevin Larke 2009-2020
This file is part of libcm.
libcm is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
libcm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
See the GNU General Public License distributed with the libcm
package or look here:
The cmRpt class provides console output style output, like stdout and stderr for most of the classes in the cm library.
By wrapping this functionality in a class it is possible to easily redirect output to one or more possible console targets.
// Application supplied callback function which is called to deliver text // to the destination terminal or GUI. typedef void (*cmRptPrintFunc_t)(void* cmRptUserPtr, const cmChar_t* text); // Data record used to hold the state information. typedef struct { cmRptPrintFunc_t printFuncPtr; // Application supplied callback text printing function as set from printFunc argument to cmRptSetup(). cmRptPrintFunc_t errorFuncPtr; // Application supplied callback error printing function as set from the errFunc argument to cmRptSetup(). void* userPtr; // Application supplied callback argument (cmRptUserPtr in cmRptPrintFunc_t) to be passed back to the application with each call to printFuncPtr() or errorFuncPtr(). } cmRpt_t; // A global cmRpt_t object which can be used to initialze another cmRpt_t. extern cmRpt_t cmRptNull; // The host application calls cmRptSetup() to initialize a cmRpt object. void cmRptSetup( cmRpt_t* rpt, cmRptPrintFunc_t printFunc, cmRptPrintFunc_t errFunc, void* userPtr ); // Text output functions: // Functions to print text to the application console. void cmRptPrint( cmRpt_t* rpt, const cmChar_t* text ); void cmRptVPrintf( cmRpt_t* rpt, const cmChar_t* fmt, va_list vl ); void cmRptPrintf( cmRpt_t* rpt, const cmChar_t* fmt, ... ); // Error reporting functions: // Functions to print error messages to the application error console, void cmRptError( cmRpt_t* rpt, const cmChar_t* text ); void cmRptVErrorf( cmRpt_t* rpt, const cmChar_t* fmt, va_list vl ); void cmRptErrorf( cmRpt_t* rpt, const cmChar_t* fmt, ... );