|
Boost Users : |
From: Paul Elliott (pelliott_at_[hidden])
Date: 2004-03-18 18:35:32
On Thu, Mar 18, 2004 at 04:08:59PM -0000, Ben Hutchings wrote:
> Paul Elliott <pelliott_at_[hidden]> 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
> <boost/libs/regex/traits_class_ref.htm>. 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<gunichar, unicode_regex_traits> 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<gunichar, boost::regex_traits<gunichar>, std::allocator<size_t> >':
err>search.hh:60: instantiated from `boost::basic_regex<gunichar, boost::regex_traits<gunichar>, std::allocator<size_t> >'
err>search.hh:60: instantiated from here
err>/usr/include/boost-1_31/boost/regex/v4/basic_regex.hpp:48: error: no type named
err> `size_type' in `class boost::regex_traits<gunichar>'
err>/usr/include/boost-1_31/boost/regex/v4/basic_regex.hpp:49: error: no type named
err> `uchar_type' in `class boost::regex_traits<gunichar>'
err>/usr/include/boost-1_31/boost/regex/v4/basic_regex.hpp:50: error: no type named
err> `string_type' in `class boost::regex_traits<gunichar>'
err>/usr/include/boost-1_31/boost/regex/v4/basic_regex.hpp: In instantiation of `boost::reg_expression<gunichar, boost::regex_traits<gunichar>, std::allocator<size_t> >':
err>search.hh:60: instantiated from `boost::basic_regex<gunichar, boost::regex_traits<gunichar>, std::allocator<size_t> >'
err>search.hh:60: instantiated from here
err>/usr/include/boost-1_31/boost/regex/v4/basic_regex.hpp:67: error: no type named
err> `locale_type' in `class boost::regex_traits<gunichar>'
err>/usr/include/boost-1_31/boost/regex/v4/basic_regex.hpp:178: error: no type
err> named `locale_type' in `class boost::regex_traits<gunichar>'
err>/usr/include/boost-1_31/boost/regex/v4/basic_regex.hpp:179: error: no type
err> named `locale_type' in `class boost::regex_traits<gunichar>'
err>/usr/include/boost-1_31/boost/regex/v4/regex_compile.hpp: In instantiation of `boost::reg_expression<gunichar, boost::regex_traits<gunichar>, std::allocator<size_t> >':
err>search.hh:60: instantiated from `boost::basic_regex<gunichar, boost::regex_traits<gunichar>, std::allocator<size_t> >'
err>search.hh:60: instantiated from here
err>/usr/include/boost-1_31/boost/regex/v4/regex_compile.hpp:1137: error: no type
err> named `string_type' in `class boost::regex_traits<gunichar>'
err>/usr/include/boost-1_31/boost/regex/v4/regex_compile.hpp:1054: error: no type
err> named `string_type' in `class boost::regex_traits<gunichar>'
So this means that regex_traits<gunichar> does not work, and I
must code my own substitute for regex_traits<gunichar>.
What are the requirements for such a traits structure?
What methods must mytraits::string_type have? What is the
required relationship between the types?
These requirements do not seem to be documented anywhere!
Help!
-- Paul Elliott 1(512)837-1096 pelliott_at_[hidden] PMB 181, 11900 Metric Blvd Suite J http://www.io.com/~pelliott/pme/ Austin TX 78758-3117
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net