当前位置: 首页>>代码示例>>C++>>正文


C++ buffer::size方法代码示例

本文整理汇总了C++中buffer::size方法的典型用法代码示例。如果您正苦于以下问题:C++ buffer::size方法的具体用法?C++ buffer::size怎么用?C++ buffer::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在buffer的用法示例。


在下文中一共展示了buffer::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: enqueue_copy_buffer

    /// Enqueues a command to copy data from \p src_buffer to
    /// \p dst_buffer.
    ///
    /// \see_opencl_ref{clEnqueueCopyBuffer}
    ///
    /// \see copy()
    event enqueue_copy_buffer(const buffer &src_buffer,
                              const buffer &dst_buffer,
                              size_t src_offset,
                              size_t dst_offset,
                              size_t size,
                              const wait_list &events = wait_list())
    {
        BOOST_ASSERT(m_queue != 0);
        BOOST_ASSERT(src_offset + size <= src_buffer.size());
        BOOST_ASSERT(dst_offset + size <= dst_buffer.size());
        BOOST_ASSERT(src_buffer.get_context() == this->get_context());
        BOOST_ASSERT(dst_buffer.get_context() == this->get_context());

        event event_;

        cl_int ret = clEnqueueCopyBuffer(
            m_queue,
            src_buffer.get(),
            dst_buffer.get(),
            src_offset,
            dst_offset,
            size,
            events.size(),
            events.get_event_ptr(),
            &event_.get()
        );

        if(ret != CL_SUCCESS){
            BOOST_THROW_EXCEPTION(opencl_error(ret));
        }

        return event_;
    }
开发者ID:ariosx,项目名称:compute,代码行数:39,代码来源:command_queue.hpp

示例2: output

 void
 checkInflate(buffer const& input, buffer const& original)
 {
     for(std::size_t i = 0; i < input.size(); ++i)
     {
         buffer output(original.size());
         inflate_stream zs;
         zs.avail_in = 0;
         zs.next_in = 0;
         zs.next_out = output.data();
         zs.avail_out = output.capacity();
         if(i > 0)
         {
             zs.next_in = (Byte*)input.data();
             zs.avail_in = i;
             auto result = zs.write(Z_FULL_FLUSH);
             expect(result == Z_OK);
         }
         zs.next_in = (Byte*)input.data() + i;
         zs.avail_in = input.size() - i;
         auto result = zs.write(Z_FULL_FLUSH);
         output.resize(output.capacity() - zs.avail_out);
         expect(result == Z_OK);
         expect(output.size() == original.size());
         expect(std::memcmp(
             output.data(), original.data(), original.size()) == 0);
     }
 }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例3:

	buffer(buffer const& b)
		: m_begin(0)
		, m_end(0)
		, m_last(0)
	{
		if (b.size() == 0) return;
		resize(b.size());
		std::memcpy(m_begin, b.begin(), b.size());
	}
开发者ID:naroya,项目名称:fdm,代码行数:9,代码来源:buffer.hpp

示例4:

	buffer(buffer const& b)
		: m_begin(0)
		, m_size(0)
		, m_capacity(0)
	{
		if (b.size() == 0) return;
		resize(b.size());
		std::memcpy(m_begin, b.begin(), b.size());
	}
开发者ID:Meonardo,项目名称:libtorrent,代码行数:9,代码来源:buffer.hpp

示例5: has_nonsubsingleton_fwd_dep

/* Return true if there is j s.t. ssinfos[j] is marked as subsingleton,
   and it dependends of argument i */
static bool has_nonsubsingleton_fwd_dep(unsigned i, buffer<param_info> const & pinfos, buffer<ss_param_info> const & ssinfos) {
    lean_assert(pinfos.size() == ssinfos.size());
    for (unsigned j = i+1; j < pinfos.size(); j++) {
        if (ssinfos[j].is_subsingleton())
            continue;
        auto const & back_deps = pinfos[j].get_back_deps();
        if (std::find(back_deps.begin(), back_deps.end(), i) != back_deps.end()) {
            return true;
        }
    }
    return false;
}
开发者ID:sakas--,项目名称:lean,代码行数:14,代码来源:fun_info.cpp

示例6: hexStr

//Function to convert string of unsigned chars to string of chars
std::string cpl::crypt::blowfish::char2Hex(const buffer &charStr)
{
  std::string hexStr(charStr.size()*2, '\0');
  std::string hex;

	for(int i=0; i < static_cast<int>(charStr.size()); i++)
	{
    hex = convertChar2Hex(charStr[i]);
		copy(hex.begin(), hex.end(), hexStr.begin()+(i*2));
	}

  return hexStr;
}
开发者ID:3cst4sy,项目名称:cpp-lib,代码行数:14,代码来源:blowfish.cpp

示例7: enqueue_fill_buffer

    /// Enqueues a command to fill \p buffer with \p pattern.
    ///
    /// \see_opencl_ref{clEnqueueFillBuffer}
    ///
    /// \opencl_version_warning{1,2}
    ///
    /// \see fill()
    event enqueue_fill_buffer(const buffer &buffer,
                              const void *pattern,
                              size_t pattern_size,
                              size_t offset,
                              size_t size,
                              const wait_list &events = wait_list())
    {
        BOOST_ASSERT(m_queue != 0);
        BOOST_ASSERT(offset + size <= buffer.size());
        BOOST_ASSERT(buffer.get_context() == this->get_context());

        event event_;

        cl_int ret = clEnqueueFillBuffer(
            m_queue,
            buffer.get(),
            pattern,
            pattern_size,
            offset,
            size,
            events.size(),
            events.get_event_ptr(),
            &event_.get()
        );

        if(ret != CL_SUCCESS){
            BOOST_THROW_EXCEPTION(opencl_error(ret));
        }

        return event_;
    }
开发者ID:ariosx,项目名称:compute,代码行数:38,代码来源:command_queue.hpp

示例8: enqueue_write_buffer_async

    /// Enqueues a command to write data from host memory to \p buffer.
    /// The copy is performed asynchronously.
    ///
    /// \see_opencl_ref{clEnqueueWriteBuffer}
    ///
    /// \see copy_async()
    event enqueue_write_buffer_async(const buffer &buffer,
                                     size_t offset,
                                     size_t size,
                                     const void *host_ptr,
                                     const wait_list &events = wait_list())
    {
        BOOST_ASSERT(m_queue != 0);
        BOOST_ASSERT(size <= buffer.size());
        BOOST_ASSERT(buffer.get_context() == this->get_context());
        BOOST_ASSERT(host_ptr != 0);

        event event_;

        cl_int ret = clEnqueueWriteBuffer(
            m_queue,
            buffer.get(),
            CL_FALSE,
            offset,
            size,
            host_ptr,
            events.size(),
            events.get_event_ptr(),
            &event_.get()
        );

        if(ret != CL_SUCCESS){
            BOOST_THROW_EXCEPTION(opencl_error(ret));
        }

        return event_;
    }
开发者ID:ariosx,项目名称:compute,代码行数:37,代码来源:command_queue.hpp

示例9: enqueue_read_buffer

    /// Enqueues a command to read data from \p buffer to host memory.
    ///
    /// \see_opencl_ref{clEnqueueReadBuffer}
    ///
    /// \see copy()
    void enqueue_read_buffer(const buffer &buffer,
                             size_t offset,
                             size_t size,
                             void *host_ptr,
                             const wait_list &events = wait_list())
    {
        BOOST_ASSERT(m_queue != 0);
        BOOST_ASSERT(size <= buffer.size());
        BOOST_ASSERT(buffer.get_context() == this->get_context());
        BOOST_ASSERT(host_ptr != 0);

        cl_int ret = clEnqueueReadBuffer(
            m_queue,
            buffer.get(),
            CL_TRUE,
            offset,
            size,
            host_ptr,
            events.size(),
            events.get_event_ptr(),
            0
        );

        if(ret != CL_SUCCESS){
            BOOST_THROW_EXCEPTION(opencl_error(ret));
        }
    }
开发者ID:ariosx,项目名称:compute,代码行数:32,代码来源:command_queue.hpp

示例10: has_local

list<unsigned> fun_info_manager::collect_deps(expr const & type, buffer<expr> const & locals) {
    buffer<unsigned> deps;
    for_each(type, [&](expr const & e, unsigned) {
            if (m_ctx.is_tmp_local(e)) {
                unsigned idx;
                for (idx = 0; idx < locals.size(); idx++)
                    if (locals[idx] == e)
                        break;
                if (idx < locals.size() && std::find(deps.begin(), deps.end(), idx) == deps.end())
                    deps.push_back(idx);
            }
            return has_local(e); // continue the search only if e has locals
        });
    std::sort(deps.begin(), deps.end());
    return to_list(deps);
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:16,代码来源:fun_info_manager.cpp

示例11: visit_projection

 expr visit_projection(name const & fn, buffer<expr> const & args) {
     projection_info const & info = *get_projection_info(env(), fn);
     expr major = visit(args[info.m_nparams]);
     buffer<bool> rel_fields;
     name I_name = *inductive::is_intro_rule(env(), info.m_constructor);
     get_constructor_info(info.m_constructor, rel_fields);
     lean_assert(info.m_i < rel_fields.size());
     lean_assert(rel_fields[info.m_i]); /* We already erased irrelevant information */
     /* Adjust projection index by ignoring irrelevant fields */
     unsigned j = 0;
     for (unsigned i = 0; i < info.m_i; i++) {
         if (rel_fields[i])
             j++;
     }
     expr r;
     if (has_trivial_structure(I_name, rel_fields)) {
         lean_assert(j == 0);
         r = major;
     } else {
         r = mk_app(mk_proj(j), major);
     }
     /* Add additional arguments */
     for (unsigned i = info.m_nparams + 1; i < args.size(); i++)
         r = mk_app(r, visit(args[i]));
     return r;
 }
开发者ID:soonhokong,项目名称:lean-osx,代码行数:26,代码来源:simp_inductive.cpp

示例12: recv_handler

/**
 * Received message callback. This function is executed to process the
 * received messages. If this is a valid message, the message is
 * dispatched to the handler defined by the user.
 *
 * @param buff Message byte buffer.
 * @param rbytes Size of the message.
 * @param ec Error code.
 */
void link::recv_handler(buffer<uint8>& buff, size_t rbytes,
						const boost::system::error_code& ec)
{
	if (ec) {
		mih::message pm;

		_handler(pm, ec);

	} else {
		mih::frame* fm = mih::frame::cast(buff.get(), rbytes);

		if (fm) {
			mih::message pm(*fm);

			_handler(pm, ec);
		}
	}

	void* rbuff = buff.get();
	size_t rlen = buff.size();

	_sock.async_receive(boost::asio::buffer(rbuff, rlen),
						boost::bind(&link::recv_handler,
									this,
									bind_rv(buff),
									boost::asio::placeholders::bytes_transferred,
									boost::asio::placeholders::error));
}
开发者ID:ATNoG,项目名称:ODTONE,代码行数:37,代码来源:link.cpp

示例13: parse_notation_expr

static expr parse_notation_expr(parser & p, buffer<expr> const & locals) {
    auto pos = p.pos();
    expr r = p.parse_expr();
    r = abstract(r, locals.size(), locals.data());
    check_notation_expr(r, pos);
    return r;
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:7,代码来源:notation_cmd.cpp

示例14: out

inline void device_buf::out(byte p)
{
	// TODO: If out_buf was resized so that it would be full at the next flush moment,
	// we only need to do one check here.
	out_buf.put(p);
	if(out_buf.size() > out_buffer_size)
		flush(); // Time to flush
}
开发者ID:coyun,项目名称:gvl,代码行数:8,代码来源:device_buf.hpp

示例15: runtime_error

void cpl::crypt::blowfish::init( const buffer &ucKey ) {

  short keysize = ucKey.size();

  if (keysize<1)
    throw std::runtime_error("Incorrect key length");
	//Check the Key - the key length should be between 1 and 56 bytes
	if (keysize>56)
		keysize = 56;

  buffer aucLocalKey = ucKey;

	//Reflexive Initialization of the Blowfish.
	//Generating the Subkeys from the Key flood P and S boxes with PI
        std::memcpy(m_auiP, scm_auiInitP, sizeof m_auiP);
        std::memcpy(m_auiS, scm_auiInitS, sizeof m_auiS);

	//Load P boxes with key bytes
  unsigned int x=0;
	//Repeatedly cycle through the key bits until the entire P array has been XORed with key bits

  int iCount = 0;

	for(int i=0; i<18; i++)
	{
		x=0;
		for(int n=4; n--; )
		{
			x <<= 8;
			x |= aucLocalKey[iCount];

			iCount++;
			if(iCount == keysize)
			{ //All key bytes used, so recycle 
				iCount = 0;
			}
		}
		m_auiP[i] ^= x;
	}

	//Reflect P and S boxes through the evolving Blowfish
	block b(0UL,0UL); //all-zero block
	for(int i=0; i<18; )
  {
		encrypt(b);
    m_auiP[i++] = b.m_uil;
    m_auiP[i++] = b.m_uir;
  }

	for(int j=0; j<4; j++)
		for(int k=0; k<256; )
    {
			encrypt(b);
      m_auiS[j][k++] = b.m_uil;
      m_auiS[j][k++] = b.m_uir;
    }
}
开发者ID:3cst4sy,项目名称:cpp-lib,代码行数:57,代码来源:blowfish.cpp


注:本文中的buffer::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。