Source-highlight Library
|
00001 // 00002 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008 00003 // 00004 // Copyright: See COPYING file that comes with this distribution 00005 // 00006 00007 #ifndef HIGHLIGHTTOKEN_H_ 00008 #define HIGHLIGHTTOKEN_H_ 00009 00010 #include <string> 00011 #include <list> 00012 #include <vector> 00013 #include <algorithm> 00014 00015 namespace srchilite { 00016 00017 class HighlightRule; 00018 00023 typedef std::list<std::pair<std::string, std::string> > MatchedElements; 00024 00028 typedef std::vector<std::string> MatchedSubExps; 00029 00033 struct HighlightToken { 00035 std::string prefix; 00036 00038 bool prefixOnlySpaces; 00039 00041 std::string suffix; 00042 00044 MatchedElements matched; 00045 00048 unsigned int matchedSize; 00049 00053 MatchedSubExps matchedSubExps; 00054 00056 const HighlightRule *rule; 00057 00058 HighlightToken(const HighlightRule *_rule = 0); 00059 HighlightToken(const std::string &elem, const std::string &matched, 00060 const std::string &_prefix, const HighlightRule *_rule = 0); 00061 ~HighlightToken(); 00062 00067 void copyFrom(const HighlightToken &token) { 00068 prefix = token.prefix; 00069 suffix = token.suffix; 00070 matched = token.matched; 00071 matchedSize = token.matchedSize; 00072 matchedSubExps = token.matchedSubExps; 00073 rule = token.rule; 00074 } 00075 00079 void clearMatched(); 00080 00086 void addMatched(const std::string &elem, const std::string &s); 00087 }; 00088 00089 } 00090 00091 #endif /*HIGHLIGHTTOKEN_H_*/