本文整理汇总了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!");
}
}
示例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();
}
}
示例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();
}
示例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;
}