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 
15 namespace srchilite {
16 
18 
23 typedef std::list<std::pair<std::string, std::string> > MatchedElements;
24 
28 typedef std::vector<std::string> MatchedSubExps;
29 
35  std::string prefix;
36 
39 
41  std::string suffix;
42 
44  MatchedElements matched;
45 
48  unsigned int matchedSize;
49 
53  MatchedSubExps matchedSubExps;
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);
61  ~HighlightToken();
62 
67  void copyFrom(const HighlightToken &token) {
68  prefix = token.prefix;
69  suffix = token.suffix;
70  matched = token.matched;
71  matchedSize = token.matchedSize;
72  matchedSubExps = token.matchedSubExps;
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_*/
std::vector< std::string > MatchedSubExps
The matched subexpressions (if the original rule had subexpressions)
Definition: highlighttoken.h:28
bool prefixOnlySpaces
true if the prefix is empty or contains only spaces
Definition: highlighttoken.h:38
MatchedElements matched
the matched elements information
Definition: highlighttoken.h:44
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
const HighlightRule * rule
the matching rule
Definition: highlighttoken.h:56
std::string prefix
the possible prefix (part before the matched string)
Definition: highlighttoken.h:35
unsigned int matchedSize
the size of the whole matched sequence (this is computed automatically when matched elements are set ...
Definition: highlighttoken.h:48
void addMatched(const std::string &elem, const std::string &s)
Adds information about a matched element.
Definition: highlighttoken.cpp:32
Base class for highlight rules.
Definition: highlightrule.h:27
void clearMatched()
Resets the matched related fields (i.e., matched, matchedSize)
Definition: highlighttoken.cpp:37
Token containing information for performing the highlight.
Definition: highlighttoken.h:33
MatchedSubExps matchedSubExps
The matched subexpressions (in case the rule had subexpressions)
Definition: highlighttoken.h:53
std::string suffix
the possible suffix (part after the matched string)
Definition: highlighttoken.h:41
std::list< std::pair< std::string, std::string > > MatchedElements
The matched element information by a rule.
Definition: highlighttoken.h:17
void copyFrom(const HighlightToken &token)
Copy from the passed toke.
Definition: highlighttoken.h:67