Add wxRegEx::GetLibraryVersionInfo()
This allows to check the version of PCRE used.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#if wxUSE_REGEX
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/versioninfo.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
@@ -148,6 +149,9 @@ public:
|
||||
// return the extended RE corresponding to the given basic RE
|
||||
static wxString ConvertFromBasic(const wxString& bre);
|
||||
|
||||
// return version information for the underlying regex library
|
||||
static wxVersionInfo GetLibraryVersionInfo();
|
||||
|
||||
// dtor not virtual, don't derive from this class
|
||||
~wxRegEx();
|
||||
|
||||
|
@@ -360,5 +360,17 @@ public:
|
||||
@since 3.1.6
|
||||
*/
|
||||
static wxString ConvertFromBasic(const wxString& bre);
|
||||
|
||||
/**
|
||||
Return the version of PCRE used.
|
||||
|
||||
The returned wxVersionInfo object currently always has its micro
|
||||
version component set to 0, as PCRE uses only major and minor version
|
||||
components. Its description component contains the version number,
|
||||
release date and, for pre-release PCRE versions, a mention of it.
|
||||
|
||||
@since 3.1.6
|
||||
*/
|
||||
static wxVersionInfo GetLibraryVersionInfo();
|
||||
};
|
||||
|
||||
|
@@ -1494,4 +1494,13 @@ wxString wxRegEx::QuoteMeta(const wxString& str)
|
||||
return strEscaped;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxVersionInfo wxRegEx::GetLibraryVersionInfo()
|
||||
{
|
||||
wxRegChar buf[64];
|
||||
pcre2_config(PCRE2_CONFIG_VERSION, buf);
|
||||
|
||||
return wxVersionInfo("PCRE2", PCRE2_MAJOR, PCRE2_MINOR, 0, buf);
|
||||
}
|
||||
|
||||
#endif // wxUSE_REGEX
|
||||
|
@@ -196,4 +196,13 @@ TEST_CASE("wxRegEx::Unicode", "[regex][unicode]")
|
||||
CHECK( re.GetMatch(cyrillicSmallA) == cyrillicSmallA );
|
||||
}
|
||||
|
||||
// This pseudo test can be used just to see the version of PCRE being used.
|
||||
TEST_CASE("wxRegEx::GetLibraryVersionInfo", "[.]")
|
||||
{
|
||||
const wxVersionInfo ver = wxRegEx::GetLibraryVersionInfo();
|
||||
WARN("Using " << ver.GetName() << " " << ver.GetDescription()
|
||||
<< " (major=" << ver.GetMajor()
|
||||
<< ", minor=" << ver.GetMinor() << ")");
|
||||
}
|
||||
|
||||
#endif // wxUSE_REGEX
|
||||
|
Reference in New Issue
Block a user