Akumuli
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
resp.h
1 
16 #pragma once
17 
18 #include "stream.h"
19 #include <vector>
20 
21 namespace Akumuli {
22 
24  RESPError(std::string msg, int pos);
25 };
26 
30 struct RESPStream {
31  enum {
32  KB = 1024,
33  MB = 1024 * KB,
34  STRING_LENGTH_MAX = 1 * KB, //< Longest possible string
35  BULK_LENGTH_MAX = 1 * MB, //< Longest possible bulk string
36  };
37 
38  enum Type {
39  STRING,
40  INTEGER,
41  ARRAY,
42  BULK_STR,
43  ERROR,
44  BAD,
45  };
46 
47  ByteStreamReader* stream_; //< Stream
48 
50 
53  Type next_type() const;
54 
60  uint64_t read_int();
61 
66  uint64_t _read_int_body();
67 
74  int read_string(Byte* buffer, size_t buffer_size);
75 
77  int _read_string_body(Byte* buffer, size_t buffer_size);
78 
85  int read_bulkstr(Byte* buffer, size_t buffer_size);
86 
92  uint64_t read_array_size();
93 };
94 }
Definition: stream.h:29
uint64_t _read_int_body()
Definition: resp.cpp:42
int read_bulkstr(Byte *buffer, size_t buffer_size)
Definition: resp.cpp:113
uint64_t read_array_size()
Definition: resp.cpp:152
int read_string(Byte *buffer, size_t buffer_size)
Definition: resp.cpp:104
Definition: stream.h:44
Definition: resp.h:30
int _read_string_body(Byte *buffer, size_t buffer_size)
Definition: resp.cpp:81
Type next_type() const
Definition: resp.cpp:16
Definition: resp.h:23
uint64_t read_int()
Definition: resp.cpp:72