本文整理汇总了C++中StringBuffer::concat方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::concat方法的具体用法?C++ StringBuffer::concat怎么用?C++ StringBuffer::concat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer::concat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fieldCommands
static bool fieldCommands(NWK_DataInd_t *ind) {
int ret;
if (hqVerboseOutput) {
Serial.print(F("Received command"));
Serial.print(F("lqi: "));
Serial.print(ind->lqi);
Serial.print(F(" "));
Serial.print(F("rssi: "));
Serial.println(ind->rssi);
}
if (fieldAnswerTo) {
if (hqVerboseOutput) {
Serial.println(F("can't receive command while sending answer"));
}
return false;
}
if (!fieldCommand.concat((const char*)ind->data, ind->size)) {
return false; // TODO we need to restart or something, no memory
}
// when null terminated, do the message
if (fieldCommand[fieldCommand.length() - 1] != '\0') {
if (hqVerboseOutput) {
Serial.println(F("waiting for more"));
}
return true;
}
if (hqVerboseOutput) {
Serial.print(F("running command "));
Serial.println(fieldCommand);
}
// run the command and chunk back the results
setOutputHandler(&printToString<&fieldCommandOutput>);
// TODO: Once bitlash fixes const-correctness, this and similar casts
// should be removed.
ret = (int)doCommand(const_cast<char *>(fieldCommand.c_str()));
fieldCommand = (char*)NULL;
resetOutputHandler();
if (hqVerboseOutput) {
Serial.print(F("got result "));
Serial.println(ret);
}
// send data back in chunks
fieldAnswerTo = ind->srcAddr;
fieldAnswerChunksAt = 0;
fieldAnswerRetries = 0;
fieldAnswerChunk();
return true;
}
示例2: sendStr
void StringBuffer::sendStr(Context* context, Value d, void(*func)(const char*,int))
{
switch (d.getType()->getSymbol()) {
case HSym_NilClass:
func("", 0);
break;
case HSym_String:
func((const char*) d.ptrData, HMD_STRLEN((const char*) d.ptrData));
break;
case HSym_StringBuffer:
{
StringBuffer* sb = d.toObj()->cppObj<StringBuffer>();
func(sb->top(), sb->length());
}
break;
default:
{
StringBuffer* sb = new StringBuffer();
sb->concat(context, d, 1);
func(sb->top(), sb->length());
delete sb;
}
}
}
示例3: fieldCommands
static bool fieldCommands(NWK_DataInd_t *ind) {
numvar ret;
if (Scout.handler.isVerbose) {
Serial.print(F("Received command"));
Serial.print(F("lqi: "));
Serial.print(ind->lqi);
Serial.print(F(" "));
Serial.print(F("rssi: "));
Serial.println(ind->rssi);
}
if (fieldAnswerTo) {
if (Scout.handler.isVerbose) {
Serial.println(F("can't receive command while sending answer"));
}
return false;
}
if (!fieldCommand.concat((const char*)ind->data, ind->size)) {
return false; // TODO we need to restart or something, no memory
}
// ack w/ our rssi as control
NWK_SetAckControl(abs(ind->rssi));
// when null terminated, do the message
if (fieldCommand[fieldCommand.length() - 1] != '\0') {
if (Scout.handler.isVerbose) {
Serial.println(F("waiting for more"));
}
return true;
}
if (Scout.handler.isVerbose) {
Serial.print(F("running command "));
Serial.println(fieldCommand.c_str());
}
Shell.lastMeshRssi = abs(ind->rssi);
Shell.lastMeshLqi = ind->lqi;
Shell.lastMeshFrom = ind->srcAddr;
fieldCommandOutput = "";
ret = Shell.eval(PrintToString(fieldCommandOutput), fieldCommand);
fieldCommand = (char*)NULL;
if (Scout.handler.isVerbose) {
Serial.print(F("got result "));
Serial.println(ret);
Serial.println(fieldCommandOutput.c_str());
}
// a command from the command endpoint doesn't get a response
if(ind->srcEndpoint == 2)
{
fieldCommandOutput = (char*)NULL;
return true;
}
// send data back in chunks
fieldAnswerTo = ind->srcAddr;
fieldAnswerChunksAt = 0;
fieldAnswerRetries = 0;
fieldAnswerChunk();
return true;
}