This module organizes all of Tidy's configuration options, including picklist management, option setting and retrieval, option file utilities, and so on.
Data Structures | |
struct | TidyOptionImpl |
This structure defines the internal representation of a Tidy option. More... | |
struct | PickListItem |
Structs of this type contain information needed in order to present picklists, relate picklist entries to public enum values, and parse strings that are accepted in order to assign the value. More... | |
struct | TidyConfigImpl |
This type is used to define a structure for keeping track of the values for each option. More... | |
struct | TidyOptionDoc |
Used to build a table of documentation cross-references. More... | |
union | TidyOptionValue |
Stored option values can be one of two internal types. More... | |
Macros | |
#define | cfg(doc, id) ((doc)->config.value[ (id) ].v) |
Access the raw, non-string uint value of the given option ID. More... | |
#define | cfgAutoBool(doc, id) ((TidyTriState) cfg(doc, id)) |
Access the TidyTriState value of the given option ID. More... | |
#define | cfgBool(doc, id) ((Bool) cfg(doc, id)) |
Access the Bool value of the given option ID. More... | |
#define | cfgStr(doc, id) ((ctmbstr) (doc)->config.value[ (id) ].p) |
Access the string value of the given option ID. More... | |
#define | TIDY_PL_SIZE 16 |
Determines the maximum number of items in an option's picklist. More... | |
Typedefs | |
typedef Bool( | ParseProperty) (TidyDocImpl *doc, const TidyOptionImpl *opt) |
This typedef describes a function that is used for parsing the input given for a particular Tidy option. More... | |
typedef const PickListItem | PickListItems[TIDY_PL_SIZE] |
An array of PickListItems, fixed in size for in-code declarations. More... | |
Functions | |
Bool | TY_❪AdjustCharEncoding❫ (TidyDocImpl *doc, int encoding) |
Ensure that char encodings are self consistent. More... | |
void | TY_❪AdjustConfig❫ (TidyDocImpl *doc) |
Ensure that the configuration options are self consistent. More... | |
int | TY_❪CharEncodingId❫ (TidyDocImpl *doc, ctmbstr charenc) |
Returns the character encoding ID for the given character encoding string. More... | |
ctmbstr | TY_❪CharEncodingName❫ (int encoding) |
Returns the full name of the encoding for the given ID. More... | |
ctmbstr | TY_❪CharEncodingOptName❫ (int encoding) |
Returns the Tidy command line option name of the encoding for the given ID. More... | |
Bool | TY_❪ConfigDiffThanDefault❫ (TidyDocImpl *doc) |
Indicates whether or not the current configuration is completely default. More... | |
Bool | TY_❪ConfigDiffThanSnapshot❫ (TidyDocImpl *doc) |
Indicates whether or not the current configuration is different from the stored snapshot. More... | |
void | TY_❪CopyConfig❫ (TidyDocImpl *docTo, TidyDocImpl *docFrom) |
Copies the configuration from one document to another. More... | |
void | TY_❪DeclareListItem❫ (TidyDocImpl *doc, const TidyOptionImpl *opt, ctmbstr name) |
Coordinates Config update and list data. More... | |
void | TY_❪FreeConfig❫ (TidyDocImpl *doc) |
Frees the configuration memory for the given Tidy document. More... | |
ctmbstr | TY_❪getNextOptionPick❫ (const TidyOptionImpl *option, TidyIterator *iter) |
Gets the next picklist possibility provided by the iterator. More... | |
const TidyOptionImpl * | TY_❪getNextOption❫ (TidyDocImpl *doc, TidyIterator *iter) |
Gets the next option provided by the iterator. More... | |
const Bool | TY_❪getOptionIsList❫ (TidyOptionId optId) |
Given an option ID, indicates whether or not the option is a list. More... | |
TidyIterator | TY_❪getOptionList❫ (TidyDocImpl *doc) |
Initiates an iterator to cycle through all of the available options. More... | |
TidyIterator | TY_❪getOptionPickList❫ (const TidyOptionImpl *option) |
Initiates an iterator to cycle through all of the available picklist possibilities. More... | |
const TidyOptionImpl * | TY_❪getOption❫ (TidyOptionId optId) |
Given an option ID, return an instance of an option. More... | |
ctmbstr | TY_❪GetPickListLabelForPick❫ (TidyOptionId optId, uint pick) |
Gets the picklist label for a given value. More... | |
void | TY_❪InitConfig❫ (TidyDocImpl *doc) |
Initialize the configuration for the given Tidy document. More... | |
const TidyOptionImpl * | TY_❪lookupOption❫ (ctmbstr optnam) |
Given an option name, return an instance of an option. More... | |
const TidyOptionDoc * | TY_❪OptGetDocDesc❫ (TidyOptionId optId) |
Returns the cross-reference information structure for optID, which is used for generating documentation. More... | |
int | TY_❪ParseConfigFileEnc❫ (TidyDocImpl *doc, ctmbstr cfgfil, ctmbstr charenc) |
Attempts to parse the given config file into the document, using the provided encoding. More... | |
int | TY_❪ParseConfigFile❫ (TidyDocImpl *doc, ctmbstr cfgfil) |
Attempts to parse the given config file into the document. More... | |
Bool | TY_❪ParseConfigOption❫ (TidyDocImpl *doc, ctmbstr optnam, ctmbstr optVal) |
Attempts to parse the provided value for the given option name. More... | |
Bool | TY_❪ParseConfigValue❫ (TidyDocImpl *doc, TidyOptionId optId, ctmbstr optVal) |
Attempts to parse the provided value for the given option id. More... | |
void | TY_❪ResetConfigToDefault❫ (TidyDocImpl *doc) |
Resets all options in the document to their default values. More... | |
void | TY_❪ResetConfigToSnapshot❫ (TidyDocImpl *doc) |
Restores all of the configuration values to their snapshotted values. More... | |
Bool | TY_❪ResetOptionToDefault❫ (TidyDocImpl *doc, TidyOptionId optId) |
Resets the given option to its default value. More... | |
int | TY_❪SaveConfigFile❫ (TidyDocImpl *doc, ctmbstr cfgfil) |
Saves the current configuration for options not having default values into the specified file. More... | |
int | TY_❪SaveConfigSink❫ (TidyDocImpl *doc, TidyOutputSink *sink) |
Writes the current configuration for options not having default values into the specified sink. More... | |
Bool | TY_❪SetOptionBool❫ (TidyDocImpl *doc, TidyOptionId optId, Bool val) |
Sets the bool value for the given option Id. More... | |
Bool | TY_❪SetOptionInt❫ (TidyDocImpl *doc, TidyOptionId optId, ulong val) |
Sets the integer value for the given option Id. More... | |
void | TY_❪TakeConfigSnapshot❫ (TidyDocImpl *doc) |
Stores a snapshot of all of the configuration values that can be restored later. More... | |
struct _tidy_option |
This structure defines the internal representation of a Tidy option.
The TidyOptionImpl type implements the _tidy_option
structure.
Data Fields | ||
---|---|---|
TidyConfigCategory | category | The category of the option. |
ulong | dflt | Default value for TidyInteger and TidyBoolean. |
TidyOptionId | id | The unique identifier for this option. |
ctmbstr | name | The name of the option. |
ParseProperty * | parser | Function to parse input; read-only if NULL. |
ctmbstr | pdflt | Default value for TidyString. |
PickListItems * | pickList | The picklist of possible values for this option. |
TidyOptionType | type | The date type for the option. |
struct PickListItem |
Structs of this type contain information needed in order to present picklists, relate picklist entries to public enum values, and parse strings that are accepted in order to assign the value.
Data Fields | ||
---|---|---|
ctmbstr | inputs[10] | String values that can select this value. |
ctmbstr | label | PickList label for this item. |
const int | value | The option value represented by this label. |
struct TidyConfigImpl |
This type is used to define a structure for keeping track of the values for each option.
Data Fields | ||
---|---|---|
uint | c | Current char in input stream for reading options. |
StreamIn * | cfgIn | Current input source for reading options. |
uint | defined_tags | Tracks user-defined tags. |
TidyOptionValue | snapshot[N_TIDY_OPTIONS+1] | Snapshot of values to be restored later. |
TidyOptionValue | value[N_TIDY_OPTIONS+1] | Current config values. |
struct TidyOptionDoc |
Used to build a table of documentation cross-references.
Data Fields | ||
---|---|---|
TidyOptionId const * | links |
Cross references. Last element must be 'TidyUnknownOption'. |
TidyOptionId | opt | Identifier. |
union TidyOptionValue |
#define cfg | ( | doc, | |
id | |||
) | ((doc)->config.value[ (id) ].v) |
Access the raw, non-string uint value of the given option ID.
#define cfgAutoBool | ( | doc, | |
id | |||
) | ((TidyTriState) cfg(doc, id)) |
Access the TidyTriState value of the given option ID.
#define cfgStr | ( | doc, | |
id | |||
) | ((ctmbstr) (doc)->config.value[ (id) ].p) |
Access the string value of the given option ID.
#define TIDY_PL_SIZE 16 |
Determines the maximum number of items in an option's picklist.
PickLists may have up to 16 items. For some reason, this limit has been hard-coded into Tidy for some time. Feel free to increase this as needed.
typedef Bool( ParseProperty) (TidyDocImpl *doc, const TidyOptionImpl *opt) |
This typedef describes a function that is used for parsing the input given for a particular Tidy option.
typedef const PickListItem PickListItems[TIDY_PL_SIZE] |
An array of PickListItems, fixed in size for in-code declarations.
Arrays must be populated in 0 to 10 order, as the option value is assigned based on this index and not on the structures' value field. It remains a best practice, however, to assign a public enum value with the proper index value.
Bool TY_❪AdjustCharEncoding❫ | ( | TidyDocImpl * | doc, |
int | encoding | ||
) |
Ensure that char encodings are self consistent.
doc | The Tidy document to adjust. |
encoding | The encoding being applied. |
void TY_❪AdjustConfig❫ | ( | TidyDocImpl * | doc | ) |
Ensure that the configuration options are self consistent.
doc | The Tidy document to adjust. |
int TY_❪CharEncodingId❫ | ( | TidyDocImpl * | doc, |
ctmbstr | charenc | ||
) |
Returns the character encoding ID for the given character encoding string.
doc | The Tidy document. |
charenc | The name of the character encoding. |
ctmbstr TY_❪CharEncodingName❫ | ( | int | encoding | ) |
Returns the full name of the encoding for the given ID.
encoding | The Id of the encoding. |
ctmbstr TY_❪CharEncodingOptName❫ | ( | int | encoding | ) |
Returns the Tidy command line option name of the encoding for the given ID.
encoding | The Id of the encoding. |
Bool TY_❪ConfigDiffThanDefault❫ | ( | TidyDocImpl * | doc | ) |
Indicates whether or not the current configuration is completely default.
doc | The Tidy document. |
Bool TY_❪ConfigDiffThanSnapshot❫ | ( | TidyDocImpl * | doc | ) |
Indicates whether or not the current configuration is different from the stored snapshot.
doc | The Tidy document. |
void TY_❪CopyConfig❫ | ( | TidyDocImpl * | docTo, |
TidyDocImpl * | docFrom | ||
) |
Copies the configuration from one document to another.
docTo | The destination Tidy document. |
docFrom | The source Tidy document. |
void TY_❪DeclareListItem❫ | ( | TidyDocImpl * | doc, |
const TidyOptionImpl * | opt, | ||
ctmbstr | name | ||
) |
Coordinates Config update and list data.
doc | The Tidy document. |
opt | The option the list item is intended for. |
name | The name of the new list item. |
void TY_❪FreeConfig❫ | ( | TidyDocImpl * | doc | ) |
Frees the configuration memory for the given Tidy document.
doc | The Tidy document. |
ctmbstr TY_❪getNextOptionPick❫ | ( | const TidyOptionImpl * | option, |
TidyIterator * | iter | ||
) |
Gets the next picklist possibility provided by the iterator.
option | The instance of the option for which to iterate a picklist. |
iter | The iterator token initialized by TY_(getOptionPickList)(). |
const TidyOptionImpl* TY_❪getNextOption❫ | ( | TidyDocImpl * | doc, |
TidyIterator * | iter | ||
) |
Gets the next option provided by the iterator.
doc | The Tidy document to get options. |
iter | The iterator token initialized by TY_(getOptionList)(). |
const Bool TY_❪getOptionIsList❫ | ( | TidyOptionId | optId | ) |
Given an option ID, indicates whether or not the option is a list.
optId | The option ID to check. |
TidyIterator TY_❪getOptionList❫ | ( | TidyDocImpl * | doc | ) |
Initiates an iterator to cycle through all of the available options.
doc | The Tidy document to get options. |
TidyIterator TY_❪getOptionPickList❫ | ( | const TidyOptionImpl * | option | ) |
Initiates an iterator to cycle through all of the available picklist possibilities.
option | An instance of an option for which to iterate a picklist. |
const TidyOptionImpl* TY_❪getOption❫ | ( | TidyOptionId | optId | ) |
Given an option ID, return an instance of an option.
optId | The option ID to retrieve. |
ctmbstr TY_❪GetPickListLabelForPick❫ | ( | TidyOptionId | optId, |
uint | pick | ||
) |
Gets the picklist label for a given value.
optId | the option id having a picklist to check. |
pick | the picklist item to retrieve. |
void TY_❪InitConfig❫ | ( | TidyDocImpl * | doc | ) |
Initialize the configuration for the given Tidy document.
doc | The Tidy document. |
const TidyOptionImpl* TY_❪lookupOption❫ | ( | ctmbstr | optnam | ) |
Given an option name, return an instance of an option.
optnam | The option name to retrieve. |
const TidyOptionDoc* TY_❪OptGetDocDesc❫ | ( | TidyOptionId | optId | ) |
Returns the cross-reference information structure for optID, which is used for generating documentation.
optId | The option ID to get cross-reference information for. |
Attempts to parse the given config file into the document, using the provided encoding.
doc | The Tidy document. |
cfgfil | The file to load. |
charenc | The name of the encoding to use for reading the file. |
int TY_❪ParseConfigFile❫ | ( | TidyDocImpl * | doc, |
ctmbstr | cfgfil | ||
) |
Attempts to parse the given config file into the document.
doc | The Tidy document. |
cfgfil | The file to load. |
Attempts to parse the provided value for the given option name.
Returns false if unknown option, missing parameter, or the option doesn't use the parameter.
doc | The Tidy document. |
optnam | The name of the option to be set. |
optVal | The string value to attempt to parse. |
Bool TY_❪ParseConfigValue❫ | ( | TidyDocImpl * | doc, |
TidyOptionId | optId, | ||
ctmbstr | optVal | ||
) |
Attempts to parse the provided value for the given option id.
Returns false if unknown option, missing parameter, or the option doesn't use the parameter.
doc | The Tidy document. |
optId | The ID of the option to be set. |
optVal | The string value to attempt to parse. |
void TY_❪ResetConfigToDefault❫ | ( | TidyDocImpl * | doc | ) |
Resets all options in the document to their default values.
doc | The Tidy document. |
void TY_❪ResetConfigToSnapshot❫ | ( | TidyDocImpl * | doc | ) |
Restores all of the configuration values to their snapshotted values.
doc | The Tidy document. |
Bool TY_❪ResetOptionToDefault❫ | ( | TidyDocImpl * | doc, |
TidyOptionId | optId | ||
) |
Resets the given option to its default value.
doc | The Tidy document. |
optId | The option ID to set. |
int TY_❪SaveConfigFile❫ | ( | TidyDocImpl * | doc, |
ctmbstr | cfgfil | ||
) |
Saves the current configuration for options not having default values into the specified file.
doc | The Tidy document. |
cfgfil | The file to save. |
int TY_❪SaveConfigSink❫ | ( | TidyDocImpl * | doc, |
TidyOutputSink * | sink | ||
) |
Writes the current configuration for options not having default values into the specified sink.
doc | The Tidy document. |
sink | The sink to save into. |
Bool TY_❪SetOptionBool❫ | ( | TidyDocImpl * | doc, |
TidyOptionId | optId, | ||
Bool | val | ||
) |
Sets the bool value for the given option Id.
doc | The Tidy document. |
optId | The option ID to set. |
val | The value to set. |
Bool TY_❪SetOptionInt❫ | ( | TidyDocImpl * | doc, |
TidyOptionId | optId, | ||
ulong | val | ||
) |
Sets the integer value for the given option Id.
doc | The Tidy document. |
optId | The option ID to set. |
val | The value to set. |
void TY_❪TakeConfigSnapshot❫ | ( | TidyDocImpl * | doc | ) |
Stores a snapshot of all of the configuration values that can be restored later.
doc | The Tidy document. |