15#ifndef ACTIONENGINE_REDIS_REPLY_CONVERTERS_H_ 
   16#define ACTIONENGINE_REDIS_REPLY_CONVERTERS_H_ 
   18#include <absl/status/status.h> 
   20#include "actionengine/data/conversion.h" 
   21#include "actionengine/redis/reply.h" 
   25constexpr std::string_view MapReplyEnumToTypeName(ReplyType type) {
 
   27    case ReplyType::Status:
 
   29    case ReplyType::Error:
 
   31    case ReplyType::Integer:
 
   35    case ReplyType::String:
 
   39    case ReplyType::Double:
 
   41    case ReplyType::Array:
 
   51    case ReplyType::BigNum:
 
   53    case ReplyType::Verbatim:
 
   61absl::Status EgltAssignInto(
const Reply& from, absl::Status* to);
 
   62absl::Status EgltAssignInto(
const Reply& from, int64_t* to);
 
   63absl::Status EgltAssignInto(
const Reply& from, 
double* to);
 
   64absl::Status EgltAssignInto(Reply from, std::string* to);
 
   65absl::Status EgltAssignInto(
const Reply& from, 
bool* to);
 
   68absl::Status EgltAssignInto(Reply from, ArrayReplyData* to);
 
   69absl::Status EgltAssignInto(Reply from, MapReplyData* to);
 
   70absl::Status EgltAssignInto(Reply from, SetReplyData* to);
 
   71absl::Status EgltAssignInto(Reply from, PushReplyData* to);
 
   72absl::Status EgltAssignInto(Reply from, VerbatimReplyData* to);
 
   75absl::Status EgltAssignInto(ArrayReplyData from, MapReplyData* to);
 
   76absl::Status EgltAssignInto(MapReplyData from, ArrayReplyData* to);
 
   77absl::Status EgltAssignInto(PushReplyData from, ArrayReplyData* to);
 
   80absl::Status EgltAssignInto(ArrayReplyData from, std::vector<Reply>* to);
 
   81absl::Status EgltAssignInto(ArrayReplyData from,
 
   82                            absl::flat_hash_map<std::string, Reply>* to);
 
   83absl::Status EgltAssignInto(MapReplyData from, std::vector<Reply>* to);
 
   84absl::Status EgltAssignInto(MapReplyData from,
 
   85                            absl::flat_hash_map<std::string, Reply>* to);
 
   86absl::Status EgltAssignInto(SetReplyData from, std::vector<Reply>* to);
 
   87absl::Status EgltAssignInto(PushReplyData from, std::vector<Reply>* to);
 
   88absl::Status EgltAssignInto(VerbatimReplyData from, std::string* to);
 
   90absl::Status EgltAssignInto(Reply from, std::vector<Reply>* to);
 
   91absl::Status EgltAssignInto(Reply from,
 
   92                            absl::flat_hash_map<std::string, Reply>* to);
 
   96absl::Status EgltAssignInto(Reply from, std::vector<T>* to) {
 
   97  ASSIGN_OR_RETURN(std::vector<Reply> reply_vector,
 
   98                   ConvertTo<std::vector<Reply>>(std::move(from)));
 
   99  std::vector<T> converted_vector;
 
  100  converted_vector.reserve(reply_vector.size());
 
  101  for (
const Reply& reply : reply_vector) {
 
  103    ASSIGN_OR_RETURN(value, ConvertTo<T>(reply));
 
  104    converted_vector.push_back(std::move(value));
 
  106  *to = std::move(converted_vector);
 
  107  return absl::OkStatus();
 
  111absl::Status EgltAssignInto(Reply from,
 
  112                            absl::flat_hash_map<std::string, T>* to) {
 
  114      ConvertTo<absl::flat_hash_map<std::string, Reply>>(std::move(from));
 
  115  RETURN_IF_ERROR(reply_map.status());
 
  116  absl::flat_hash_map<std::string, T> converted_map;
 
  117  converted_map.reserve(reply_map->size());
 
  118  for (
const auto& [key, reply] : *reply_map) {
 
  120    ASSIGN_OR_RETURN(value, ConvertTo<T>(reply));
 
  121    converted_map.emplace(std::move(key), std::move(value));
 
  123  *to = std::move(converted_map);
 
  124  return absl::OkStatus();