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


C++ StringBuffer::concat方法代码示例

本文整理汇总了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;
}
开发者ID:drogge,项目名称:library-pinoccio,代码行数:58,代码来源:ScoutHandler.cpp

示例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;
        }
    }
}
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:24,代码来源:hyStringBuffer.cpp

示例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;
}
开发者ID:Pinoccio,项目名称:library-pinoccio,代码行数:67,代码来源:ScoutHandler.cpp


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