diff options
author | Murray Cumming <murrayc@murrayc.com> | 2007-06-22 14:43:53 +0000 |
---|---|---|
committer | Murray Cumming <murrayc@src.gnome.org> | 2007-06-22 14:43:53 +0000 |
commit | c72439e0d5963fd6200283a906b32300f2ab65b6 (patch) | |
tree | 3e3282e4d1b8ddc6384ff43e1b8f124584090a01 /examples | |
parent | fdba92ddd4221df38d48677063af8d1de5939e5a (diff) | |
download | glibmm-c72439e0d5963fd6200283a906b32300f2ab65b6.tar.gz |
Added a create() method, and added some more default parameter values to
2007-06-22 Murray Cumming <murrayc@murrayc.com>
* glib/src/regex.ccg:
* glib/src/regex.hg: Added a create() method, and added some
more default parameter values to the methods.
* configure.in:
* examples/Makefile.am:
* examples/regex/main.cc: Added a very simple example.
* glib/glibmm/value_custom.h: Put header guards around this, though
this should never be included directly anyway.
svn path=/trunk/; revision=419
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 2 | ||||
-rw-r--r-- | examples/regex/Makefile.am | 6 | ||||
-rw-r--r-- | examples/regex/main.cc | 49 |
3 files changed, 56 insertions, 1 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index 79d9c73a..02679415 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1,4 @@ -example_dirs = markup options thread iochannel_stream child_watch +example_dirs = markup options thread iochannel_stream child_watch regex # These use gtkmm stuff: # thread diff --git a/examples/regex/Makefile.am b/examples/regex/Makefile.am new file mode 100644 index 00000000..0c79f50b --- /dev/null +++ b/examples/regex/Makefile.am @@ -0,0 +1,6 @@ +include $(top_srcdir)/examples/Makefile.am_fragment + +#Build the executable, but don't install it. +noinst_PROGRAMS = example +example_SOURCES = main.cc + diff --git a/examples/regex/main.cc b/examples/regex/main.cc new file mode 100644 index 00000000..c5c5e24d --- /dev/null +++ b/examples/regex/main.cc @@ -0,0 +1,49 @@ +/* Copyright (C) 2004 The glibmm Development Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <glibmm.h> +#include <iostream> + +Glib::ustring bool_text (bool val) +{ + return val ? "true" : "false"; +} + +int main(int argc, char** argv) +{ + Glib::init(); + + /* Reusing one regex pattern: */ + Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create ("(a)?(b)"); + std::cout << "Pattern=" << regex->get_pattern() + << ", with string=abcd, result=" + << bool_text( regex->match("abcd") ) + << std::endl; + std::cout << "Pattern=" << regex->get_pattern() + << ", with string=1234, result=" + << bool_text( regex->match("1234") ) + << std::endl; + std::cout << std::endl; + + /* Using the static function without a regex instance: */ + std::cout << "Pattern=b* with string=abcd, result=" + << bool_text( Glib::Regex::match_simple("b*", "abcd") ) + << std::endl; + + return 0; +} + |