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


C++ Buffer函数代码示例

本文整理汇总了C++中Buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ Buffer函数的具体用法?C++ Buffer怎么用?C++ Buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: FlushDNSFIFOMonitor

//Flush DNS cache FIFO Monitor
bool FlushDNSFIFOMonitor(
	void)
{
//Initialization
	unlink(FIFO_PATH_NAME);
	std::shared_ptr<char> Buffer(new char[PACKET_MAXSIZE]());
	memset(Buffer.get(), 0, PACKET_MAXSIZE);
	int FIFO_FD = 0;

//Create FIFO.
	if (mkfifo(FIFO_PATH_NAME, O_CREAT) < EXIT_SUCCESS || chmod(FIFO_PATH_NAME, S_IRUSR|S_IWUSR|S_IWGRP|S_IWOTH) < EXIT_SUCCESS)
	{
		PrintError(LOG_ERROR_SYSTEM, L"Create FIFO error", errno, nullptr, 0);

		unlink(FIFO_PATH_NAME);
		return false;
	}

//Open FIFO.
	FIFO_FD = open(FIFO_PATH_NAME, O_RDONLY, 0);
	if (FIFO_FD < EXIT_SUCCESS)
	{
		PrintError(LOG_ERROR_SYSTEM, L"Create FIFO error", errno, nullptr, 0);

		unlink(FIFO_PATH_NAME);
		return false;
	}

//FIFO Monitor
	for (;;)
	{
		memset(Buffer.get(), 0, PACKET_MAXSIZE);
		if (read(FIFO_FD, Buffer.get(), PACKET_MAXSIZE) > 0 && memcmp(Buffer.get(), FIFO_MESSAGE_FLUSH_DNS, strlen(FIFO_MESSAGE_FLUSH_DNS)) == EXIT_SUCCESS)
			FlushAllDNSCache();

		Sleep(LOOP_INTERVAL_TIME_MONITOR);
	}

//Monitor terminated
	close(FIFO_FD);
	unlink(FIFO_PATH_NAME);
	PrintError(LOG_ERROR_SYSTEM, L"FIFO module Monitor terminated", 0, nullptr, 0);
	return true;
}
开发者ID:qq98982,项目名称:Pcap_DNSProxy,代码行数:45,代码来源:Service.cpp

示例2: buffer

ICQFullInfo::AddressItemList ICQFullInfo::parseAddressItemList( const QByteArray& data ) const
{
	Buffer buffer( data );
	AddressItemList infoList;

	int count = buffer.getWord();
	while ( (count--) > 0 )
	{
		QList<TLV> tlvList = Buffer( buffer.getBSTR() ).getTLVList();

		AddressItem info;
		QList<TLV>::const_iterator it;
		for ( it = tlvList.constBegin(); it != tlvList.constEnd(); ++it )
		{
			switch ( (*it).type )
			{
			case 0x0064:
				info.address = (*it).data;
				break;
			case 0x006E:
				info.city = (*it).data;
				break;
			case 0x0078:
				info.state = (*it).data;
				break;
			case 0x0082:
				info.zip = (*it).data;
				break;
			case 0x008C:
				{
					Buffer b( (*it).data );
					info.country = b.getDWord();
				}
				break;
			default:
				kDebug(OSCAR_RAW_DEBUG) << "Unhandled tlv: " << hex << (*it).type << " data: " << hex << (*it).data;
				break;
			}
		}
		infoList.append( info );
	}
	return infoList;
}
开发者ID:Jtalk,项目名称:kopete-fork-xep0136,代码行数:43,代码来源:icquserinfo.cpp

示例3: produce_one

    bool produce_one()
    {
        ssize_t n = getline(&buffer_, &cap_, file_);

        if (n <= 0)
        {
            return false;
        }

        if (buffer_[n-1] == '\n')
        {
            buffer_[n-1] = '\0';
            n--;
        }

        emit(Buffer(buffer_, n));

        return true;
    }
开发者ID:huiliang,项目名称:geoloc,代码行数:19,代码来源:pipeline.hpp

示例4: GetID

//IDを生成・ロードする
std::string GetID()
{
	std::vector<wchar_t> Buffer(MAX_PATH,0);
	std::string IDString;
	bool OldIDFileExist=false;

	SHGetSpecialFolderPath(nullptr,Buffer.data(),CSIDL_APPDATA,false);
	std::wstring IDFile(Buffer.data());
	IDFile=IDFile+L"\\81Gyazo"+L"\\id.txt";

	//まずはファイルから ID をロード
	std::ifstream IDFileStream;

	IDFileStream.open(IDFile);
	if(!!IDFileStream){
		//IDを読み込む
		IDFileStream>>IDString;
		IDFileStream.close();
	}
开发者ID:abcsharp,项目名称:81Gyazo_Win,代码行数:20,代码来源:81Gyazo.cpp

示例5: HandleScope

/** read:
* read data from the current bufer to a new buffer object
* 
* @param int togo
*	bytes to be read
*
* @return object
*	New Buffer containing the read data
*/
void CJSBuffer::FxRead(const v8::FunctionCallbackInfo<v8::Value> &args)
{
	v8::HandleScope HandleScope(v8::Isolate::GetCurrent());
	CJSBuffer* jBuffer = GetJSObject<CJSBuffer>(args.Holder());
	CBufferObj* pBuffer = jBuffer->m_pBuffer;
	if (args.Length() < 1)
	{
		args.GetIsolate()->ThrowException(v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), (uint8_t*)"Invalid Argument"));
		return;
	}

	BUFFER_TRY
	size_t ToGo = args[0]->Uint32Value();
	CBuffer Buffer(ToGo);
	Buffer.WriteData(pBuffer->ReadData(ToGo), ToGo);
	CJSObject* jObject = CJSBuffer::New(new CBufferObj(Buffer), jBuffer->m_pScript);
	args.GetReturnValue().Set(jObject->GetInstance());
	BUFFER_CATCH
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:28,代码来源:JSBuffer.cpp

示例6: MaybeResize

GMPErr
GMPPlaneImpl::Copy(const GMPPlane& aPlane)
{
  auto& planeimpl = static_cast<const GMPPlaneImpl&>(aPlane);

  GMPErr err = MaybeResize(planeimpl.mSize);
  if (err != GMPNoErr) {
    return err;
  }

  if (planeimpl.Buffer() && planeimpl.mSize > 0) {
    memcpy(Buffer(), planeimpl.Buffer(), mSize);
  }

  mSize = planeimpl.mSize;
  mStride = planeimpl.mStride;

  return GMPNoErr;
}
开发者ID:CodeSpeaker,项目名称:gecko-dev,代码行数:19,代码来源:GMPVideoPlaneImpl.cpp

示例7: Buffer

// Buffer a block of data
int
LineBuffer::
Buffer( const char ** buf, int *nptr )
{
	const char	*bptr = *buf;
	int			nbytes = *nptr;

	// Loop through the whole input buffer
	while( nbytes-- ) {
		int status = Buffer( *bptr++ );
		if ( status ) {
			*buf = bptr;
			*nptr = nbytes;
			return status;
		}
	}
	*nptr = 0;
	return 0;
}
开发者ID:AlainRoy,项目名称:htcondor,代码行数:20,代码来源:linebuffer.cpp

示例8: LOG_DEBUG

void Connection::start()
{
  LOG_DEBUG(socket().native() << ": start()");

  request_parser_.reset();
  request_.reset();
  try {
    request_.remoteIP = socket().remote_endpoint().address().to_string();
    request_.port = socket().local_endpoint().port();
  } catch (std::exception& e) {
    LOG_ERROR("remote_endpoint() threw: " << e.what());
  }

  asio_error_code ignored_ec;
  socket().set_option(asio::ip::tcp::no_delay(true), ignored_ec);

  rcv_buffers_.push_back(Buffer());
  startAsyncReadRequest(rcv_buffers_.back(), CONNECTION_TIMEOUT);
}
开发者ID:LifeGo,项目名称:wt,代码行数:19,代码来源:Connection.C

示例9: poll_send_cq

Buffer RDMACMSocket::get_send_buf() {
    
    if (send_bufs.empty()) {
        struct ibv_wc wc[PACKET_WINDOW_SIZE];
	int ret = poll_send_cq(PACKET_WINDOW_SIZE, wc);

        for (int i = 1; i < ret; ++i) {
	    send_bufs.push_back(Buffer(reinterpret_cast<char*>(wc[i].wr_id), PACKET_SIZE));
        }

	Buffer buf(reinterpret_cast<char*>(wc[0].wr_id), PACKET_SIZE);
	buf.clear();
	return buf;
    }
    
    Buffer ret = send_bufs.front();
    send_bufs.pop_front();
    ret.clear();
    return ret;
}
开发者ID:nao23,项目名称:ramp-with-rdma,代码行数:20,代码来源:RDMACMSocket.cpp

示例10: FlushBuffer

void ImmutableIndexWriter::Finalize() {
  FlushBuffer();

  if (!index_offsets.empty()) {
    WriteData(Buffer(&index_offsets[0],
        index_offsets.size() * sizeof(offset_t)), RECORD_TYPE_INDEX_OFFSETS);

    for(vector<Buffer>::iterator i = index_keys.begin(); i != index_keys.end(); ++i) {
      WriteData(*i, RECORD_TYPE_INDEX_KEY);
    }
  } else {
    WriteData(Buffer::Empty(), RECORD_TYPE_INDEX_OFFSETS);
  }

  WriteData(Buffer::Empty(), RECORD_TYPE_FILE_FOOTER);

  storage.commit();
  storage.truncate();
  storage.close();
}
开发者ID:MagnusTiberius,项目名称:WalkerRoad,代码行数:20,代码来源:index_writer.cpp

示例11: Buffer

/**
this is not needed for bulk_extractor
*/
int64 File::Copy(File &Dest,int64 Length)
{ //This file is not called in bulk_extractor
  Array<char> Buffer(0x10000);
  int64 CopySize=0;
  bool CopyAll=(Length==INT64NDF);

  while (CopyAll || Length>0)
  {
    Wait();
    size_t SizeToRead=(!CopyAll && Length<(int64)Buffer.Size()) ? (size_t)Length:Buffer.Size();
    int ReadSize=Read(&Buffer[0],SizeToRead);
    if (ReadSize==0)
      break;
    Dest.Write(&Buffer[0],ReadSize);
    CopySize+=ReadSize;
    if (!CopyAll)
      Length-=ReadSize;
  }
  return(CopySize);
}
开发者ID:ajnelson,项目名称:bulk_extractor,代码行数:23,代码来源:file.cpp

示例12: Buffer

bool IComplexDatum::DeserializeJSON (const CString &sTypename, const TArray<CDatum> &Data)

//	DeserializeJSON
//
//	Deserialize from JSON

	{
	if (Data.GetCount() == 0 || Data[0].GetBasicType() != CDatum::typeString)
		return false;

	//	LATER: Handle serialization/deserialization of struct-based objects

	//	Default deserialization

	CStringBuffer Buffer(Data[0]);
	CBase64Decoder Decoder(&Buffer);
	if (!OnDeserialize(CDatum::formatJSON, sTypename, Decoder))
		return false;

	return true;
	}
开发者ID:kronosaur,项目名称:Hexarc,代码行数:21,代码来源:IComplexDatum.cpp

示例13: UtilAppendFile

//読み取り元ファイルを書き込み先ファイルのseekのある箇所から後にコピーして書き込む
//戻り値はエラーなしなら0,読み取りエラーは1,書き込みエラーは-1
int UtilAppendFile(HANDLE hWriteTo,HANDLE hReadFrom)
{
	//16KBずつコピー
	DWORD dwRead=0,dwWrite=0;
	std::vector<BYTE> Buffer(16*1024);
	for(;;){
		if(!ReadFile(hReadFrom,&Buffer.at(0),16*1024,&dwRead,NULL)){
			return 1;
		}
		if(0==dwRead){
			break;
		}
		if(!WriteFile(hWriteTo,&Buffer.at(0),dwRead,&dwWrite,NULL)){
			return -1;
		}
		if(dwRead!=dwWrite){
			return -1;
		}
	}
	return 0;
}
开发者ID:Claybird,项目名称:lhaforge,代码行数:23,代码来源:FileOperation.cpp

示例14: Buffer

void WriteHandler::handle(Event& evt){
    EpollEvent& eref = static_cast<EpollEvent&>(evt);

    logger.log("do write handle for fd: ");

    int fd = eref.getFd();

    logger.log(fd);
    
    if(handleTable.find(fd) == handleTable.end()){
        handleTable[fd] = Buffer();
    }
    
    Buffer& buffer =handleTable[fd];
    const char* buf = "say server";
    size_t num = Sockets::write(fd,buf,strlen(buf),0);

    if(num == -1){
        logger.log("write data to connection error");
    }
}
开发者ID:qqqil,项目名称:bude,代码行数:21,代码来源:write_handler.cpp

示例15: SetCursor

//
/// Loads a "hand" cursor from the winhlp32.exe module.
//
/// \note It appeared in Paul DiLascia's Jan 1998 MSJ articles.
void
TUrlLink::SetupCursor()
{
  SetCursor(GetModule(), IDC_HANDCURSOR);
  if(HCursor == 0){
    // if was problem try load cursor from winhlp32.exe
    // Get the windows directory
    TAPointer<tchar> Buffer(new tchar[MAX_PATH]);
    ::GetWindowsDirectory(Buffer, MAX_PATH);
     _tcscat(Buffer,_T("\\winhlp32.exe"));
    // This retrieves cursor #106 from winhlp32.exe, which is a hand pointer
    HMODULE hModule = ::LoadLibrary(Buffer);
    if (hModule) {
      HCURSOR hHandCursor = ::LoadCursor(hModule, TResId(106));
      if (hHandCursor)
        HCursor = CopyCursor(hHandCursor); // it is a macro in Win32

      ::FreeLibrary(hModule);
    }
  }
}
开发者ID:Meridian59,项目名称:Meridian59,代码行数:25,代码来源:urllink.cpp


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