#include <highlightstate.h>
Public Member Functions | |
| HighlightState (const std::string &e="normal") | |
| HighlightState (const HighlightState ©) | |
| Copies all the elements of the highlight state, except for the id: a new id will be used. | |
| void | addRule (HighlightRulePtr rule) |
| Adss a rule to this state. | |
| HighlightRulePtr | replaceRule (RuleList::size_type index, HighlightRulePtr rule) |
| Substitutes the rule at the specified position. | |
| unsigned int | getId () const |
| const RuleList & | getRuleList () const |
| const std::string & | getDefaultElement () const |
| void | setDefaultElement (const std::string &e) |
| bool | findBestMatch (const std::string &s, HighlightToken &token, const MatchingParameters ¶ms) const |
| Tries to find the rule that matches best (and first): the first rule with the smallest prefix and longest matching sequence. | |
| bool | findBestMatch (std::string::const_iterator start, std::string::const_iterator end, HighlightToken &token, const MatchingParameters ¶ms) const |
| Tries to find the rule that matches best (and first): the first rule with the smallest prefix and longest matching sequence. | |
| void | replaceReferences (const ReplacementList &rep) |
| Performs replacement of references in the rules of this state. | |
| bool | getNeedsReferenceReplacement () const |
| void | setNeedsReferenceReplacement (bool b=true) |
| HighlightStatePtr | getOriginalState () const |
| void | setOriginalState (HighlightStatePtr orig) |
Static Public Member Functions | |
| static bool | betterThan (const HighlightToken &t1, const HighlightToken &t2) |
| Whether t1 is better than t2: t1 has a non-longer prefix and a longer matching string (this makes sense only if a string was matched, and in fact this should be used only after having matched something). | |
Private Attributes | |
| const unsigned int | id |
| the identifier of the state | |
| std::string | defaultElement |
| the name of the element for strings when no rule matches (default: "normal") for states this should always be "normal" while for environments it should be the same element that represents the new state (e.g., "comment", "string", etc. | |
| RuleList | ruleList |
| the list of rules of this state | |
| bool | needsReferenceReplacement |
| whether one of the contained rules has dynamic references to be replaced | |
| HighlightStatePtr | originalState |
| In case this state is a copy of another state, in this field we store the original state. | |
Static Private Attributes | |
| static unsigned int | global_id = 1 |
| the global counter to assign unique state ids | |
)
| srchilite::HighlightState::HighlightState | ( | const std::string & | e = "normal" |
) |
| e | the element for strings when no rule matches (default: "normal") |
| srchilite::HighlightState::HighlightState | ( | const HighlightState & | copy | ) |
Copies all the elements of the highlight state, except for the id: a new id will be used.
| copy |
| void srchilite::HighlightState::addRule | ( | HighlightRulePtr | rule | ) |
Adss a rule to this state.
| rule | the rule to add at the end of the list |
| bool srchilite::HighlightState::betterThan | ( | const HighlightToken & | t1, | |
| const HighlightToken & | t2 | |||
| ) | [static] |
Whether t1 is better than t2: t1 has a non-longer prefix and a longer matching string (this makes sense only if a string was matched, and in fact this should be used only after having matched something).
| t1 | ||
| t2 |
| bool srchilite::HighlightState::findBestMatch | ( | std::string::const_iterator | start, | |
| std::string::const_iterator | end, | |||
| HighlightToken & | token, | |||
| const MatchingParameters & | params | |||
| ) | const |
Tries to find the rule that matches best (and first): the first rule with the smallest prefix and longest matching sequence.
| start | the beginning of the string for trying to match the rule | |
| end | the beginning of the string for trying to match the rule | |
| token | where results will be inserted, if the rule matched | |
| params | additional arguments for the matching |
| bool srchilite::HighlightState::findBestMatch | ( | const std::string & | s, | |
| HighlightToken & | token, | |||
| const MatchingParameters & | params | |||
| ) | const |
Tries to find the rule that matches best (and first): the first rule with the smallest prefix and longest matching sequence.
| s | the string for trying to match the rule | |
| token | where results will be inserted, if the rule matched | |
| params | additional arguments for the matching |
| void srchilite::HighlightState::replaceReferences | ( | const ReplacementList & | rep | ) |
Performs replacement of references in the rules of this state.
For each rule that needs replacement, it creates a copy of the rule.
| the | list of values for the replacement; the first element is the value for replacing the first dynamic back reference, and so on. (it should contain 9 possibly empty elements) |
| HighlightRulePtr srchilite::HighlightState::replaceRule | ( | RuleList::size_type | index, | |
| HighlightRulePtr | rule | |||
| ) |
Substitutes the rule at the specified position.
The rule must exit at the specified position.
| index | ||
| rule | the new rule |
std::string srchilite::HighlightState::defaultElement [private] |
the name of the element for strings when no rule matches (default: "normal") for states this should always be "normal" while for environments it should be the same element that represents the new state (e.g., "comment", "string", etc.
)
1.5.9