Added a new tidyOptionIsList() API service.

This commit is contained in:
Jim Derry 2017-11-19 12:02:24 -05:00
parent b342232378
commit ae20af4181
4 changed files with 24 additions and 1 deletions

View file

@ -708,10 +708,16 @@ TIDY_EXPORT ctmbstr TIDY_CALL tidyOptGetName( TidyOption opt );
/** Get datatype of given Option
** @param opt An instance of a TidyOption to query.
** @result the TidyOptionType of the given option.
** @result The TidyOptionType of the given option.
*/
TIDY_EXPORT TidyOptionType TIDY_CALL tidyOptGetType( TidyOption opt );
/** Indicates that an option takes a list of items.
** @param opt An instance of a TidyOption to query.
** @result A bool indicating whether or not the option accepts a list.
*/
TIDY_EXPORT Bool TIDY_CALL tidyOptionIsList( TidyOption opt );
/** Is Option read-only? Some options (mainly internal use only options) are
** read-only.
** @deprecated This is no longer a valid test for the public API; instead

View file

@ -342,6 +342,11 @@ const TidyOptionImpl* TY_(getOption)( TidyOptionId optId )
return NULL;
}
const Bool TY_(getOptionIsList)( TidyOptionId optId )
{
const TidyOptionImpl* option = TY_(getOption)( optId );
return option->parser == ParseList;
}
static void FreeOptionValue( TidyDocImpl* doc, const TidyOptionImpl* option, TidyOptionValue* value )
{

View file

@ -149,6 +149,11 @@ const TidyOptionImpl* TY_(lookupOption)( ctmbstr optnam );
*/
const TidyOptionImpl* TY_(getOption)( TidyOptionId optId );
/** Given an option ID, indicates whether or not the option is a list.
** @param optId The option ID to check.
** @returns Returns yes if the option value is a list.
*/
const Bool TY_(getOptionIsList)( TidyOptionId optId );
/** Initiates an iterator to cycle through all of the available options.
** @param doc The Tidy document to get options.

View file

@ -357,6 +357,13 @@ TidyOptionType TIDY_CALL tidyOptGetType( TidyOption topt )
return option->type;
return (TidyOptionType) -1;
}
Bool TIDY_CALL tidyOptionIsList( TidyOption opt )
{
const TidyOptionImpl* option = tidyOptionToImpl( opt );
if ( option )
return TY_(getOptionIsList)( option->id );
return no;
}
TidyConfigCategory TIDY_CALL tidyOptGetCategory( TidyOption topt )
{
const TidyOptionImpl* option = tidyOptionToImpl( topt );