Arduino-Redis
A Redis library for Arduino.
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
RedisObject Class Referenceabstract

Detailed Description

A basic object model for the Redis serialization protocol (RESP): https://redis.io/topics/protocol

Definition at line 22 of file RedisInternal.h.

Public Types

enum  Type {
  NoType = '\0', SimpleString = '+', Error = '-', Integer = ':',
  BulkString = '$', Array = '*', InternalError = '!'
}
 

Public Member Functions

 RedisObject ()
 
 RedisObject (Type tc)
 
 RedisObject (Type tc, Client &c)
 
virtual ~RedisObject ()
 
virtual void init (Client &client)
 
virtual String RESP ()=0
 
virtual operator String ()
 
Type type () const
 

Static Public Member Functions

static std::shared_ptr< RedisObjectparseType (Client &)
 

Protected Attributes

String data
 
Type _type = Type::NoType
 

#include <RedisInternal.h>

Inheritance diagram for RedisObject:
Inheritance graph
[legend]

Member Enumeration Documentation

◆ Type

Denote a basic Redis type, with NoType and InternalError defined specifically for this API

Enumerator
NoType 
SimpleString 
Error 
Integer 
BulkString 
Array 
InternalError 

Definition at line 26 of file RedisInternal.h.

Constructor & Destructor Documentation

◆ RedisObject() [1/3]

RedisObject::RedisObject ( )
inline

Definition at line 37 of file RedisInternal.h.

◆ RedisObject() [2/3]

RedisObject::RedisObject ( Type  tc)
inline

Definition at line 38 of file RedisInternal.h.

◆ RedisObject() [3/3]

RedisObject::RedisObject ( Type  tc,
Client &  c 
)
inline

Definition at line 39 of file RedisInternal.h.

◆ ~RedisObject()

virtual RedisObject::~RedisObject ( )
inlinevirtual

Definition at line 41 of file RedisInternal.h.

Member Function Documentation

◆ init()

void RedisObject::init ( Client &  client)
virtual

Initialize a RedisObject instance from the bytestream represented by 'client'. Only does very basic (e.g. SimpleString-style) parsing of the object from the byte stream. Concrete subclasses are expected to override this to provide class-specific parsing & initialization logic.

Reimplemented in RedisArray, and RedisBulkString.

Definition at line 5 of file RedisInternal.cpp.

◆ operator String()

virtual RedisObject::operator String ( )
inlinevirtual

Produce a human-readable String representation. Base implementation only returns the type character, so should be overriden.

Definition at line 57 of file RedisInternal.h.

◆ parseType()

std::shared_ptr< RedisObject > RedisObject::parseType ( Client &  client)
static

Definition at line 131 of file RedisInternal.cpp.

◆ RESP()

virtual String RedisObject::RESP ( )
pure virtual

Produce the Redis serialization protocol (RESP) representation. Must be overridden.

Implemented in RedisInternalError, RedisArray, RedisBulkString, and RedisSimpleString.

◆ type()

Type RedisObject::type ( ) const
inline

Definition at line 59 of file RedisInternal.h.

Member Data Documentation

◆ _type

Type RedisObject::_type = Type::NoType
protected

Definition at line 63 of file RedisInternal.h.

◆ data

String RedisObject::data
protected

Definition at line 62 of file RedisInternal.h.