Source-highlight Library
highlighttoken.h
1//
2// Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008
3//
4// Copyright: See COPYING file that comes with this distribution
5//
6
7#ifndef HIGHLIGHTTOKEN_H_
8#define HIGHLIGHTTOKEN_H_
9
10#include <string>
11#include <list>
12#include <vector>
13#include <algorithm>
14
15namespace srchilite {
16
17class HighlightRule;
18
23typedef std::list<std::pair<std::string, std::string> > MatchedElements;
24
28typedef std::vector<std::string> MatchedSubExps;
29
35 std::string prefix;
36
39
41 std::string suffix;
42
45
48 unsigned int matchedSize;
49
54
57
58 HighlightToken(const HighlightRule *_rule = 0);
59 HighlightToken(const std::string &elem, const std::string &matched,
60 const std::string &_prefix, const HighlightRule *_rule = 0);
62
67 void copyFrom(const HighlightToken &token) {
68 prefix = token.prefix;
69 suffix = token.suffix;
70 matched = token.matched;
73 rule = token.rule;
74 }
75
79 void clearMatched();
80
86 void addMatched(const std::string &elem, const std::string &s);
87};
88
89}
90
91#endif /*HIGHLIGHTTOKEN_H_*/
Base class for highlight rules.
Definition: highlightrule.h:27
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
std::list< std::pair< std::string, std::string > > MatchedElements
The matched element information by a rule.
Definition: highlighttoken.h:23
std::vector< std::string > MatchedSubExps
The matched subexpressions (if the original rule had subexpressions)
Definition: highlighttoken.h:28
Token containing information for performing the highlight.
Definition: highlighttoken.h:33
std::string prefix
the possible prefix (part before the matched string)
Definition: highlighttoken.h:35
MatchedSubExps matchedSubExps
The matched subexpressions (in case the rule had subexpressions)
Definition: highlighttoken.h:53
const HighlightRule * rule
the matching rule
Definition: highlighttoken.h:56
unsigned int matchedSize
the size of the whole matched sequence (this is computed automatically when matched elements are set ...
Definition: highlighttoken.h:48
std::string suffix
the possible suffix (part after the matched string)
Definition: highlighttoken.h:41
void copyFrom(const HighlightToken &token)
Copy from the passed toke.
Definition: highlighttoken.h:67
void addMatched(const std::string &elem, const std::string &s)
Adds information about a matched element.
Definition: highlighttoken.cpp:32
MatchedElements matched
the matched elements information
Definition: highlighttoken.h:44
bool prefixOnlySpaces
true if the prefix is empty or contains only spaces
Definition: highlighttoken.h:38
void clearMatched()
Resets the matched related fields (i.e., matched, matchedSize)
Definition: highlighttoken.cpp:37