~ubuntu-branches/ubuntu/oneiric/bombono-dvd/oneiric

« back to all changes in this revision

Viewing changes to src/mlib/regex.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101104114625-2tfaxma74eqggp5r
Tags: 0.8.0-0ubuntu1
* New upstream release (LP: #670193).
* Refresh 02_sparc.diff patch.
* Replace 05-boost_filesystem-link.patch with 05-fix_boost.patch, it fixes
  build failure with Boost <= 1.44.
* Bump Standards.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// mlib/regex.cpp
 
3
// This file is part of Bombono DVD project.
 
4
//
 
5
// Copyright (c) 2010 Ilya Murav'jov
 
6
//
 
7
// This program is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// This program is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with this program; if not, write to the Free Software
 
19
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
// 
 
21
 
 
22
#include "regex.h"
 
23
 
 
24
#include <boost/regex.hpp>
 
25
 
 
26
namespace re
 
27
{
 
28
 
 
29
//
 
30
// pattern
 
31
// 
 
32
struct pattern::impl: public boost::regex
 
33
{
 
34
    typedef boost::regex base_t;
 
35
 
 
36
    explicit impl(const char* p, flag_type f): base_t(p, f) {}
 
37
};
 
38
 
 
39
pattern::pattern(const char* p, flag_type f): pimpl_(new impl(p, f)) {}
 
40
 
 
41
pattern::~pattern() {}
 
42
 
 
43
//
 
44
// match_results
 
45
// 
 
46
struct match_results::impl: public boost::smatch
 
47
{
 
48
    typedef boost::smatch base_t;
 
49
};
 
50
 
 
51
match_results::match_results(): pimpl_(new impl) {}
 
52
 
 
53
match_results::~match_results() {}
 
54
 
 
55
match_results::size_type match_results::size() const
 
56
{
 
57
    return pimpl_->size();
 
58
}
 
59
 
 
60
sub_match match_results::operator[](int sub) const
 
61
{
 
62
    boost::smatch::const_reference pimpl_res = (*pimpl_)[sub];
 
63
 
 
64
    sub_match res;
 
65
    res.matched = pimpl_res.matched;
 
66
    res.first   = pimpl_res.first;
 
67
    res.second  = pimpl_res.second;
 
68
 
 
69
    return res;
 
70
}
 
71
 
 
72
//
 
73
// ~ boost::regex_match()
 
74
//
 
75
bool match(const std::string& s, 
 
76
           match_results& m, 
 
77
           const pattern& e, 
 
78
           match_flag_type flags)
 
79
{
 
80
    return boost::regex_match(s, *m.pimpl_, *e.pimpl_, flags);  
 
81
}
 
82
 
 
83
//
 
84
// ~ boost::regex_search()
 
85
//
 
86
bool search(const_iterator beg, const_iterator end, 
 
87
            match_results& m, 
 
88
            const pattern& e, 
 
89
            match_flag_type flags)
 
90
{
 
91
    return boost::regex_search(beg, end, *m.pimpl_, *e.pimpl_, flags);  
 
92
}
 
93
 
 
94
 
 
95
} // namespace re
 
96
 
 
97