1 | |
2 | // vim:sw=2:ai |
3 | |
4 | /* |
5 | * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. |
6 | * See COPYRIGHT.txt for details. |
7 | */ |
8 | |
9 | #ifndef DENA_HSTCPCLI_HPP |
10 | #define DENA_HSTCPCLI_HPP |
11 | |
12 | #include <sys/types.h> |
13 | #include <sys/socket.h> |
14 | #include <string> |
15 | #include <memory> |
16 | |
17 | #include "config.hpp" |
18 | #include "socket.hpp" |
19 | #include "string_ref.hpp" |
20 | #include "string_buffer.hpp" |
21 | |
22 | namespace dena { |
23 | |
24 | struct hstcpcli_filter { |
25 | string_ref filter_type; |
26 | string_ref op; |
27 | size_t ff_offset; |
28 | string_ref val; |
29 | hstcpcli_filter() : ff_offset(0) { } |
30 | }; |
31 | |
32 | struct hstcpcli_i; |
33 | typedef std::auto_ptr<hstcpcli_i> hstcpcli_ptr; |
34 | |
35 | struct hstcpcli_i { |
36 | virtual ~hstcpcli_i() { } |
37 | virtual void close() = 0; |
38 | virtual int reconnect() = 0; |
39 | virtual bool stable_point() = 0; |
40 | virtual void request_buf_auth(const char *secret, const char *typ) = 0; |
41 | virtual void request_buf_open_index(size_t pst_id, const char *dbn, |
42 | const char *tbl, const char *idx, const char *retflds, |
43 | const char *filflds = 0) = 0; |
44 | virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op, |
45 | const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip, |
46 | const string_ref& mod_op, const string_ref *mvs, size_t mvslen, |
47 | const hstcpcli_filter *fils = 0, size_t filslen = 0, |
48 | int invalues_keypart = -1, const string_ref *invalues = 0, |
49 | size_t invalueslen = 0) = 0; // FIXME: too long |
50 | virtual int request_send() = 0; |
51 | virtual int response_recv(size_t& num_flds_r) = 0; |
52 | virtual const string_ref *get_next_row() = 0; |
53 | virtual void response_buf_remove() = 0; |
54 | virtual int get_error_code() = 0; |
55 | virtual std::string get_error() = 0; |
56 | static hstcpcli_ptr create(const socket_args& args); |
57 | }; |
58 | |
59 | }; |
60 | |
61 | #endif |
62 | |
63 | |