ASIO async_read_until...
Hello list,
I have a set of inherited classes as follows:
client [parent of]
stream [parent of]
parser [parent of]
grammar
When I perform the following call:
boost::asio::async_read_until(
socket_,
streambuf_,
stream::parse(),
boost::bind(
&client::handle_read,
this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
)
);
The xml::parser::operator() call for the match condition is a copy of
the classes:
parser [parent of]
grammar
I need to know if someone could suggest a client way for me to use
(shared) pointers to the classes so that the xml::parser::operator() can
keep its state changes over successive calls for async_read_until.
Currently I have this (hack) for the issue, but hope there is a cleaner
approach:
class parser
: public grammar {
public:
parser(
) : parser_(//stupid hack...
this
) {
};
virtual ~parser(
) {
};
parser& parse(
) {
return *this;
};
template <typename T>
std::pair
On Thu, Jul 23, 2009 at 1:27 PM, Etienne Philip
Pretorius
Hello list,
I have a set of inherited classes as follows:
client [parent of] stream [parent of] parser [parent of] grammar
When I perform the following call:
boost::asio::async_read_until( socket_, streambuf_, stream::parse(), boost::bind( &client::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred ) );
The xml::parser::operator() call for the match condition is a copy of the classes:
parser [parent of] grammar
I need to know if someone could suggest a client way for me to use (shared) pointers to the classes so that the xml::parser::operator() can keep its state changes over successive calls for async_read_until.
I should throw in a disclaimer that I have no experience at all with the xml parsing classes you're using so this may not apply. Can you store a single instance of parser inside client and then call async_read_until with boost::ref(parser_) instead of stream::parse()?
Zachary Turner wrote:
On Thu, Jul 23, 2009 at 1:27 PM, Etienne Philip Pretorius
wrote: Hello list,
I have a set of inherited classes as follows:
client [parent of] stream [parent of] parser [parent of] grammar
When I perform the following call:
boost::asio::async_read_until( socket_, streambuf_, stream::parse(), boost::bind( &client::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred ) );
The xml::parser::operator() call for the match condition is a copy of the classes:
parser [parent of] grammar
I need to know if someone could suggest a client way for me to use (shared) pointers to the classes so that the xml::parser::operator() can keep its state changes over successive calls for async_read_until.
I should throw in a disclaimer that I have no experience at all with the xml parsing classes you're using so this may not apply.
No problem, I am a hobby coder and decided to make my own with boost libraries...
Can you store a single instance of parser inside client and then call async_read_until with boost::ref(parser_) instead of stream::parse()?
You are correct. Thank you.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Etienne Philip Pretorius
-
Zachary Turner