本文整理汇总了C++中SymbolString::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolString::push_back方法的具体用法?C++ SymbolString::push_back怎么用?C++ SymbolString::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolString
的用法示例。
在下文中一共展示了SymbolString::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseHexMaster
result_t MainLoop::parseHexMaster(vector<string> &args, size_t argPos, SymbolString& master)
{
ostringstream msg;
while (argPos < args.size()) {
if ((args[argPos].length() % 2) != 0) {
return RESULT_ERR_INVALID_NUM;
}
msg << args[argPos++];
}
if (msg.str().size() < 4*2) // at least ZZ, PB, SB, NN
return RESULT_ERR_INVALID_ARG;
result_t ret;
unsigned int length = parseInt(msg.str().substr(3*2, 2).c_str(), 16, 0, MAX_POS, ret);
if (ret == RESULT_OK && (4+length)*2 != msg.str().size())
return RESULT_ERR_INVALID_ARG;
ret = master.push_back(m_address, false);
if (ret == RESULT_OK)
ret = master.parseHex(msg.str());
if (ret == RESULT_OK && !isValidAddress(master[1]))
ret = RESULT_ERR_INVALID_ADDR;
return ret;
}
示例2: receiveCompleted
void BusHandler::receiveCompleted()
{
unsigned char srcAddress = m_command[0], dstAddress = m_command[1];
if (srcAddress == dstAddress) {
logError(lf_bus, "invalid self-addressed message from %2.2x", srcAddress);
return;
}
addSeenAddress(srcAddress);
addSeenAddress(dstAddress);
bool master = isMaster(dstAddress);
if (dstAddress == BROADCAST) {
logInfo(lf_update, "update BC cmd: %s", m_command.getDataStr().c_str());
if (m_command.size()>=5+9 && m_command[2]==0x07 && m_command[3]==0x04) {
unsigned char slaveAddress = (unsigned char)((srcAddress+5)&0xff);
addSeenAddress(slaveAddress);
Message* message = m_messages->getScanMessage(slaveAddress);
if (message && (message->getLastUpdateTime()==0 || message->getLastSlaveData().size()<10)) {
// e.g. 10fe07040a b5564149303001248901
m_seenAddresses[slaveAddress] |= SCAN_INIT;
SymbolString idData;
istringstream input;
result_t result = message->prepareMaster(m_ownMasterAddress, idData, input);
if (result==RESULT_OK) {
idData.clear();
idData.push_back(9);
for (size_t i = 5; i <= 5+9; i++) {
idData.push_back(m_command[i]);
}
result = message->storeLastData(pt_slaveData, idData, 0);
}
if (result==RESULT_OK) {
m_seenAddresses[slaveAddress] |= SCAN_DONE;
}
logNotice(lf_update, "store BC ident: %s", getResultCode(result));
}
}
} else if (master) {
logInfo(lf_update, "update MM cmd: %s", m_command.getDataStr().c_str());
} else {
logInfo(lf_update, "update MS cmd: %s / %s", m_command.getDataStr().c_str(), m_response.getDataStr().c_str());
}
Message* message = m_messages->find(m_command);
if (m_grabMessages) {
unsigned long long key;
if (message) {
key = message->getKey();
} else {
key = Message::createKey(m_command, 4); // up to 4 DD bytes
}
m_grabbedMessages[key].setLastData(m_command, m_response);
}
if (message == NULL) {
if (dstAddress == BROADCAST) {
logNotice(lf_update, "unknown BC cmd: %s", m_command.getDataStr().c_str());
} else if (master) {
logNotice(lf_update, "unknown MM cmd: %s", m_command.getDataStr().c_str());
} else {
logNotice(lf_update, "unknown MS cmd: %s / %s", m_command.getDataStr().c_str(), m_response.getDataStr().c_str());
}
} else {
m_messages->invalidateCache(message);
string circuit = message->getCircuit();
string name = message->getName();
result_t result = message->storeLastData(m_command, m_response);
ostringstream output;
if (result==RESULT_OK) {
result = message->decodeLastData(output);
}
if (result < RESULT_OK) {
logError(lf_update, "unable to parse %s %s from %s / %s: %s", circuit.c_str(), name.c_str(), m_command.getDataStr().c_str(), m_response.getDataStr().c_str(), getResultCode(result));
} else {
string data = output.str();
if (m_answer && dstAddress == (master ? m_ownMasterAddress : m_ownSlaveAddress)) {
logNotice(lf_update, "self-update %s %s QQ=%2.2x: %s", circuit.c_str(), name.c_str(), srcAddress, data.c_str()); // TODO store in database of internal variables
} else if (message->getDstAddress() == SYN) { // any destination
if (message->getSrcAddress() == SYN) { // any destination and any source
logNotice(lf_update, "update %s %s QQ=%2.2x ZZ=%2.2x: %s", circuit.c_str(), name.c_str(), srcAddress, dstAddress, data.c_str());
} else {
logNotice(lf_update, "update %s %s ZZ=%2.2x: %s", circuit.c_str(), name.c_str(), dstAddress, data.c_str());
}
} else if (message->getSrcAddress() == SYN) { // any source
logNotice(lf_update, "update %s %s QQ=%2.2x: %s", circuit.c_str(), name.c_str(), srcAddress, data.c_str());
} else {
logNotice(lf_update, "update %s %s: %s", circuit.c_str(), name.c_str(), data.c_str());
}
}
}
}