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 | |
TY_PRIVATE Bool | TY_❪AdjustCharEncoding❫ (TidyDocImpl *doc, int encoding) |
Ensure that char encodings are self consistent. More... | |
TY_PRIVATE void | TY_❪AdjustConfig❫ (TidyDocImpl *doc) |
Ensure that the configuration options are self consistent. More... | |
TY_PRIVATE int | TY_❪CharEncodingId❫ (TidyDocImpl *doc, ctmbstr charenc) |
Returns the character encoding ID for the given character encoding string. More... | |
TY_PRIVATE ctmbstr | TY_❪CharEncodingName❫ (int encoding) |
Returns the full name of the encoding for the given ID. More... | |
TY_PRIVATE ctmbstr | TY_❪CharEncodingOptName❫ (int encoding) |
Returns the Tidy command line option name of the encoding for the given ID. More... | |
TY_PRIVATE Bool | TY_❪ConfigDiffThanDefault❫ (TidyDocImpl *doc) |
Indicates whether or not the current configuration is completely default. More... | |
TY_PRIVATE Bool | TY_❪ConfigDiffThanSnapshot❫ (TidyDocImpl *doc) |
Indicates whether or not the current configuration is different from the stored snapshot. More... | |
TY_PRIVATE void | TY_❪CopyConfig❫ (TidyDocImpl *docTo, TidyDocImpl *docFrom) |
Copies the configuration from one document to another. More... | |
TY_PRIVATE void | TY_❪DeclareListItem❫ (TidyDocImpl *doc, const TidyOptionImpl *opt, ctmbstr name) |
Coordinates Config update and list data. More... | |
TY_PRIVATE void | TY_❪FreeConfig❫ (TidyDocImpl *doc) |
Frees the configuration memory for the given Tidy document. More... | |
TY_PRIVATE ctmbstr | TY_❪getNextOptionPick❫ (const TidyOptionImpl *option, TidyIterator *iter) |
Gets the next picklist possibility provided by the iterator. More... | |
TY_PRIVATE const TidyOptionImpl * | TY_❪getNextOption❫ (TidyDocImpl *doc, TidyIterator *iter) |
Gets the next option provided by the iterator. More... | |
TY_PRIVATE const Bool | TY_❪getOptionIsList❫ (TidyOptionId optId) |
Given an option ID, indicates whether or not the option is a list. More... | |
TY_PRIVATE TidyIterator | TY_❪getOptionList❫ (TidyDocImpl *doc) |
Initiates an iterator to cycle through all of the available options. More... | |
TY_PRIVATE TidyIterator | TY_❪getOptionPickList❫ (const TidyOptionImpl *option) |
Initiates an iterator to cycle through all of the available picklist possibilities. More... | |
TY_PRIVATE const TidyOptionImpl * | TY_❪getOption❫ (TidyOptionId optId) |
Given an option ID, return an instance of an option. More... | |
TY_PRIVATE ctmbstr | TY_❪GetPickListLabelForPick❫ (TidyOptionId optId, uint pick) |
Gets the picklist label for a given value. More... | |
TY_PRIVATE void | TY_❪InitConfig❫ (TidyDocImpl *doc) |
Initialize the configuration for the given Tidy document. More... | |
TY_PRIVATE const TidyOptionImpl * | TY_❪lookupOption❫ (ctmbstr optnam) |
Given an option name, return an instance of an option. More... | |
TY_PRIVATE const TidyOptionDoc * | TY_❪OptGetDocDesc❫ (TidyOptionId optId) |
Returns the cross-reference information structure for optID, which is used for generating documentation. More... | |
TY_PRIVATE int | TY_❪ParseConfigFileEnc❫ (TidyDocImpl *doc, ctmbstr cfgfil, ctmbstr charenc) |
Attempts to parse the given config file into the document, using the provided encoding. More... | |
TY_PRIVATE int | TY_❪ParseConfigFile❫ (TidyDocImpl *doc, ctmbstr cfgfil) |
Attempts to parse the given config file into the document. More... | |
TY_PRIVATE Bool | TY_❪ParseConfigOption❫ (TidyDocImpl *doc, ctmbstr optnam, ctmbstr optVal) |
Attempts to parse the provided value for the given option name. More... | |
TY_PRIVATE Bool | TY_❪ParseConfigValue❫ (TidyDocImpl *doc, TidyOptionId optId, ctmbstr optVal) |
Attempts to parse the provided value for the given option id. More... | |
TY_PRIVATE void | TY_❪ResetConfigToDefault❫ (TidyDocImpl *doc) |
Resets all options in the document to their default values. More... | |
TY_PRIVATE void | TY_❪ResetConfigToSnapshot❫ (TidyDocImpl *doc) |
Restores all of the configuration values to their snapshotted values. More... | |
TY_PRIVATE Bool | TY_❪ResetOptionToDefault❫ (TidyDocImpl *doc, TidyOptionId optId) |
Resets the given option to its default value. More... | |
TY_PRIVATE int | TY_❪SaveConfigFile❫ (TidyDocImpl *doc, ctmbstr cfgfil) |
Saves the current configuration for options not having default values into the specified file. More... | |
TY_PRIVATE int | TY_❪SaveConfigSink❫ (TidyDocImpl *doc, TidyOutputSink *sink) |
Writes the current configuration for options not having default values into the specified sink. More... | |
TY_PRIVATE Bool | TY_❪SetOptionBool❫ (TidyDocImpl *doc, TidyOptionId optId, Bool val) |
Sets the bool value for the given option Id. More... | |
TY_PRIVATE Bool | TY_❪SetOptionInt❫ (TidyDocImpl *doc, TidyOptionId optId, ulong val) |
Sets the integer value for the given option Id. More... | |
TY_PRIVATE 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.
TY_PRIVATE 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. |
TY_PRIVATE void TY_❪AdjustConfig❫ | ( | TidyDocImpl * | doc | ) |
Ensure that the configuration options are self consistent.
THIS PROCESS IS DESTRUCTIVE TO THE USER STATE. It examines certain user-specified options and changes other options as a result. This means that documented API functions such as tidyOptGetValue() won't return the user-set values after this is used. As a result, don't just use this function at every opportunity, but only where needed, which is ONLY prior to parsing a stream, and again prior to saving a stream (because we reset after parsing.)
doc | The Tidy document to adjust. |
TY_PRIVATE 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. |
TY_PRIVATE ctmbstr TY_❪CharEncodingName❫ | ( | int | encoding | ) |
Returns the full name of the encoding for the given ID.
encoding | The Id of the encoding. |
TY_PRIVATE 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. |
TY_PRIVATE Bool TY_❪ConfigDiffThanDefault❫ | ( | TidyDocImpl * | doc | ) |
Indicates whether or not the current configuration is completely default.
doc | The Tidy document. |
TY_PRIVATE Bool TY_❪ConfigDiffThanSnapshot❫ | ( | TidyDocImpl * | doc | ) |
Indicates whether or not the current configuration is different from the stored snapshot.
doc | The Tidy document. |
TY_PRIVATE 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. |
TY_PRIVATE 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. |
TY_PRIVATE void TY_❪FreeConfig❫ | ( | TidyDocImpl * | doc | ) |
Frees the configuration memory for the given Tidy document.
doc | The Tidy document. |
TY_PRIVATE 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)(). |
TY_PRIVATE 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)(). |
TY_PRIVATE 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. |
TY_PRIVATE TidyIterator TY_❪getOptionList❫ | ( | TidyDocImpl * | doc | ) |
Initiates an iterator to cycle through all of the available options.
doc | The Tidy document to get options. |
TY_PRIVATE 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. |
TY_PRIVATE const TidyOptionImpl* TY_❪getOption❫ | ( | TidyOptionId | optId | ) |
Given an option ID, return an instance of an option.
optId | The option ID to retrieve. |
TY_PRIVATE 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. |
TY_PRIVATE void TY_❪InitConfig❫ | ( | TidyDocImpl * | doc | ) |
Initialize the configuration for the given Tidy document.
doc | The Tidy document. |
TY_PRIVATE const TidyOptionImpl* TY_❪lookupOption❫ | ( | ctmbstr | optnam | ) |
Given an option name, return an instance of an option.
optnam | The option name to retrieve. |
TY_PRIVATE 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. |
TY_PRIVATE int TY_❪ParseConfigFileEnc❫ | ( | TidyDocImpl * | doc, |
ctmbstr | cfgfil, | ||
ctmbstr | charenc | ||
) |
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. |
TY_PRIVATE 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. |
TY_PRIVATE Bool TY_❪ParseConfigOption❫ | ( | TidyDocImpl * | doc, |
ctmbstr | optnam, | ||
ctmbstr | optVal | ||
) |
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. |
TY_PRIVATE 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. |
TY_PRIVATE void TY_❪ResetConfigToDefault❫ | ( | TidyDocImpl * | doc | ) |
Resets all options in the document to their default values.
doc | The Tidy document. |
TY_PRIVATE void TY_❪ResetConfigToSnapshot❫ | ( | TidyDocImpl * | doc | ) |
Restores all of the configuration values to their snapshotted values.
doc | The Tidy document. |
TY_PRIVATE 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. |
TY_PRIVATE 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. |
TY_PRIVATE 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. |
TY_PRIVATE 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. |
TY_PRIVATE 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. |
TY_PRIVATE void TY_❪TakeConfigSnapshot❫ | ( | TidyDocImpl * | doc | ) |
Stores a snapshot of all of the configuration values that can be restored later.
doc | The Tidy document. |