1 /* pattern.cc
2 *
3 * Copyright (C) 2002 The gtkmm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <glib.h>
20 #include <glibmm/pattern.h>
21
22 namespace Glib
23 {
24
PatternSpec(const Glib::ustring & pattern)25 PatternSpec::PatternSpec(const Glib::ustring& pattern)
26 : gobject_(g_pattern_spec_new(pattern.c_str()))
27 {
28 }
29
PatternSpec(GPatternSpec * gobject)30 PatternSpec::PatternSpec(GPatternSpec* gobject) : gobject_(gobject)
31 {
32 }
33
~PatternSpec()34 PatternSpec::~PatternSpec() noexcept
35 {
36 g_pattern_spec_free(gobject_);
37 }
38
39 bool
match(const Glib::ustring & str) const40 PatternSpec::match(const Glib::ustring& str) const
41 {
42 return g_pattern_match(gobject_, str.bytes(), str.c_str(), nullptr);
43 }
44
45 bool
match(const Glib::ustring & str,const Glib::ustring & str_reversed) const46 PatternSpec::match(const Glib::ustring& str, const Glib::ustring& str_reversed) const
47 {
48 return g_pattern_match(gobject_, str.bytes(), str.c_str(), str_reversed.c_str());
49 }
50
51 bool
operator ==(const PatternSpec & rhs) const52 PatternSpec::operator==(const PatternSpec& rhs) const
53 {
54 return g_pattern_spec_equal(gobject_, rhs.gobject_);
55 }
56
57 bool
operator !=(const PatternSpec & rhs) const58 PatternSpec::operator!=(const PatternSpec& rhs) const
59 {
60 return !g_pattern_spec_equal(gobject_, rhs.gobject_);
61 }
62
63 } // namespace Glib
64