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


C++ CBuffer::getBuffer方法代码示例

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


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

示例1: onBufferReceived

/**
 * Callback that should be invoked when the data is received
 */
void CNaviReceiverProfileImpl::onBufferReceived(const tChannelId channel, CBuffer const& buffer)
{
   LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
   UInt8 *incomingData = buffer.getBuffer();
   int read_size = buffer.getSize();
   std::string json((char*)incomingData, read_size);
   LOG4CPLUS_TRACE(msLogger, "got string:");
   LOG4CPLUS_TRACE(msLogger, json);
   Json::Value root; // will contain the root value after parsing.
   Json::Reader reader;
   bool parsingSuccessful = reader.parse(json.c_str(), root);
   if (parsingSuccessful) {
      std::deque<std::string> tracks;
      Json::Value list=root["play"];
      Json::Value::UInt index=0;
      LOG4CPLUS_TRACE(msLogger, "tracks to play:");
      for(index=0;index<list.size();index++){
         LOG4CPLUS_TRACE(msLogger, list[index].asString());
         tracks.push_back(list[index].asString());
      }
      mpAppCallbacks->playTracks(tracks);
   } else {
      LOG4CPLUS_ERROR(msLogger, "Failed to parse tracklist!");
   }
}
开发者ID:babenkoav78,项目名称:iviLink,代码行数:28,代码来源:CNaviReceiverProfileImpl.cpp

示例2: while

CClimateClientProfile::~CClimateClientProfile()
{
   LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
   mBe = false;

   mpSenderThread->disconnect();
   delete mpSenderThread;
   delete mpReqMutex;

   while (!mReqQueue.empty())
   {
      CBuffer buf = mReqQueue.front();
      mReqQueue.pop();
      delete [] buf.getBuffer();
   }
}
开发者ID:Vanuan,项目名称:iviLink,代码行数:16,代码来源:CClimateClientProfile.cpp

示例3: handleRequest

void CClimateClientProfile::handleRequest()
{
   mpReqMutex->lock();
   CBuffer buf = mReqQueue.front();
   mReqQueue.pop();
   mpReqMutex->unlock();

   CError err = iviLink::Channel::sendBuffer(mChannelID, buf);
   if (!err.isNoError())
   {
      LOG4CPLUS_INFO(msLogger, "CClimateClientProfile::handleRequest() :: Send error"
         + static_cast<std::string>(err));
   }

   delete [] buf.getBuffer();
}
开发者ID:Vanuan,项目名称:iviLink,代码行数:16,代码来源:CClimateClientProfile.cpp

示例4: sendBuffer

/**
 * Sends buffer object to serial port
 * @param buffer
 * @return  none
 */
int CSerCom::sendBuffer(CBuffer &buffer) {

    if (!isOpen()) {
        throw string("Port closed.");
    }


    size_t len = buffer.getLength();

    unsigned char *tempBuf = new unsigned char[len];

//    cout << "++++++sending buffer: "; //@TODO remove it
    for (size_t i = 0; i < len; i++) {
        tempBuf[i] = buffer.getBuffer()[i];
//        cout << (int) tempBuf[i] << "[0x" << hex << (int) tempBuf[i] << dec << "] | ";
//        cout << (int) tempBuf[i] << "[0x" << hex << (int) tempBuf[i] << dec << "]("<<tempBuf[i]<<") | ";
    }
//    cout << endl;

    sendBuffer(tempBuf, len);
    delete[] tempBuf;
    return 0;
}
开发者ID:jezierski,项目名称:homesys,代码行数:28,代码来源:CSerCom.cpp


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