Changeset 290 for trunk


Ignore:
Timestamp:
May 8, 2007, 3:34:58 PM (14 years ago)
Author:
Peter Johansson
Message:

added suppport for links of type ticket:180 refs #180

Location:
trunk/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Trac.cc

    r289 r290  
    5353                    const std::string::const_iterator& last)
    5454  {
     55    if (ticket1(first, last))
     56      return true;
     57    if (ticket2(first, last))
     58      return true;
     59    return false;
     60  }
     61
     62
     63  bool Trac::ticket1(std::string::const_iterator& first,
     64                     const std::string::const_iterator& last)
     65  {
    5566    if (first==last)
    5667      return false;
     
    6677      return false;
    6778    }
     79
     80    const Configuration& conf = Configuration::instance();
     81    hs_.stream() << anchor(conf.trac_root()+"ticket/"+ticket,"#"+ticket);
     82    return true;
     83  }
     84
     85
     86  bool Trac::ticket2(std::string::const_iterator& first,
     87                     const std::string::const_iterator& last)
     88  {
     89    if (first==last)
     90      return false;
     91
     92    const std::string::const_iterator first_orig(first);
     93
     94    if (match(first, last, "ticket:").empty()){
     95      first = first_orig;
     96      return false;
     97    }
     98     
     99    std::string ticket = match(first, last, Digit());
    68100
    69101    const Configuration& conf = Configuration::instance();
  • trunk/lib/Trac.h

    r288 r290  
    6565                const std::string::const_iterator& last);
    6666
     67    bool ticket(std::string::const_iterator& first,
     68                const std::string::const_iterator& last);
     69
    6770    /// if range (first, last) starts with /#[:digit:]*/ a ticket link
    6871    /// is written;
    6972    /// @return if ticket is found iterator pointing to after found
    7073    /// ticket; else first is returned.
    71     bool ticket(std::string::const_iterator& first,
    72                 const std::string::const_iterator& last);
     74    bool ticket1(std::string::const_iterator& first,
     75                 const std::string::const_iterator& last);
     76
     77    bool ticket2(std::string::const_iterator& first,
     78                 const std::string::const_iterator& last);
     79
    7380
    7481
  • trunk/lib/utility.cc

    r289 r290  
    111111
    112112
     113  std::string match(std::string::const_iterator& first,
     114                    const std::string::const_iterator& last,
     115                    const char* c)
     116  {
     117    std::string str(c);
     118    if (match_begin(first, last, str)) {
     119      first += str.size();
     120      return str;
     121    }
     122    return std::string();
     123  }
     124
     125
    113126  bool node_exist(const std::string& path)
    114127  {
  • trunk/lib/utility.h

    r289 r290  
    133133  inline std::string trim(std::string str) { return htrim(ltrim(str)); }
    134134
     135
     136  std::string match(std::string::const_iterator& first,
     137                    const std::string::const_iterator& last,
     138                    const char*);
    135139
    136140  template <class T>
Note: See TracChangeset for help on using the changeset viewer.