[ create a new paste ] login | about

Link: http://codepad.org/HO9zZChl    [ raw code | fork ]

C++, pasted on May 19:
struct str_body
{
    using value_type = std::string;

    using is_direct = std::true_type;

    class writer
    {
        value_type const& body_;
        std::size_t n_ = 0;

    public:
        using const_buffers_type =
            boost::asio::const_buffers_1;

        template<bool isRequest, class Fields>
        explicit
        writer(message<
                isRequest, str_body, Fields> const& msg)
            : body_(msg.body)
        {
        }

        void
        init(error_code&)
        {
        }

        boost::optional<std::pair<const_buffers_type, bool>>
        data()
        {
            if(n_ >= body_.size())
                return boost::none;
            return {{boost::asio::buffer(
                body_.data() + n_, body_.size() - n_),
                    false}};
        }

        void
        consume(std::size_t n)
        {
            n_ += n;
        }
    };
};


Create a new paste based on this one


Comments: