Tidy provides flexible I/O.
By default, Tidy will define, create and use instances of input and output handlers for standard C buffered I/O (i.e., FILE* stdin
, FILE* stdout
, and FILE* stderr
for content input, content output and diagnostic output, respectively. A FILE* cfgFile
input handler will be used for config files. Command line options will just be set directly.
|
struct | TidyBuffer |
| A TidyBuffer is chunk of memory that can be used for multiple I/O purposes within Tidy. More...
|
|
struct | TidyInputSource |
| This type defines an input source capable of delivering raw bytes of input. More...
|
|
struct | TidyOutputSink |
| This type defines an output destination capable of accepting raw bytes of output. More...
|
|
|
A simple callback to filter or collect messages by diagnostic level, for example, TidyInfo, TidyWarning, etc.
Its name reflects its original purpose as a filter, by which your application can inform LibTidy whether or not to output a particular report.
|
typedef Bool(TIDY_CALL * | TidyReportFilter) (TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr mssg) |
| This typedef represents the required signature for your provided callback function should you wish to register one with tidySetReportFilter(). More...
|
|
Bool TIDY_CALL | tidySetReportFilter (TidyDoc tdoc, TidyReportFilter filtCallback) |
| This function informs Tidy to use the specified callback to send reports. More...
|
|
|
A sophisticated and extensible callback to filter or collect messages reported by Tidy.
It returns only an opaque type TidyMessage for every report and dialogue message, and this message can be queried with the TidyMessageCallback API, below. Note that unlike the older filters, this callback exposes all output that LibTidy emits (excluding the console application, which is a client of LibTidy).
|
typedef Bool(TIDY_CALL * | TidyMessageCallback) (TidyMessage tmessage) |
| This typedef represents the required signature for your provided callback function should you wish to register one with tidySetMessageCallback(). More...
|
|
Bool TIDY_CALL | tidySetMessageCallback (TidyDoc tdoc, TidyMessageCallback filtCallback) |
| This function informs Tidy to use the specified callback to send reports. More...
|
|
A TidyBuffer is chunk of memory that can be used for multiple I/O purposes within Tidy.
Data Fields |
uint |
allocated |
Number of bytes allocated. |
TidyAllocator * |
allocator |
Memory allocator. |
byte * |
bp |
Pointer to bytes. |
uint |
next |
Offset of current input position. |
uint |
size |
Number of bytes currently in use. |
This type defines an input source capable of delivering raw bytes of input.
Data Fields |
TidyEOFFunc |
eof |
Pointer to "eof" callback. |
TidyGetByteFunc |
getByte |
Pointer to "get byte" callback. |
void * |
sourceData |
Input context. Passed to callbacks.
|
TidyUngetByteFunc |
ungetByte |
Pointer to "unget" callback. |
This type defines an output destination capable of accepting raw bytes of output.
Data Fields |
TidyPutByteFunc |
putByte |
Pointer to "put byte" callback. |
void * |
sinkData |
Output context. Passed to callbacks.
|
#define EndOfStream (~0u) |
End of input "character".
Input Callback: is end of input?
typedef int(TIDY_CALL * TidyGetByteFunc) (void *sourceData) |
Input Callback: get next byte of input.
This typedef represents the required signature for your provided callback function should you wish to register one with tidySetMessageCallback().
Your callback function will be provided with the following parameters.
- Parameters
-
tmessage | An opaque type used as a token against which other API calls can be made. |
- Returns
- Your callback function will return
yes
if Tidy should include the report in its own output sink, or no
if Tidy should suppress it.
This typedef represents the required signature for your provided callback function should you wish to register one with tidySetMessageCallback().
Your callback function will be provided with the following parameters.
- Parameters
-
tdoc | Indicates the source tidy document. |
line | Indicates the line in the source document at this point in the process. |
col | Indicates the column in the source document at this point in the process. |
destLine | Indicates the line number in the output document at this point in the process. |
typedef void(TIDY_CALL * TidyPutByteFunc) (void *sinkData, byte bt) |
Output callback: send a byte to output.
This typedef represents the required signature for your provided callback function should you wish to register one with tidySetReportCallback().
Your callback function will be provided with the following parameters.
- Parameters
-
tdoc | Indicates the tidy document the message comes from. |
lvl | Specifies the TidyReportLevel of the message. |
line | Indicates the line number in the source document the message applies to. |
col | Indicates the column in the source document the message applies to. |
code | Specifies the message code representing the message. Note that this code is a string value that the API promises to hold constant, as opposed to an enum value that can change at any time. Although this is intended so that you can look up your own application's strings, you can retrieve Tidy's format string with this code by using tidyErrorCodeFromKey() and then the tidyLocalizedString() family of functions. |
args | Is a va_list of arguments used to fill Tidy's message format string. |
- Returns
- Your callback function will return
yes
if Tidy should include the report in its own output sink, or no
if Tidy should suppress it.
This typedef represents the required signature for your provided callback function should you wish to register one with tidySetReportFilter().
Your callback function will be provided with the following parameters.
- Parameters
-
tdoc | Indicates the tidy document the message comes from. |
lvl | Specifies the TidyReportLevel of the message. |
line | Indicates the line number in the source document the message applies to. |
col | Indicates the column in the source document the message applies to. |
mssg | Specifies the complete message as Tidy would emit it. |
- Returns
- Your callback function will return
yes
if Tidy should include the report in its own output sink, or no
if Tidy should suppress it.
typedef void(TIDY_CALL * TidyUngetByteFunc) (void *sourceData, byte bt) |
Input Callback: unget a byte of input.
Returns the format specifier of the given message argument.
The memory for this string is cleared upon termination of the callback, so do be sure to make your own copy.
- Returns
- Returns the format specifier string of the given argument.
- Parameters
-
tmessage | The message whose arguments you want to access. |
arg | The argument that you are querying. |
Returns the TidyFormatParameterType
of the given message argument.
- Returns
- Returns the type of parameter of type TidyFormatParameterType.
- Parameters
-
tmessage | The message whose arguments you want to access. |
arg | The argument that you are querying. |
Returns the double value of the given message argument.
An assertion will be generated if the argument type is not a double.
- Returns
- Returns the double value of the given argument.
- Parameters
-
tmessage | The message whose arguments you want to access. |
arg | The argument that you are querying. |
Returns the integer value of the given message argument.
An assertion will be generated if the argument type is not an integer.
- Returns
- Returns the integer value of the given argument.
- Parameters
-
tmessage | The message whose arguments you want to access. |
arg | The argument that you are querying. |
Returns the string value of the given message argument.
An assertion will be generated if the argument type is not a string.
- Returns
- Returns the string value of the given argument.
- Parameters
-
tmessage | The message whose arguments you want to access. |
arg | The argument that you are querying. |
Returns the unsigned integer value of the given message argument.
An assertion will be generated if the argument type is not an unsigned int.
- Returns
- Returns the unsigned integer value of the given argument.
- Parameters
-
tmessage | The message whose arguments you want to access. |
arg | The argument that you are querying. |
Helper: get next byte from input source.
- Parameters
-
source | A pointer to your input source. |
- Returns
- Returns a byte as an unsigned integer.
Get the file path to use for reports when TidyEmacs
is being used.
This function provides a proper interface for using the hidden, internal-only TidyEmacsFile
configuration option.
- Parameters
-
tdoc | The tidy document for which you want to fetch the file path. |
- Returns
- Returns a string indicating the file path.
Get the message with the format string already completed, in Tidy's current localization.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the message in the current localization.
Initiates an iterator for a list of arguments related to a given message.
This iterator allows you to iterate through all of the arguments, if any. In order to iterate through the arguments, initiate the iterator with this function, and then use tidyGetNextMessageArgument() to retrieve the first and subsequent arguments. For example:
- Parameters
-
tmessage | The message about whose arguments you wish to query. |
- Returns
- Returns a TidyIterator, which is a token used to represent the current position in a list within LibTidy.
Get the message code.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns a code representing the message. This code can be used directly with the localized strings API; however we never make any guarantees about the value of these codes. For code stability don't store this value in your own application. Instead use the enum field or use the message key string value.
Get the column the message applies to.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the column number, if any, that generated the message.
Get the message with the format string already completed, in Tidy's default localization.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the message in the default localization.
Get the tidy document this message comes from.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the TidyDoc that generated the message.
Get the localized format string.
If a localized version of the format string doesn't exist, then the default version will be returned.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the localized format string of the message.
Get the default format string, which is the format string for the message in Tidy's default localization (en_us).
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the default localization format string of the message.
Get the muted status of the message, that is, whether or not the current configuration indicated that this message should be muted.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns a Bool indicating that the config indicates muting this message.
Get the message key string.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns a string representing the message. This string is intended to be stable by the LibTidy API, and is suitable for use as a key in your own applications.
Get the TidyReportLevel of the message.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns a TidyReportLevel indicating the severity or status of the message.
Get the line number the message applies to.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the line number, if any, that generated the message.
Get the complete message as Tidy would emit it in the current localization.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the complete message just as Tidy would display it on the console.
Get the complete message as Tidy would emit it in the default localization.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the complete message just as Tidy would display it on the console.
Get the position part part of the message in the current language.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the positional part of a string as Tidy would display it in the console application.
Get the position part part of the message in the default language.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the positional part of a string as Tidy would display it in the console application.
Get the prefix part of a message in the current language.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the message prefix part of a string as Tidy would display it in the console application.
Get the prefix part of a message in the default language.
- Parameters
-
tmessage | Specify the message that you are querying. |
- Returns
- Returns the message prefix part of a string as Tidy would display it in the console application.
Facilitates user defined sinks by providing an entry point to marshal pointers-to-functions.
This is needed by .NET, and possibly other language bindings.
- Returns
- Returns a bool indicating success or failure.
- Parameters
-
sink | The sink to populate with data. |
snkData | The output context. |
pbFunc | Pointer to the "put byte" callback function. |
Facilitates user defined source by providing an entry point to marshal pointers-to-functions.
This is needed by .NET, and possibly other language bindings.
- Returns
- Returns a bool indicating success or failure.
- Parameters
-
source | The source to populate with data. |
srcData | The input context. |
gbFunc | Pointer to the "get byte" callback. |
ugbFunc | Pointer to the "unget" callback. |
endFunc | Pointer to the "eof" callback. |
Helper: check if input source at end.
- Parameters
-
- Returns
- Returns a bool indicating whether or not the source is at EOF.
Helper: send a byte to output.
- Parameters
-
sink | The output sink to send a byte. |
byteValue | The byte to be sent. |
Set the file path to use for reports when TidyEmacs
is being used.
This function provides a proper interface for using the hidden, internal-only TidyEmacsFile
configuration option.
- Parameters
-
tdoc | The tidy document for which you are setting the filePath. |
filePath | The path of the document that should be reported. |
Set error sink to given buffer.
- Returns
- Returns 0 upon success or a standard error number.
- Parameters
-
tdoc | The document to set. |
errbuf | The TidyBuffer to collect output. |
Set error sink to named file.
- Returns
- Returns a file handle.
- Parameters
-
tdoc | The document to set. |
errfilnam | The file path to send output. |
Set error sink to given generic sink.
- Returns
- Returns 0 upon success or a standard error number.
- Parameters
-
This function informs Tidy to use the specified callback to send reports.
- Parameters
-
tdoc | The tidy document for which the callback applies. |
filtCallback | A pointer to your callback function of type TidyMessageCallback. |
This function informs Tidy to use the specified callback for tracking the pretty-printing process progress.
This function informs Tidy to use the specified callback to send reports.
- Parameters
-
tdoc | The tidy document for which the callback applies. |
filtCallback | A pointer to your callback function of type TidyReportCallback. |
This function informs Tidy to use the specified callback to send reports.
- Parameters
-
tdoc | The tidy document for which the callback applies. |
filtCallback | A pointer to your callback function of type TidyReportFilter. |
Helper: unget byte back to input source.
- Parameters
-
source | The input source. |
byteValue | The byte to push back. |