source: trunk/lib/Trac.h @ 439

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

Merged patch release 0.6.1 to the trunk. Delta 0.6.1 - 0.6

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.3 KB
Line 
1#ifndef _theplu_svndigest_trac_
2#define _theplu_svndigest_trac_
3
4// $Id: Trac.h 439 2007-07-09 21:04:52Z peter $
5
6/*
7  Copyright (C) 2007 Peter Johansson
8
9  This file is part of svndigest, http://trac.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, size_t width);
50
51  private:
52    /**
53     */
54    std::string anchor_text(std::string::const_iterator first,
55                            std::string::const_iterator last,
56                            std::string::const_iterator last_trunc);
57    ///
58    /// @see changeset1 changeset2 changeset3
59    ///
60    /// @return true if any of changesetX returns true
61    ///
62    bool changeset(std::string::const_iterator& first, 
63                   const std::string::const_iterator& last,
64                   const std::string::const_iterator& last_trunc);
65
66    ///
67    /// \brief search for 'r123'
68    ///
69    /// Search in range [\a first, \a last) for expression
70    /// /r(\d+)/. If expression is found an anchor to
71    /// trac-root/changeset/123, displaying expression, and first is
72    /// pointing to character after expression.
73    ///
74    /// @return true if expression is found
75    ///
76    bool changeset1(std::string::const_iterator& first, 
77                    const std::string::const_iterator& last,
78                    const std::string::const_iterator& last_trunc);
79
80    ///
81    /// \brief search for '[123]'
82    ///
83    /// Search in range [\a first, \a last) for expression
84    /// /\[(\d+)\]/. If expression is found an anchor to
85    /// trac-root/changeset/123, displaying expression, and first is
86    /// pointing to character after expression.
87    ///
88    /// @return true if expression is found
89    ///
90    bool changeset2(std::string::const_iterator& first, 
91                    const std::string::const_iterator& last,
92                    const std::string::const_iterator& last_trunc);
93
94    ///
95    /// \brief search for changeset:123
96    ///
97    /// Search in range [\a first, \a last) for expression
98    /// /changeset:(\d+)/. If expression is found an anchor to
99    /// trac-root/changeset/123, displaying expression, and first is
100    /// pointing to character after expression.
101    ///
102    /// @return true if expression is found
103    ///
104    bool changeset3(std::string::const_iterator& first, 
105                    const std::string::const_iterator& last,
106                    const std::string::const_iterator& last_trunc);
107
108    ///
109    /// \brief search for /comment:ticket:123:1/
110    ///
111    /// Search in range [\a first, \a last) for expression
112    /// /comment:ticket:(\w+):(\d+)/. If expression is found an anchor
113    /// to trac-root/ticket/123#comment:1, displaying expression, and
114    /// first is pointing to character after expression.
115    ///
116    /// @return true if expression is found
117    ///
118    bool comment(std::string::const_iterator& first, 
119                 const std::string::const_iterator& last,
120                 const std::string::const_iterator& last_trunc);
121
122    ///
123    /// @see diff1 diff2 diff3
124    ///
125    /// @return true if any of diffX returns true
126    ///
127    bool diff(std::string::const_iterator& first, 
128              const std::string::const_iterator& last,
129              const std::string::const_iterator& last_trunc);
130
131    ///
132    /// \brief search for diff:trunk@12:123
133    ///
134    /// Search in range [\a first, \a last) for expression
135    /// /diff:(.*)@(\w+):(\w+)/. If expression is found an anchor is
136    /// created, displaying the expression, and first is pointing to
137    /// character after expression.
138    ///
139    /// If $1 (trunk) is empty anchor goes to
140    /// trac-root/changeset?new=123&old=12 otherwise it goes to
141    /// trac-root/changeset?new=123&newpath=trunk&old=12&oldpath=trunk
142    ///
143    /// @return true if expression is found
144    ///
145    bool diff1(std::string::const_iterator& first, 
146               const std::string::const_iterator& last,
147               const std::string::const_iterator& last_trunc);
148
149    ///
150    /// @brief search for diff:tags/1.0 or diff:tags/1.0//tags/1.0.1
151    ///
152    /// Search in range [\a first, \a last) for expression
153    /// /diff:(^\s+)/ or /diff:(^\s+)\/\/(^\s+)/. If expression is found
154    /// an anchor is created, displaying the expression, and first is
155    /// pointing to character after expression.
156    ///
157    /// The created anchor goes to
158    /// trac-root/changeset?new_path=tags/1.0&old_path=tags/1.0 or
159    /// trac-root/changeset?new_path=tags/1.0&old_path=tags/1.0.1
160    /// respectively.
161    ///
162    /// @return true if expression is found
163    ///
164    bool diff2(std::string::const_iterator& first, 
165               const std::string::const_iterator& last,
166               const std::string::const_iterator& last_trunc);
167
168    ///
169    /// @brief search for diff:tags/1.0@123//trunk@236
170    ///
171    /// Search in range [\a first, \a last) for expression
172    /// /diff:(^\s+)@(\w+)\/\/(^\s+)@(\w+)/. If expression is found an
173    /// anchor is created, displaying the expression, and first is
174    /// pointing to character after expression.
175    ///
176    /// The created anchor goes to
177    /// trac-root/changeset?new=236&new_path=trunk&old=123&old_path=tags/1.0
178    ///
179    /// @return true if expression is found
180    ///
181    bool diff3(std::string::const_iterator& first, 
182               const std::string::const_iterator& last,
183               const std::string::const_iterator& last_trunc);
184
185
186    ///
187    /// @see log1 log2 log3
188    ///
189    /// @return true if any of logX returns true
190    ///
191    bool log(std::string::const_iterator& first, 
192             const std::string::const_iterator& last,
193             const std::string::const_iterator& last_trunc);
194
195    ///
196    /// @brief search for r123:236
197    ///
198    /// Search in range [\a first, \a last) for expression
199    /// /r(\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 log1(std::string::const_iterator& first, 
208              const std::string::const_iterator& last,
209              const std::string::const_iterator& last_trunc);
210
211    ///
212    /// @brief search for [123:236]
213    ///
214    /// Search in range [\a first, \a last) for expression
215    /// /\[(\w+):(\w+)\]/. If expression is found an
216    /// anchor is created, displaying the expression, and first is
217    /// pointing to character after expression.
218    ///
219    /// The created anchor goes to trac-root/log/?rev=236&stop_rev=123
220    ///
221    /// @return true if expression is found
222    ///
223    bool log2(std::string::const_iterator& first, 
224              const std::string::const_iterator& last,
225              const std::string::const_iterator& last_trunc);
226
227    ///
228    /// @brief search for log:trunk@123:236 or log:trunk#123:236
229    ///
230    /// Search in range [\a first, \a last) for expression
231    /// /log:(^\s*)(@|#)(\w+):(\w+)/. If expression is found an
232    /// anchor is created, displaying the expression, and first is
233    /// pointing to character after expression.
234    ///
235    /// The created anchor goes to trac-root/log/trunk?rev=236&stop_rev=123
236    ///
237    /// @return true if expression is found
238    ///
239    bool log3(std::string::const_iterator& first, 
240              const std::string::const_iterator& last,
241              const std::string::const_iterator& last_trunc);
242
243    ///
244    /// @brief search for milestone:1.0
245    ///
246    /// Search in range [\a first, \a last) for expression
247    /// /milestone:(^s\*)\w/. If expression is found an
248    /// anchor is created, displaying the expression, and first is
249    /// pointing to character after expression.
250    ///
251    /// The created anchor goes to trac-root/milestone/1.0
252    ///
253    /// @return true if expression is found
254    ///
255    bool milestone(std::string::const_iterator& first, 
256                   const std::string::const_iterator& last,
257                   const std::string::const_iterator& last_trunc);
258
259    ///
260    /// @brief search for source:trunk or source:trunk@123 or
261    /// source:trunk@123#L3
262    ///
263    /// Search in range [\a first, \a last) for expression
264    /// /source:(^s\*)/, /source:(^s\*)@(\w+)/ or
265    /// /source:(^s\*)@(\w+)#L(\d+)/. If expression is found an anchor
266    /// is created, displaying the expression, and first is pointing
267    /// to character after expression.
268    ///
269    /// The created anchor goes to trac-root/browser/trunk or
270    /// trac-root/browser/trunk?rev=123 or
271    /// trac-root/browser/trunk?rev=123#L3
272    ///
273    /// @return true if expression is found
274    ///
275    bool source(std::string::const_iterator& first, 
276                const std::string::const_iterator& last,
277                const std::string::const_iterator& last_trunc);
278
279    ///
280    /// @see ticket1 ticket2
281    ///
282    /// @return true ticket1 or ticket2 returns true
283    ///
284    bool ticket(std::string::const_iterator& first, 
285                const std::string::const_iterator& last,
286                const std::string::const_iterator& last_trunc);
287
288    ///
289    /// @brief search for #65
290    ///
291    /// Search in range [\a first, \a last) for expression
292    /// /#(\d+)/. If expression is found an
293    /// anchor is created, displaying the expression, and first is
294    /// pointing to character after expression.
295    ///
296    /// The created anchor goes to trac-root/ticket/65
297    ///
298    /// @return true if expression is found
299    ///
300    bool ticket1(std::string::const_iterator& first, 
301                 const std::string::const_iterator& last,
302                 const std::string::const_iterator& last_trunc);
303
304    ///
305    /// @brief search for ticket:65
306    ///
307    /// Search in range [\a first, \a last) for expression
308    /// /ticket:(\d+)/. If expression is found an
309    /// anchor is created, displaying the expression, and first is
310    /// pointing to character after expression.
311    ///
312    /// The created anchor goes to trac-root/ticket/65
313    ///
314    /// @return true if expression is found
315    ///
316    bool ticket2(std::string::const_iterator& first, 
317                 const std::string::const_iterator& last,
318                 const std::string::const_iterator& last_trunc);
319
320
321
322    HtmlStream& hs_;
323  };
324
325}} // end of namespace svndigest end of namespace theplu
326
327#endif
Note: See TracBrowser for help on using the repository browser.