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...
|
|
◆ _TidyBuffer
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. |
◆ TidyInputSource
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. |
◆ TidyOutputSink
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.
|
◆ EndOfStream
#define EndOfStream (~0u) |
End of input "character".
◆ TidyEOFFunc
Input Callback: is end of input?
◆ TidyGetByteFunc
typedef int(TIDY_CALL * TidyGetByteFunc) (void *sourceData) |
Input Callback: get next byte of input.
◆ TidyMessageCallback
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.
◆ TidyPPProgress
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. |
◆ TidyPutByteFunc
typedef void(TIDY_CALL * TidyPutByteFunc) (void *sinkData, byte bt) |
Output callback: send a byte to output.
◆ TidyReportCallback
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.
◆ TidyReportFilter
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.
◆ TidyUngetByteFunc
typedef void(TIDY_CALL * TidyUngetByteFunc) (void *sourceData, byte bt) |
Input Callback: unget a byte of input.
◆ tidyGetArgFormat()
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. |
◆ tidyGetArgType()
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. |
◆ tidyGetArgValueDouble()
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. |
◆ tidyGetArgValueInt()
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. |
◆ tidyGetArgValueString()
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. |
◆ tidyGetArgValueUInt()
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. |
◆ tidyGetByte()
Helper: get next byte from input source.
- Parameters
-
source | A pointer to your input source. |
- Returns
- Returns a byte as an unsigned integer.
◆ tidyGetEmacsFile()
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.
◆ tidyGetMessage()
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.
◆ tidyGetMessageArguments()
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:
while ( itArg ) {
}
TidyMessageArgument TIDY_CALL tidyGetNextMessageArgument(TidyMessage tmessage, TidyIterator *iter)
Given a valid TidyIterator initiated with tidyGetMessageArguments(), returns an instance of the opaqu...
TidyIterator TIDY_CALL tidyGetMessageArguments(TidyMessage tmessage)
Initiates an iterator for a list of arguments related to a given message.
Instances of this type represent the arguments that compose part of the message represented by TidyMe...
- 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.
◆ tidyGetMessageCode()
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.
◆ tidyGetMessageColumn()
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.
◆ tidyGetMessageDefault()
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.
◆ tidyGetMessageDoc()
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.
◆ tidyGetMessageFormat()
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.
◆ tidyGetMessageFormatDefault()
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.
◆ tidyGetMessageIsMuted()
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.
◆ tidyGetMessageKey()
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.
◆ tidyGetMessageLevel()
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.
◆ tidyGetMessageLine()
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.
◆ tidyGetMessageOutput()
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.
◆ tidyGetMessageOutputDefault()
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.
◆ tidyGetMessagePos()
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.
◆ tidyGetMessagePosDefault()
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.
◆ tidyGetMessagePrefix()
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.
◆ tidyGetMessagePrefixDefault()
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.
◆ tidyGetNextMessageArgument()
◆ tidyInitSink()
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. |
◆ tidyInitSource()
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. |
◆ tidyIsEOF()
Helper: check if input source at end.
- Parameters
-
- Returns
- Returns a bool indicating whether or not the source is at EOF.
◆ tidyPutByte()
Helper: send a byte to output.
- Parameters
-
sink | The output sink to send a byte. |
byteValue | The byte to be sent. |
◆ tidySetEmacsFile()
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. |
◆ tidySetErrorBuffer()
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. |
◆ tidySetErrorFile()
Set error sink to named file.
- Returns
- Returns a file handle.
- Parameters
-
tdoc | The document to set. |
errfilnam | The file path to send output. |
◆ tidySetErrorSink()
Set error sink to given generic sink.
- Returns
- Returns 0 upon success or a standard error number.
- Parameters
-
◆ tidySetMessageCallback()
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. |
◆ tidySetPrettyPrinterCallback()
This function informs Tidy to use the specified callback for tracking the pretty-printing process progress.
◆ tidySetReportCallback()
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. |
◆ tidySetReportFilter()
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. |
◆ tidyUngetByte()
Helper: unget byte back to input source.
- Parameters
-
source | The input source. |
byteValue | The byte to push back. |