RE: [Boost-users] regular expression searching for Glib::ustring??
Paul Elliott
I am using Gtkmm. I want to do boost regular expression searching on Glib::ustring.
http://www.gtkmm.org/gtkmm2/docs/reference/html/classGlib_1_1ustring.htm l
This class represents characters in UTF-8, so each character in the buffer is represented by a varriable number of bytes. But it does have a bidirectional iterator.
How would you set up boost regex to search if both the regular expression and the string to be searched is a ustring?
Does one need to override any of the types defiened in regex_traits?
The character type should be gunichar.
Thank you.
BTW. Quote from:http://www.boost.org/libs/regex/doc/regex_traits.html
"Under construction. The current boost.regex traits class design will be migrated to that specified in the regular expression standardization proposal."
This is not very useful to someone trying to use the boost_regex library now!
I am using Boost 1.30, in which the traits are documented in
On Thu, Mar 18, 2004 at 04:08:59PM -0000, Ben Hutchings wrote:
Paul Elliott
wrote: I am using Gtkmm. I want to do boost regular expression searching on Glib::ustring.
http://www.gtkmm.org/gtkmm2/docs/reference/html/classGlib_1_1ustring.htm l
This class represents characters in UTF-8, so each character in the buffer is represented by a varriable number of bytes. But it does have a bidirectional iterator.
How would you set up boost regex to search if both the regular expression and the string to be searched is a ustring?
Does one need to override any of the types defiened in regex_traits?
The character type should be gunichar.
I am using Boost 1.30, in which the traits are documented in
. I don't know whether that documentation still applies to 1.31. You don't necessarily need custom traits to use custom iterator types. However, you do need to define custom traits to make character classes, case folding and so on work for all Unicode characters.
To create a regex from a ustring I would write something like this:
boost::reg_expression
re;
In the above, you have unicode_regex_traits, which is necessary
because when I tried:
boost::basic_regex<gunichar> regular_expression;
I got the following error message:
err>In file included from gmore.hh:6,
err> from peless.cc:6:
err>search.hh: In instantiation of `boost::regex_traits<gunichar>':
err>search.hh:30: instantiated from here
err>search.hh:30: error: base class `boost::c_regex_traits<gunichar>' has
err> incomplete type
err>/usr/include/boost-1_31/boost/regex/v4/basic_regex.hpp: In instantiation of `boost::reg_expression
participants (2)
-
Ben Hutchings
-
Paul Elliott