source: trunk/lib/Trac.cc @ 288

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

declaring more functions in Trac class. refs #178 and #180.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1// $Id: Trac.cc 288 2007-05-07 16:22:33Z peter $
2
3/*
4  Copyright (C) 2007 Peter Johansson
5
6  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "Trac.h"
25
26#include "Configuration.h"
27#include "HtmlStream.h"
28#include "html_utility.h"
29
30namespace theplu{
31namespace svndigest{
32
33  Trac::Trac(HtmlStream& hs)
34    : hs_(hs) 
35  {}
36
37  void Trac::print(std::string str)
38  {
39    std::string::const_iterator first(str.begin());
40    while (first!=str.end()) {
41      if (log(first, str.end()))
42        continue;
43      if (ticket(first, str.end()))
44        continue;
45      hs_ << *first;
46      ++first;
47    }
48  }
49
50
51  bool Trac::ticket(std::string::const_iterator& first, 
52                    const std::string::const_iterator& last)
53  {
54    if (first==last)
55      return false;
56
57    const std::string::const_iterator first_orig(first);
58    if (*first != '#')
59      return false;
60    ++first;
61    std::string ticket;
62    for (;first!=last && isdigit(*first); ++first) 
63      ticket.append(1,*first);
64
65    if (ticket.empty())
66      return false;
67
68    Configuration* conf = Configuration::instance();
69    hs_.stream() << anchor(conf->trac_ticket()+ticket,"#"+ticket); 
70    return true;
71  }
72
73
74  bool Trac::log(std::string::const_iterator& first, 
75                 const std::string::const_iterator& last)
76  {
77    if (first==last)
78      return false;
79
80    const std::string::const_iterator first_orig(first);
81    if (*first != '#')
82      return false;
83    ++first;
84    std::string ticket;
85    for (;first!=last && isdigit(*first); ++first) 
86      ticket.append(1,*first);
87
88    if (ticket.empty())
89      return false;
90
91    Configuration* conf = Configuration::instance();
92    hs_.stream() << anchor(conf->trac_ticket()+ticket,"#"+ticket); 
93    return true;
94  }
95
96}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.