示例#1
0
void instance::write(buffer_type& buf,
                     message_type operation,
                     uint32_t* payload_len,
                     uint64_t operation_data,
                     const node_id& source_node,
                     const node_id& dest_node,
                     actor_id source_actor,
                     actor_id dest_actor,
                     payload_writer* pw) {
  if (! pw) {
    binary_serializer bs{std::back_inserter(buf), &get_namespace()};
    source_node.serialize(bs);
    dest_node.serialize(bs);
    bs.write(source_actor)
      .write(dest_actor)
      .write(uint32_t{0})
      .write(static_cast<uint32_t>(operation))
      .write(operation_data);
  } else {
    // reserve space in the buffer to write the payload later on
    auto wr_pos = static_cast<ptrdiff_t>(buf.size());
    char placeholder[basp::header_size];
    buf.insert(buf.end(), std::begin(placeholder), std::end(placeholder));
    auto pl_pos = buf.size();
    { // lifetime scope of first serializer (write payload)
      binary_serializer bs1{std::back_inserter(buf), &get_namespace()};
      (*pw)(bs1);
    }
    // write broker message to the reserved space
    binary_serializer bs2{buf.begin() + wr_pos, &get_namespace()};
    auto plen = static_cast<uint32_t>(buf.size() - pl_pos);
    source_node.serialize(bs2);
    dest_node.serialize(bs2);
    bs2.write(source_actor)
       .write(dest_actor)
       .write(plen)
       .write(static_cast<uint32_t>(operation))
       .write(operation_data);
    if (payload_len)
      *payload_len = plen;
  }
}
示例#2
0
文件: Buffer.hpp 项目: h82258652/YDWE
 iterator end()
 {
     return buf_.end();
 }
示例#3
0
文件: Buffer.hpp 项目: h82258652/YDWE
 const_iterator begin() const
 {
     return buf_.begin();
 }
示例#4
0
文件: Buffer.hpp 项目: h82258652/YDWE
 iterator begin()
 {
     return buf_.begin();
 }
示例#5
0
文件: Buffer.hpp 项目: h82258652/YDWE
 void reset()
 {
     cur_ = buf_.begin();
     end_ = buf_.end();
 }
示例#6
0
文件: Buffer.hpp 项目: h82258652/YDWE
 buffer(Elem const* from, size_t length)
     : buf_(static_cast<value_type const*>(from), static_cast<value_type const*>(from)+length)
     , cur_(buf_.begin())
     , end_(buf_.end())
 { }
示例#7
0
文件: Buffer.hpp 项目: h82258652/YDWE
 buffer(InputIterator begin, InputIterator end)
     : buf_(begin, end)
     , cur_(buf_.begin())
     , end_(buf_.end())
 { }
示例#8
0
#include <fcppt/config/external_end.hpp>


TEST_CASE(
	"container::buffer::to_raw_vector",
	"[container],[buffer]"
)
{
	typedef
	fcppt::container::buffer::object<
		int
	>
	buffer_type;

	buffer_type buffer{
		2u
	};

	buffer.write_data()[
		0
	]
		= 10;

	buffer.written(
		1u
	);

	typedef
	fcppt::container::raw_vector::object<
		int
	>
示例#9
0
文件: Buffer.hpp 项目: h82258652/YDWE
 buffer(buffer&& source)
     : buf_(std::move(source.buf_))
     , cur_(buf_.begin())
     , end_(buf_.end())
 { }
示例#10
0
文件: Buffer.hpp 项目: h82258652/YDWE
 buffer()
     : buf_()
     , cur_(buf_.begin())
     , end_(buf_.end())
 { }
示例#11
0
void async_udp::udp_listener::enlarge_buffer_( buffer_type& bt )
{
	bt->resize( bt->size() + default_buffer_size );
}
示例#12
0
void multicast_communication::udp_listener::enlarge_buffer_( buffer_type& bt )
{
	bt->resize( bt->size() + default_buffer_size );
}
示例#13
0
	static http::request_data assemble(http::request_data const& data, buffer_type& header)
	{
		namespace spirit = boost::spirit;

		char const sp[] = " ";
		char const ver[] = "HTTP/";
		char const crlf[] = "\r\n";
		//! собираем start-line
		header.insert(header.end(), data.method.begin(), data.method.end());
		header.insert(header.end(), sp, sp + sizeof(sp) - 1);
		header.insert(header.end(), data.uri.begin(), data.uri.end());
		header.insert(header.end(), sp, sp + sizeof(sp) - 1);
		header.insert(header.end(), ver, ver + sizeof(ver) - 1);
		header.insert(header.end(), data.ver.begin(), data.ver.end());
		header.insert(header.end(), crlf, crlf + sizeof(crlf) - 1);
		//! собираем message-header в плоский буфер
		detail::assemble(data.hdrs, header);
		//! разбираем сформированнй буфер и создаем структуру пакета
		http::request_data req_data;
		http::request req(&req_data);
		char const* begin = &header[0];
		char const* end = &header[0] + header.size();
		spirit::parse_info<> info = spirit::parse(begin, end, req);
		return req_data;
	}
示例#14
0
文件: Buffer.hpp 项目: h82258652/YDWE
 const_iterator end() const
 {
     return buf_.end();
 }
示例#15
0
文件: Buffer.hpp 项目: h82258652/YDWE
 buffer(Source const& source)
     : buf_(source.begin(), source.end())
     , cur_(buf_.begin())
     , end_(buf_.end())
 { }
示例#16
0
				bool is_out_of_range(buffer_type const& buffer, size_type i) const {
					return i >= buffer.size();
				}
示例#17
0
 /// fills the buffer using the generator
 void fill_buffer(buffer_type& buffer)
 {
   for (typename buffer_type::iterator it=buffer.begin();it!=buffer.end();++it)
     *it=generator_();
 }