本文整理汇总了C++中buffer_t类的典型用法代码示例。如果您正苦于以下问题:C++ buffer_t类的具体用法?C++ buffer_t怎么用?C++ buffer_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了buffer_t类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setAddress
void i2c::write( const buffer_t& data )
{
setAddress();
if( ::write(mDevice, data.data(), data.size()) < 0 )
{
ostringstream os;
os << "unable to write: " << strerror( errno );
throw runtime_error{ move( os.str() ) };
}
}
开发者ID:elvisdukaj,项目名称:icaldo,代码行数:10,代码来源:i2c_linux_device.cpp
示例2: append
static void append(std::vector<buffer_t>& buffers, buffer_t const& arg)
{
append_size(buffers, '$', arg.size());
if (arg.size() > RESP_LARGE_BUFFER_SIZE)
{
buffers.push_back(arg);
buffers.push_back("\r\n");
}
else
{
buffer_t& buffer = buffers.back();
buffer.append(arg);
buffer.append("\r\n");
}
}
开发者ID:TigerZhang,项目名称:resp,代码行数:15,代码来源:encoder.hpp
示例3: inFile
void SidTuneBase::loadFile(const char* fileName, buffer_t& bufferRef)
{
std::ifstream inFile(fileName, std::ifstream::binary);
if (!inFile.is_open())
{
throw loadError(ERR_CANT_OPEN_FILE);
}
inFile.seekg(0, inFile.end);
const size_t fileLen = (size_t)inFile.tellg();
if (fileLen == 0)
{
throw loadError(ERR_EMPTY);
}
inFile.seekg(0, inFile.beg);
buffer_t fileBuf;
fileBuf.reserve(fileLen);
fileBuf.assign(std::istreambuf_iterator<char>(inFile), std::istreambuf_iterator<char>());
if (inFile.bad())
{
throw loadError(ERR_CANT_LOAD_FILE);
}
inFile.close();
bufferRef.swap(fileBuf);
}
开发者ID:9a3eedi,项目名称:Droidsound,代码行数:33,代码来源:SidTuneBase.cpp
示例4: time
bool
CLabelManagerLanguageMonitor::ReadStatus(buffer_t& Status)
{
time_t t = time(NULL);
fprintf(stderr, "DEBUG: CLabelManagerLanguageMonitor::ReadStatus() %s\n", ctime(&t));
bool Result = false;
Status.clear();
buffer_t RequestStatusCommand = CLabelManagerDriver::GetRequestStatusCommand();
Environment_.WriteData(RequestStatusCommand);
Environment_.ReadData(Status);
if (Status.size() > 0)
{
Result = true;
}
fprintf(stderr, "DEBUG: ReadStatus() returned %i %i\n", (int)Status.size(), (int)Result);
return Result;
}
开发者ID:xcross,项目名称:dymo-cups-drivers,代码行数:22,代码来源:LabelManagerLanguageMonitor.cpp
示例5:
buffer_t
hmac::make(
hash_t type, const buffer_t& key, const unsigned char* src, size_t length) {
auto digest = digest_pair(type);
mbedcrypto_c_call(
mbedtls_md_hmac,
std::get<0>(digest),
to_const_ptr(key),
key.size(),
src,
length,
to_ptr(std::get<1>(digest)));
return std::get<1>(digest);
}
开发者ID:HuangKBAaron,项目名称:mbedcrypto,代码行数:16,代码来源:hash.cpp
示例6: read
virtual size_t read(buffer_t& buffer, size_t len) {
auto l = buffer_.read(buffer.data(), len);
if(buffer_.size() < buffer_update*frame_size_) fill_buffer();
return l;
}
开发者ID:otgaard,项目名称:simple_mp3,代码行数:5,代码来源:wave_stream.hpp
示例7: return
bool buffer_t::operator!=( const buffer_t& other) const
{
return ( bounds() != other.bounds()) || ( pixels_ != other.pixels_);
}
开发者ID:devernay,项目名称:ramen-1,代码行数:4,代码来源:buffer.cpp
示例8: acceptSidTune
void SidTuneBase::acceptSidTune(const char* dataFileName, const char* infoFileName,
buffer_t& buf, bool isSlashedFileName)
{
// Make a copy of the data file name and path, if available.
if (dataFileName != nullptr)
{
const size_t fileNamePos = isSlashedFileName ?
SidTuneTools::slashedFileNameWithoutPath(dataFileName) :
SidTuneTools::fileNameWithoutPath(dataFileName);
info->m_path = std::string(dataFileName, fileNamePos);
info->m_dataFileName = std::string(dataFileName + fileNamePos);
}
// Make a copy of the info file name, if available.
if (infoFileName != nullptr)
{
const size_t fileNamePos = isSlashedFileName ?
SidTuneTools::slashedFileNameWithoutPath(infoFileName) :
SidTuneTools::fileNameWithoutPath(infoFileName);
info->m_infoFileName = std::string(infoFileName + fileNamePos);
}
// Fix bad sidtune set up.
if (info->m_songs > MAX_SONGS)
{
info->m_songs = MAX_SONGS;
}
else if (info->m_songs == 0)
{
info->m_songs = 1;
}
if (info->m_startSong == 0
|| info->m_startSong > info->m_songs)
{
info->m_startSong = 1;
}
info->m_dataFileLen = buf.size();
info->m_c64dataLen = buf.size() - fileOffset;
// Calculate any remaining addresses and then
// confirm all the file details are correct
resolveAddrs(&buf[fileOffset]);
if (checkRelocInfo() == false)
{
throw loadError(ERR_BAD_RELOC);
}
if (checkCompatibility() == false)
{
throw loadError(ERR_BAD_ADDR);
}
if (info->m_dataFileLen >= 2)
{
// We only detect an offset of two. Some position independent
// sidtunes contain a load address of 0xE000, but are loaded
// to 0x0FFE and call player at 0x1000.
info->m_fixLoad = (endian_little16(&buf[fileOffset])==(info->m_loadAddr+2));
}
// Check the size of the data.
if (info->m_c64dataLen > MAX_MEMORY)
{
throw loadError(ERR_DATA_TOO_LONG);
}
else if (info->m_c64dataLen == 0)
{
throw loadError(ERR_EMPTY);
}
cache.swap(buf);
}
开发者ID:kode54,项目名称:sidplay-residfp,代码行数:74,代码来源:SidTuneBase.cpp
示例9:
void
MockPrintEnvironment::ReadData(buffer_t& Data)
{
Data.clear();
}
开发者ID:DimensionalDrift,项目名称:Internship2014,代码行数:5,代码来源:MOCK_PrintEnvironment.cpp
示例10:
void
CLabelManagerLanguageMonitor::ProcessData(const buffer_t& Data)
{
PageData_.insert(PageData_.end(), Data.begin(), Data.end());
}
开发者ID:xcross,项目名称:dymo-cups-drivers,代码行数:5,代码来源:LabelManagerLanguageMonitor.cpp
示例11: recv_response
void Client_connection::recv_response(buffer_t buf)
{
if (buf->empty()) {
end_response({Error::NO_REPLY});
return;
}
const std::string data{(char*) buf->data(), buf->size()};
// restart timer since we got data
if(timer_.is_running())
timer_.restart(timeout_dur_);
// create response if not exist
if(res_ == nullptr)
{
try {
res_ = make_response(data); // this also parses
}
catch(...)
{
end_response({Error::INVALID});
return;
}
}
// if there already is a response
else
{
// this is the case when Status line is received, but not yet headers.
if(not res_->headers_complete() && req_->method() != HEAD)
{
*res_ << data;
res_->parse();
}
// here we assume all headers has already been received (could not be true?)
else
{
// add chunks of body data
res_->add_chunk(data);
}
}
const auto& header = res_->header();
// TODO: Temporary, not good enough
// if(res_->is_complete())
// Assume we want some headers
if(!header.is_empty())
{
if(header.has_field(header::Content_Length))
{
try
{
const unsigned conlen = std::stoul(std::string(header.value(header::Content_Length)));
const unsigned body_size = res_->body().size();
//printf("<http::Connection> [%s] Data: %u ConLen: %u Body:%u\n",
// req_->uri().to_string().to_string().c_str(), data.size(), conlen, body_size);
// risk buffering forever if no timeout
if(body_size == conlen)
{
end_response();
}
else if(body_size > conlen)
{
end_response({Error::INVALID});
}
}
catch(...)
{ end_response({Error::INVALID}); }
}
else
end_response();
}
else if(req_->method() == HEAD)
{
end_response();
}
}
开发者ID:RicoAntonioFelix,项目名称:IncludeOS,代码行数:77,代码来源:client_connection.cpp
示例12: push_back
/*
Add a request to the back of the queue.
If the queue was empty/finished, point current to the new request.
*/
void push_back(buffer_t wr) {
debug2("<WriteQueue> Inserted WR: size=%u, current=%u, size=%u\n",
(uint32_t) wr->size(), current_, (uint32_t) size());
q.push_back(std::move(wr));
}
开发者ID:AnnikaH,项目名称:IncludeOS,代码行数:9,代码来源:write_queue.hpp
示例13: ostream
ostream(buffer_t &buf) : buf(buf), offset(buf.size()) {}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:1,代码来源:compat.hpp
示例14: end
uint8_t* end() const { return buffer.get() + length(); }
开发者ID:andreashappe,项目名称:IncludeOS,代码行数:1,代码来源:write_buffer.hpp
示例15: pos
uint8_t* pos() const { return buffer.get() + offset; }
开发者ID:andreashappe,项目名称:IncludeOS,代码行数:1,代码来源:write_buffer.hpp
示例16: begin
uint8_t* begin() const { return buffer.get(); }
开发者ID:andreashappe,项目名称:IncludeOS,代码行数:1,代码来源:write_buffer.hpp
示例17: write
void write(const_pointer buf, std::uint32_t len, std::uint32_t pos)
{
buffer_.write(buf, len, pos);
}
开发者ID:xeon2007,项目名称:smart_cpp_lib,代码行数:4,代码来源:serialize.hpp
示例18: read
void read(pointer buf, std::uint32_t len, std::uint32_t pos)
{
buffer_.read(buf, len, pos);
}
开发者ID:xeon2007,项目名称:smart_cpp_lib,代码行数:4,代码来源:serialize.hpp
示例19: buffer
const_pointer buffer() const
{
return buffer_.buffer();
}
开发者ID:xeon2007,项目名称:smart_cpp_lib,代码行数:4,代码来源:serialize.hpp
注:本文中的buffer_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论