5 // TODO: Move all not Handle dependent members to a ReadHandleBase class
8 #define HH_ReadHelper_ 1
12 #include <boost/function.hpp>
13 #include <boost/intrusive_ptr.hpp>
14 #include <boost/scoped_ptr.hpp>
16 #include "Utils/intrusive_refcount.hh"
17 #include "Scheduler.hh"
19 //#include "ReadHelper.mpp"
20 ///////////////////////////////hh.p////////////////////////////////////////
25 template <class Handle>
27 : public satcom::lib::intrusive_refcount
30 ///////////////////////////////////////////////////////////////////////////
33 typedef boost::intrusive_ptr<ReadHelper> ptr;
34 typedef boost::function<void (ptr)> Callback;
36 ///////////////////////////////////////////////////////////////////////////
37 ///\name Structors and default members
40 static ptr dispatch(Handle handle, std::string::size_type maxSize,
43 template <class Predicate>
44 static ptr dispatch(Handle handle, std::string::size_type maxSize, Predicate predicate,
48 ///////////////////////////////////////////////////////////////////////////
50 Handle handle() const;
51 unsigned maxSize() const;
53 std::string const & data() const;
54 std::string const & tail() const;
56 bool complete() const;
58 void throw_error() const;
65 struct InternalPredicate;
67 ReadHelper(Handle handle, unsigned maxSize, InternalPredicate * predicate, Callback cb);
69 static void dispatchProcess(ptr helper, Handle handle, satcom::lib::Scheduler::EventId event);
70 void process(Handle handle, satcom::lib::Scheduler::EventId event);
74 std::string::size_type maxSize_;
75 boost::scoped_ptr<InternalPredicate> predicate_;
86 ReadUntil(std::string target);
87 std::string::size_type operator()(std::string data);
93 ///////////////////////////////hh.e////////////////////////////////////////
94 #include "ReadHelper.cci"
95 #include "ReadHelper.ct"
96 #include "ReadHelper.cti"
97 //#include "ReadHelper.mpp"