MCPcopy Create free account
hub / github.com/cc20110101/RedisView / formatToText

Method formatToText

src/RedisView/RedisLib/RedisRespParser.cpp:373–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373void RedisRespParser::formatToText(const RespType &inResp, QByteArray &outResp, int spaceNum) {
374 outResp.append(4 * spaceNum, ' ');
375 if(inResp._formatType == ':') {
376 outResp.append(QByteArray::number(inResp._integerValue));
377 outResp.append("\r\n");
378 } else if(inResp._formatType == '+' ||
379 inResp._formatType == '-') {
380 outResp.append(inResp._stringValue);
381 outResp.append("\r\n");
382 } else if(inResp._formatType == '$') {
383 if(inResp._formatLength == 0) {
384 outResp.append("0\r\n");
385 } else if (inResp._formatLength == -1) {
386 outResp.append("-1\r\n");
387 } else {
388 outResp.append(inResp._stringValue);
389 outResp.append("\r\n");
390 }
391 } else if(inResp._formatType == '*') {
392 ++spaceNum;
393 outResp.append(QByteArray::number(inResp._arrayLength));
394 outResp.append(":\r\n");
395 for(int i = 0 ; i < inResp._arrayLength; ++i) {
396 formatToText(inResp._arrayValue[i], outResp, spaceNum);
397 }
398 }
399}
400
401void RedisRespParser::formatToResp(const RespType &inResp, QByteArray &outResp, int spaceNum) {
402

Callers

nothing calls this directly

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected