summaryrefslogtreecommitdiff
path: root/examples/regex
diff options
context:
space:
mode:
authorDaniel Elstner <daniel@src.gnome.org>2009-03-23 11:58:58 +0000
committerDaniel Elstner <daniel@src.gnome.org>2009-03-23 11:58:58 +0000
commiteeb95c593ba5176800abb0c123f23731aad3e906 (patch)
treeacf14b034661336b7f6b9a1c7ecaf0c3152fc577 /examples/regex
parent1a3809efbe08c181b27d9642591919a007178ad0 (diff)
downloadglibmm-eeb95c593ba5176800abb0c123f23731aad3e906.tar.gz
Fix --disable-api-exceptions build
* glib/src/keyfile.{ccg,hg}: Conditionalize all exception-handling code in order to fix the build with --disable-api-exceptions. * glib/src/regex.hg: ditto, * gio/src/appinfo.ccg: ditto, * gio/src/file.{ccg,hg}: ditto, * gio/src/outputstream.ccg: ditto, * examples/keyfile/main.cc: ditto, * examples/regex/main.cc: ditto, * tests/giomm_ioerror/main.cc: ditto, * tests/giomm_simple/main.cc: ditto. svn path=/trunk/; revision=803
Diffstat (limited to 'examples/regex')
-rw-r--r--examples/regex/main.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/examples/regex/main.cc b/examples/regex/main.cc
index ff9861de..6873f81d 100644
--- a/examples/regex/main.cc
+++ b/examples/regex/main.cc
@@ -17,31 +17,35 @@
#include <glibmm.h>
#include <iostream>
+#include <iomanip>
-Glib::ustring bool_text (bool val)
-{
- return val ? "true" : "false";
-}
-
-int main(int argc, char** argv)
+int main(int, char**)
{
Glib::init();
-
- /* Reusing one regex pattern: */
- Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create ("(a)?(b)");
+
+ /* Reusing one regex pattern: */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(a)?(b)");
+#else
+ std::auto_ptr<Glib::Error> error;
+ Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(a)?(b)",
+ Glib::RegexCompileFlags(),
+ Glib::RegexMatchFlags(),
+ error);
+#endif
std::cout << "Pattern=" << regex->get_pattern()
<< ", with string=abcd, result="
- << bool_text( regex->match("abcd") )
+ << std::boolalpha << regex->match("abcd")
<< std::endl;
std::cout << "Pattern=" << regex->get_pattern()
<< ", with string=1234, result="
- << bool_text( regex->match("1234") )
+ << std::boolalpha << 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::boolalpha << Glib::Regex::match_simple("b*", "abcd")
<< std::endl;
return 0;