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

Method parseResp

src/RedisView/RedisLib/RedisRespParser.cpp:337–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337bool RedisRespParser::parseResp(const QByteArray &data, RespType &rResult) {
338 if(data.isEmpty())
339 return false;
340
341 if (data.at(0) == '+') { // 简单字符串
342 rResult._formatType = '+';
343 if(!parseRespString(data, rResult._stringValue)) {
344 return false;
345 }
346 } else if (data.at(0) == '-') { // 错误
347 rResult._formatType = '-';
348 if(!parseRespError(data, rResult._stringValue)) {
349 return false;
350 }
351 } else if (data.at(0) == ':') { // 整数
352 rResult._formatType = ':';
353 if(!parseRespInteger(data, rResult._integerValue)) {
354 return false;
355 }
356 } else if (data.at(0) == '$') { // 大字符串
357 rResult._formatType = '$';
358 if(!parseRespBulkString(data, rResult._stringValue, rResult._formatLength)) {
359 return false;
360 }
361 } else if (data.at(0) == '*') { // 数组
362 rResult._formatType = '*';
363 if(!parseRespArray(data, rResult._arrayValue, rResult._arrayLength)) {
364 return false;
365 }
366 } else {
367 return false;
368 }
369
370 return true;
371}
372
373void RedisRespParser::formatToText(const RespType &inResp, QByteArray &outResp, int spaceNum) {
374 outResp.append(4 * spaceNum, ' ');

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected