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


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

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


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

示例1: 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

示例2: 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

示例3: 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

示例4:

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

示例5: 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

示例6: 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

示例7: 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

示例8: ostream

 ostream(buffer_t &buf) : buf(buf), offset(buf.size()) {}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:1,代码来源:compat.hpp


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