source: trunk/lib/Trac.h @ 309

Last change on this file since 309 was 309, checked in by Peter Johansson, 14 years ago

added test for Trac class. fixes #189

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.2 KB
Line 
1#ifndef _theplu_svndigest_trac_
2#define _theplu_svndigest_trac_
3
4// $Id: Trac.h 309 2007-05-12 13:26:38Z peter $
5
6/*
7  Copyright (C) 2007 Peter Johansson
8
9  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
10
11  svndigest is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 2 of the License, or
14  (at your option) any later version.
15
16  svndigest is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
27#include <string>
28
29namespace theplu{
30namespace svndigest{
31
32  class HtmlStream;
33
34  ///
35  /// Class responsible for filtering log messages and detect
36  /// trac:links and create appropriate anchors.
37  ///
38  class Trac
39  {
40  public:
41    ///
42    /// \Constructor
43    ///
44    Trac(HtmlStream& html);
45   
46    ///
47    ///
48    ///
49    void print(std::string str);
50
51  private:
52    ///
53    /// @see changeset1 changeset2 changeset3
54    ///
55    /// @return true if any of changesetX returns true
56    ///
57    bool changeset(std::string::const_iterator& first, 
58                   const std::string::const_iterator& last);
59
60    ///
61    /// \brief search for 'r123'
62    ///
63    /// Search in range [\a first, \a last) for expression
64    /// /r(\d+)/. If expression is found an anchor to
65    /// trac-root/changeset/123, displaying expression, and first is
66    /// pointing to character after expression.
67    ///
68    /// @return true if expression is found
69    ///
70    bool changeset1(std::string::const_iterator& first, 
71                   const std::string::const_iterator& last);
72
73    ///
74    /// \brief search for '[123]'
75    ///
76    /// Search in range [\a first, \a last) for expression
77    /// /\[(\d+)\]/. If expression is found an anchor to
78    /// trac-root/changeset/123, displaying expression, and first is
79    /// pointing to character after expression.
80    ///
81    /// @return true if expression is found
82    ///
83    bool changeset2(std::string::const_iterator& first, 
84                   const std::string::const_iterator& last);
85
86    ///
87    /// \brief search for changeset:123
88    ///
89    /// Search in range [\a first, \a last) for expression
90    /// /changeset:(\d+)/. If expression is found an anchor to
91    /// trac-root/changeset/123, displaying expression, and first is
92    /// pointing to character after expression.
93    ///
94    /// @return true if expression is found
95    ///
96    bool changeset3(std::string::const_iterator& first, 
97                   const std::string::const_iterator& last);
98
99    ///
100    /// \brief search for /comment:ticket:123:1/
101    ///
102    /// Search in range [\a first, \a last) for expression
103    /// /comment:ticket:(\w+):(\d+)/. If expression is found an anchor
104    /// to trac-root/ticket/123#comment:1, displaying expression, and
105    /// first is pointing to character after expression.
106    ///
107    /// @return true if expression is found
108    ///
109    bool comment(std::string::const_iterator& first, 
110                 const std::string::const_iterator& last);
111
112    ///
113    /// @see diff1 diff2 diff3
114    ///
115    /// @return true if any of diffX returns true
116    ///
117    bool diff(std::string::const_iterator& first, 
118              const std::string::const_iterator& last);
119
120    ///
121    /// \brief search for diff:trunk@12:123
122    ///
123    /// Search in range [\a first, \a last) for expression
124    /// /diff:(.*)@(\w+):(\w+)/. If expression is found an anchor is
125    /// created, displaying the expression, and first is pointing to
126    /// character after expression.
127    ///
128    /// If $1 (trunk) is empty anchor goes to
129    /// trac-root/changeset?new=123&old=12 otherwise it goes to
130    /// trac-root/changeset?new=123&newpath=trunk&old=12&oldpath=trunk
131    ///
132    /// @return true if expression is found
133    ///
134    bool diff1(std::string::const_iterator& first, 
135               const std::string::const_iterator& last);
136
137    ///
138    /// @brief search for diff:tags/1.0 or diff:tags/1.0//tags/1.0.1
139    ///
140    /// Search in range [\a first, \a last) for expression
141    /// /diff:(^\s+)/ or /diff:(^\s+)\/\/(^\s+)/. If expression is found
142    /// an anchor is created, displaying the expression, and first is
143    /// pointing to character after expression.
144    ///
145    /// The created anchor goes to
146    /// trac-root/changeset?new_path=tags/1.0&old_path=tags/1.0 or
147    /// trac-root/changeset?new_path=tags/1.0&old_path=tags/1.0.1
148    /// respectively.
149    ///
150    /// @return true if expression is found
151    ///
152    bool diff2(std::string::const_iterator& first, 
153               const std::string::const_iterator& last);
154
155    ///
156    /// @brief search for diff:tags/1.0@123//trunk@236
157    ///
158    /// Search in range [\a first, \a last) for expression
159    /// /diff:(^\s+)@(\w+)\/\/(^\s+)@(\w+)/. If expression is found an
160    /// anchor is created, displaying the expression, and first is
161    /// pointing to character after expression.
162    ///
163    /// The created anchor goes to
164    /// trac-root/changeset?new=236&new_path=trunk&old=123&old_path=tags/1.0
165    ///
166    /// @return true if expression is found
167    ///
168    bool diff3(std::string::const_iterator& first, 
169               const std::string::const_iterator& last);
170
171
172    ///
173    /// @see log1 log2 log3
174    ///
175    /// @return true if any of logX returns true
176    ///
177    bool log(std::string::const_iterator& first, 
178             const std::string::const_iterator& last);
179
180    ///
181    /// @brief search for r123:236
182    ///
183    /// Search in range [\a first, \a last) for expression
184    /// /r(\w+):(\w+)/. If expression is found an
185    /// anchor is created, displaying the expression, and first is
186    /// pointing to character after expression.
187    ///
188    /// The created anchor goes to trac-root/log/?rev=236&stop_rev=123
189    ///
190    /// @return true if expression is found
191    ///
192    bool log1(std::string::const_iterator& first, 
193              const std::string::const_iterator& last);
194
195    ///
196    /// @brief search for [123:236]
197    ///
198    /// Search in range [\a first, \a last) for expression
199    /// /\[(\w+):(\w+)\]/. If expression is found an
200    /// anchor is created, displaying the expression, and first is
201    /// pointing to character after expression.
202    ///
203    /// The created anchor goes to trac-root/log/?rev=236&stop_rev=123
204    ///
205    /// @return true if expression is found
206    ///
207    bool log2(std::string::const_iterator& first, 
208              const std::string::const_iterator& last);
209
210    ///
211    /// @brief search for log:trunk@123:236 or log:trunk#123:236
212    ///
213    /// Search in range [\a first, \a last) for expression
214    /// /log:(^\s*)(@|#)(\w+):(\w+)/. If expression is found an
215    /// anchor is created, displaying the expression, and first is
216    /// pointing to character after expression.
217    ///
218    /// The created anchor goes to trac-root/log/trunk?rev=236&stop_rev=123
219    ///
220    /// @return true if expression is found
221    ///
222    bool log3(std::string::const_iterator& first, 
223              const std::string::const_iterator& last);
224
225    ///
226    /// @brief search for milestone:1.0
227    ///
228    /// Search in range [\a first, \a last) for expression
229    /// /milestone:(^s\*)\w/. If expression is found an
230    /// anchor is created, displaying the expression, and first is
231    /// pointing to character after expression.
232    ///
233    /// The created anchor goes to trac-root/milestone/1.0
234    ///
235    /// @return true if expression is found
236    ///
237    bool milestone(std::string::const_iterator& first, 
238                   const std::string::const_iterator& last);
239
240    ///
241    /// @brief search for source:trunk or source:trunk@123 or
242    /// source:trunk@123#L3
243    ///
244    /// Search in range [\a first, \a last) for expression
245    /// /source:(^s\*)/, /source:(^s\*)@(\w+)/ or
246    /// /source:(^s\*)@(\w+)#L(\d+)/. If expression is found an anchor
247    /// is created, displaying the expression, and first is pointing
248    /// to character after expression.
249    ///
250    /// The created anchor goes to trac-root/browser/trunk or
251    /// trac-root/browser/trunk?rev=123 or
252    /// trac-root/browser/trunk?rev=123#L3
253    ///
254    /// @return true if expression is found
255    ///
256    bool source(std::string::const_iterator& first, 
257                const std::string::const_iterator& last);
258
259    ///
260    /// @see ticket1 ticket2
261    ///
262    /// @return true ticket1 or ticket2 returns true
263    ///
264    bool ticket(std::string::const_iterator& first, 
265                const std::string::const_iterator& last);
266
267    ///
268    /// @brief search for #65
269    ///
270    /// Search in range [\a first, \a last) for expression
271    /// /#(\d+)/. If expression is found an
272    /// anchor is created, displaying the expression, and first is
273    /// pointing to character after expression.
274    ///
275    /// The created anchor goes to trac-root/ticket/65
276    ///
277    /// @return true if expression is found
278    ///
279    bool ticket1(std::string::const_iterator& first, 
280                 const std::string::const_iterator& last);
281
282    ///
283    /// @brief search for ticket:65
284    ///
285    /// Search in range [\a first, \a last) for expression
286    /// /ticket:(\d+)/. If expression is found an
287    /// anchor is created, displaying the expression, and first is
288    /// pointing to character after expression.
289    ///
290    /// The created anchor goes to trac-root/ticket/65
291    ///
292    /// @return true if expression is found
293    ///
294    bool ticket2(std::string::const_iterator& first, 
295                 const std::string::const_iterator& last);
296
297
298
299    HtmlStream& hs_;
300  };
301
302}} // end of namespace svndigest end of namespace theplu
303
304#endif
Note: See TracBrowser for help on using the repository browser.