7 data = client.readStringUntil(
'\r');
13 String emitStr((
char)
_type);
24 auto dLen =
data.toInt();
29 data = (
const char *)
nullptr;
33 auto charBuf =
new char[dLen + 1];
34 bzero(charBuf, dLen + 1);
36 auto readB = client.readBytes(charBuf, dLen);
37 if ((
int)readB != dLen)
39 Serial.printf(
"ERROR! Bad read (%ld ?= %ld)\n", (
long)readB, (
long)dLen);
43 data = String(charBuf);
49 String emitStr((
char)
_type);
50 emitStr += String(
data.length());
59 for (
int i = 0; i <
data.toInt(); i++)
63 RedisArray::operator std::vector<String>()
const
65 std::vector<String> rv;
67 rv.push_back((String)*ro.get());
73 String emitStr((
char)
_type);
74 emitStr += String(
vec.size());
76 for (
auto rTypeInst :
vec)
78 emitStr += rTypeInst->RESP();
85 if (!cmdClient.connected())
88 auto cmdRespStr =
RESP();
89 cmdClient.print(cmdRespStr);
91 if (ret && ret->type() == RedisObject::Type::InternalError)
97 int RedisCommand::issue_typed<int>(Client &cmdClient)
99 auto cmdRet =
issue(cmdClient);
101 return INT_MAX - 0x0f;
102 if (cmdRet->type() != RedisObject::Type::Integer)
103 return INT_MAX - 0xf0;
108 bool RedisCommand::issue_typed<bool>(Client &cmdClient)
110 auto cmdRet =
issue(cmdClient);
111 if (cmdRet && cmdRet->type() == RedisObject::Type::Integer)
117 String RedisCommand::issue_typed<String>(Client &cmdClient)
119 return (String)*
issue(cmdClient);
125 {RedisObject::Type::SimpleString, [](Client &c)
127 {RedisObject::Type::BulkString, [](Client &c)
129 {RedisObject::Type::Integer, [](Client &c)
131 {RedisObject::Type::Array, [](Client &c)
133 {RedisObject::Type::Error, [](Client &c)
138 if (client.connected() && !client.available()) {
143 if (!client.connected())
149 if (typeChar == -1 || typeChar ==
'\r' || typeChar ==
'\n') {
153 if (g_TypeParseMap.find(typeChar) != g_TypeParseMap.end())
155 auto retVal = g_TypeParseMap[typeChar](client);
157 if (!retVal || retVal->type() == RedisObject::Type::Error)
159 String err = retVal ? (String)*retVal :
"(nil)";
163 return std::shared_ptr<RedisObject>(retVal);
171 std::shared_ptr<RedisObject>
type =
nullptr;
172 while (
type==
nullptr) {