17 #ifndef HH_SENF_Scheduler_ReadHelper_ 18 #define HH_SENF_Scheduler_ReadHelper_ 1 22 #include <boost/function.hpp> 23 #include <boost/intrusive_ptr.hpp> 24 #include <boost/scoped_ptr.hpp> 61 template <
class Handle>
69 typedef boost::intrusive_ptr<ReadHelper>
ptr;
89 template <
class Predicate>
109 std::string::size_type
maxSize()
const;
111 std::string
const &
data()
const;
112 std::string
const &
tail()
const;
123 struct InternalPredicate;
126 InternalPredicate * predicate, Callback cb);
128 static void dispatchProcess(ptr helper, Handle
handle,
int event);
134 std::string::size_type maxSize_;
135 boost::scoped_ptr<InternalPredicate> predicate_;
155 std::string::size_type operator()(std::string
const &
data);
static ptr dispatch(Handle handle, std::string::size_type maxSize, Callback callback)
Register new ReadHandler instance.
std::string const & data() const
return data read
std::string::size_type maxSize() const
Return maximum number of bytes to be read.
bool complete() const
Check whether the read has completed successfully.
void process()
Event handler main loop.
void revoke()
Remove the ReadHelper from the scheduler.
bool error() const
Check for error condition.
Handle handle() const
Access the handle object.
FdDispatcher public header.
void throw_error() const
If an error occurred, throw it.
boost::intrusive_ptr< ReadHelper > ptr
Smart pointer type for this class.
std::string const & tail() const
return data read but not matched by the predicate
ReadHelper predicate matching an arbitrary string.
boost::function< void(ptr)> Callback
Callback type.
Asynchronous reading helper.