2 Copyright (c) 2018-2019 Nokia.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
17 #include "private/redis/asyncredisreply.hpp"
19 using namespace shareddatalayer;
20 using namespace shareddatalayer::redis;
22 AsyncRedisReply::AsyncRedisReply():
29 AsyncRedisReply::AsyncRedisReply(const redisReply& rr):
32 typeMap { { REDIS_REPLY_NIL, Type::NIL }, { REDIS_REPLY_INTEGER, Type::INTEGER },
33 { REDIS_REPLY_STATUS, Type::STATUS }, { REDIS_REPLY_STRING, Type::STRING },
34 { REDIS_REPLY_ARRAY, Type::ARRAY } }
36 auto res(typeMap.find(rr.type));
37 if (res != typeMap.end())
44 AsyncRedisReply::Type AsyncRedisReply::getType() const
49 long long AsyncRedisReply::getInteger() const
54 const AsyncRedisReply::DataItem* AsyncRedisReply::getString() const
59 const AsyncRedisReply::ReplyVector* AsyncRedisReply::getArray() const
64 void AsyncRedisReply::parseReply(const redisReply& rr)
73 dataItem.str = std::string(rr.str, static_cast<size_t>(rr.len));
74 dataItem.len = rr.len;
85 void AsyncRedisReply::parseArray(const redisReply& rr)
87 for (auto i(0U); i < rr.elements; ++i)
88 replyVector.push_back(std::make_shared<AsyncRedisReply>(*rr.element[i]));