[glibmm/glibmm-2-64] Glib::Regex: Deprecate some uses of match() and match_all()



commit 6138969f34e83eddca34d2fea1857a7d061d69bf
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Mar 16 12:41:42 2020 +0100

    Glib::Regex: Deprecate some uses of match() and match_all()
    
    Deprecate use of rvalue string references, such as temporary values.
    
    See issue #66 and MR !26

 examples/regex/main.cc |  7 +++++--
 glib/src/regex.hg      | 10 ++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/examples/regex/main.cc b/examples/regex/main.cc
index 94fd059b..93f4f572 100644
--- a/examples/regex/main.cc
+++ b/examples/regex/main.cc
@@ -23,12 +23,15 @@ main(int, char**)
 {
   Glib::init();
 
+  Glib::ustring u_abcd = "abcd";
+  Glib::ustring u_1234 = "1234";
+
   /* Reusing one regex pattern: */
   const auto regex = Glib::Regex::create("(a)?(b)");
   std::cout << "Pattern=" << regex->get_pattern() << ", with string=abcd, result=" << std::boolalpha
-            << regex->match("abcd") << std::endl;
+            << regex->match(u_abcd) << std::endl;
   std::cout << "Pattern=" << regex->get_pattern() << ", with string=1234, result=" << std::boolalpha
-            << regex->match("1234") << std::endl;
+            << regex->match(u_1234) << std::endl;
   std::cout << std::endl;
 
   /* Using the static function without a regex instance: */
diff --git a/glib/src/regex.hg b/glib/src/regex.hg
index 514b990d..ea42792b 100644
--- a/glib/src/regex.hg
+++ b/glib/src/regex.hg
@@ -165,6 +165,11 @@ public:
    */
   bool match(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags 
match_options);
 
+#if defined(GLIBMM_DISABLE_DEPRECATED) || defined(DOXYGEN_SHOULD_SKIP_THIS)
+  /// @deprecated Disallow rvalue references, such as temporary values.
+  bool match(Glib::ustring&& string, ...) = delete;
+#endif // GLIBMM_DISABLE_DEPRECATED || DOXYGEN_SHOULD_SKIP_THIS
+
   _WRAP_METHOD_DOCS_ONLY(g_regex_match_all)
   bool match_all(
     const Glib::ustring& string,
@@ -205,6 +210,11 @@ public:
    */
   bool match_all(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags 
match_options);
 
+#if defined(GLIBMM_DISABLE_DEPRECATED) || defined(DOXYGEN_SHOULD_SKIP_THIS)
+  /// @deprecated Disallow rvalue references, such as temporary values.
+  bool match_all(Glib::ustring&& string, ...) = delete;
+#endif // GLIBMM_DISABLE_DEPRECATED || DOXYGEN_SHOULD_SKIP_THIS
+
 #m4 _CONVERSION(`gchar**',`Glib::StringArrayHandle',`Glib::StringArrayHandle($3, Glib::OWNERSHIP_DEEP)')
 
   _WRAP_METHOD(static Glib::StringArrayHandle split_simple(const Glib::ustring& pattern, const 
Glib::ustring& string, RegexCompileFlags compile_options = static_cast<RegexCompileFlags>(0), RegexMatchFlags 
match_options = static_cast<RegexMatchFlags>(0)), g_regex_split_simple)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]