Boost logo

Boost :

Subject: [boost] Antwort: Re: Attibutes and Qi
From: Steffen.Roeber_at_[hidden]
Date: 2010-08-30 02:20:12


Thanks your for your answer. It works great. But to complete the example,
is it also possible to replace the std::string::iterator with
QString.:Iterator.
The following code:
  QString t2 = "Hallo";
  QString s2;
  qi::rule<QString::iterator, QString()> rule = (+qi::char_);
  qi::rule<QString::iterator> rule2 = rule[phoenix::ref(s2) = qi::_1];
  qi::phrase_parse(t2.begin(), t2.end(), rule2, qi::ascii::space);
does not compile:
1>------ Build started: Project: Spirit 2, Configuration: Debug Win32
------
1>Compiling...
1>main.cpp
1>using native typeof
1>D:\Devel10\Base\Libraries\boost_1_44_0\boost/spirit/home/support/char_class.hpp(783)
: error C2440: '<function-style-cast>' : cannot convert from 'const QChar'
to 'int'
1> No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called
1>
D:\Devel10\Base\Libraries\boost_1_44_0\boost/spirit/home/support/char_class.hpp(782)
: while compiling class template member function 'bool
boost::spirit::traits::ischar<CharParam,CharEncoding>::call(const
CharParam &)'
1> with
1> [
1> CharParam=QChar,
1> CharEncoding=boost::spirit::char_encoding::ascii
1> ]
1>
D:\Devel10\Base\Libraries\boost_1_44_0\boost/spirit/home/qi/char/char_class.hpp(68)
: see reference to class template instantiation
'boost::spirit::traits::ischar<CharParam,CharEncoding>' being compiled
1> with
1> [
1> CharParam=QChar,
1> CharEncoding=boost::spirit::char_encoding::ascii
1> ]
1>
D:\Devel10\Base\Libraries\boost_1_44_0\boost/spirit/home/qi/char/char_parser.hpp(68)
: see reference to function template instantiation 'bool
boost::spirit::qi::char_class<Tag>::test<QChar,Context>(CharParam,Context
&) const' being compiled
1> with
1> [
1>
Tag=boost::spirit::tag::char_code<boost::spirit::tag::space,boost::spirit::char_encoding::ascii>,
1> Context=const boost::fusion::unused_type,
1> CharParam=QChar
1> ]
1>
D:\Devel10\Base\Libraries\boost_1_44_0\boost/spirit/home/qi/skip_over.hpp(27)
: see reference to function template instantiation 'bool
boost::spirit::qi::char_parser<Derived,Char>::parse<Iterator,const
boost::fusion::unused_type,boost::fusion::unused_type,const
boost::fusion::unused_type>(Iterator &,const Iterator &,Context &,const
Skipper &,Attribute &) const' being compiled
1> with
1> [
1>
Derived=boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space,boost::spirit::char_encoding::ascii>>,
1> Char=boost::spirit::char_encoding::ascii::char_type,
1> Iterator=QString::iterator,
1> Context=const boost::fusion::unused_type,
1> Skipper=boost::fusion::unused_type,
1> Attribute=const boost::fusion::unused_type
1> ]
1>
D:\Devel10\Base\Libraries\boost_1_44_0\boost/spirit/home/qi/detail/parse.hpp(89)
: see reference to function template instantiation 'void
boost::spirit::qi::skip_over<Iterator,skipper_type>(Iterator &,const
Iterator &,const T &)' being compiled
1> with
1> [
1> Iterator=QString::iterator,
1> T=skipper_type
1> ]
1>
D:\Devel10\Base\Libraries\boost_1_44_0\boost/spirit/home/qi/parse.hpp(100)
: see reference to function template instantiation 'bool
boost::spirit::qi::detail::phrase_parse_impl<Expr>::call<Iterator,Skipper>(Iterator
&,Iterator,const Expr &,const Skipper
&,boost::spirit::qi::skip_flag::enum_type)' being compiled
1> with
1> [
1> Expr=boost::spirit::qi::rule<QString::iterator>,
1> Iterator=QString::iterator,
1> Skipper=boost::spirit::ascii::space_type
1> ]
1>
D:\Devel10\Base\Libraries\boost_1_44_0\boost/spirit/home/qi/parse.hpp(113)
: see reference to function template instantiation 'bool
boost::spirit::qi::phrase_parse<QString::iterator,boost::spirit::qi::rule<Iterator>,boost::spirit::ascii::space_type>(Iterator
&,Iterator,const Expr &,const Skipper
&,boost::spirit::qi::skip_flag::enum_type)' being compiled
1> with
1> [
1> Iterator=QString::iterator,
1> Expr=boost::spirit::qi::rule<QString::iterator>,
1> Skipper=boost::spirit::ascii::space_type
1> ]
1> .\main.cpp(48) : see reference to function template
instantiation 'bool
boost::spirit::qi::phrase_parse<QString::iterator,boost::spirit::qi::rule<Iterator>,boost::spirit::ascii::space_type>(const
Iterator &,Iterator,const Expr &,const Skipper
&,boost::spirit::qi::skip_flag::enum_type)' being compiled
1> with
1> [
1> Iterator=QString::iterator,
1> Expr=boost::spirit::qi::rule<QString::iterator>,
1> Skipper=boost::spirit::ascii::space_type
1> ]
1>Build Time 0:07
1>Build log was saved at "file://c:\Dokumente und Einstellungen\str\Eigene
Dateien\Visual Studio 2005\Projects\Spirit 2.0 Test\Spirit 2.0
Test\Debug\BuildLog.htm"
1>Spirit 2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========

It seems that spirit tries to convert a QChar into a int. Is there any
template I have to specialize?

Hella Aglaia Mobile Vision GmbH
Steffen Roeber
Firmware & Tools
Treskowstr. 14, D-13089 Berlin
Amtsgericht Berlin-Charlottenburg HRB 66976 B
Geschäftsführer: Kay Talmi

Fon: +49 30 200 04 29? 412
Fax: +49 30 200 04 29? 109
Mail: Steffen.Roeber_at_[hidden]
URL: www.aglaia-gmbh.de

URL: www.mobilevision.de

Dieses Dokument ist vertraulich zu behandeln. Die Weitergabe sowie
Vervielfältigung, Verwertung und Mitteilung seines Inhalts ist nur mit
unserer ausdrücklichen Genehmigung gestattet. Alle Rechte vorbehalten,
insbesondere für den Fall der Schutzrechtsanmeldung.
This document has to be treated confidentially. Its contents are not to be
passed on, duplicated, exploited or disclosed without our express
permission. All rights reserved, especially the right to apply for
protective rights.

"Hartmut Kaiser"/

(
Gesendet von: boost-bounces_at_[hidden]
27.08.2010 20:03
Bitte antworten an
boost_at_[hidden]

An
<boost_at_[hidden]>
Kopie

Thema
Re: [boost] Attibutes and Qi

> > I used the classic spirit in the past. Now I want to migrate to Spirit
> > 2.4 but I don't get the things together.Reading the different docus in
> > the web did not help. What I want to do at first is to parse a simple
> > string into a QString:
> > My pseudo code looks like:
> >
> > QString t;
> > qi::rule<string::iterator, QString()> r1 = (+qi::char_)(qi::_val =
> > qi::_1);
> > qi::rule<string::iterator , void()> r = r1[ref(t) = _1];
> > std::string temp("Hallo");
> > phrase_parse(temp.begin(), temp.end(), r, qi::space);
> >
> > But the compiler does no like this. Can anybody help me?
>
> Please note, I don't know anything about QString. But in order to be
> usable in places where Spirit expects to see a container, any data type
> needs to conform to certain concepts. In particular the type is expected
> to expose a STL compatible insert() function, expose the embedded types
> 'value_type', 'iterator', 'size_type', and 'reference'. IOW, it needs to
> be a STL compatible container.
>
> If the required interfaces are not exposed, you'll need to specialize
> Spirit's customization points for your data type (see the docs and
> examples for that, for instance:
>
http://www.boost.org/doc/libs/1_44_0/libs/spirit/doc/html/spirit/advanced/
> customize/is_container.html).
>
> If you write such customization points for QString we would love to get
> them back and having it added to the Spirit repository.

For the sake of it I added an example to Spirit
($BOOST_ROOT/libs/spirit/example/qi/custom_string.cpp) showing how to
parse
directly into a QString.

HTH
Regards Hartmut

---------------
Meet me at BoostCon
www.boostcon.com

_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk