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.
18 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 * platform project (RICP).
22 #include "private/redis/asyncredisreply.hpp"
24 using namespace shareddatalayer;
25 using namespace shareddatalayer::redis;
27 AsyncRedisReply::AsyncRedisReply():
34 AsyncRedisReply::AsyncRedisReply(const redisReply& rr):
37 typeMap { { REDIS_REPLY_NIL, Type::NIL }, { REDIS_REPLY_INTEGER, Type::INTEGER },
38 { REDIS_REPLY_STATUS, Type::STATUS }, { REDIS_REPLY_STRING, Type::STRING },
39 { REDIS_REPLY_ARRAY, Type::ARRAY } }
41 auto res(typeMap.find(rr.type));
42 if (res != typeMap.end())
49 AsyncRedisReply::Type AsyncRedisReply::getType() const
54 long long AsyncRedisReply::getInteger() const
59 const AsyncRedisReply::DataItem* AsyncRedisReply::getString() const
64 const AsyncRedisReply::ReplyVector* AsyncRedisReply::getArray() const
69 void AsyncRedisReply::parseReply(const redisReply& rr)
78 dataItem.str = std::string(rr.str, static_cast<size_t>(rr.len));
79 dataItem.len = rr.len;
90 void AsyncRedisReply::parseArray(const redisReply& rr)
92 for (auto i(0U); i < rr.elements; ++i)
93 replyVector.push_back(std::make_shared<AsyncRedisReply>(*rr.element[i]));