-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathIStatementPutGet.hpp
100 lines (89 loc) · 2.75 KB
/
IStatementPutGet.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright (c) 2018-2019 Snowflake Computing, Inc. All rights reserved.
*/
#ifndef SNOWFLAKECLIENT_ISTATEMENT_HPP
#define SNOWFLAKECLIENT_ISTATEMENT_HPP
#include "PutGetParseResponse.hpp"
#include "Proxy.hpp"
#include <iostream>
namespace Snowflake
{
namespace Client
{
/**
* Interface that should be implemented by external component to interact
* with server to get metadata/credentials about put/get command
*/
class IStatementPutGet
{
public:
/**
* Send put or get command to gs and get all data back.
* This command will allocate a PutGetParseResponse object on heap,
* Caller of this method is responsible for deallocating the memory
*
* @param sql put or get command
* @param putGetParseResponse parse response. Object is owned by caller
*
* return true if parse succeed otherwise false
*/
virtual bool parsePutGetCommand(std::string *sql,
PutGetParseResponse *putGetParseResponse) = 0;
/**
* PUT/GET on GCS use this interface to perform put request.
* Not implemented by default.
* @param url The url of the request.
* @param headers The headers of the request.
* @param payload The upload data.
* @param responseHeaders The headers of the response.
*
* return true if succeed otherwise false
*/
virtual bool http_put(std::string const& url,
std::vector<std::string> const& headers,
std::basic_iostream<char>& payload,
size_t payloadLen,
std::string& responseHeaders)
{
return false;
}
/**
* PUT/GET on GCS use this interface to perform put request.
* Not implemented by default.
* @param url The url of the request.
* @param headers The headers of the request.
* @param payload The upload data.
* @param responseHeaders The headers of the response.
* @param headerOnly True if get response header only without payload body.
*
* return true if succeed otherwise false
*/
virtual bool http_get(std::string const& url,
std::vector<std::string> const& headers,
std::basic_iostream<char>* payload,
std::string& responseHeaders,
bool headerOnly)
{
return false;
}
virtual Util::Proxy* get_proxy()
{
return NULL;
}
// Utility functions to convert enconding between UTF-8 to the encoding
// from system locale. No coversion by default.
virtual std::string UTF8ToPlatformString(const std::string& utf8_str)
{
return std::string(utf8_str);
}
virtual std::string platformStringToUTF8(const std::string& platform_str)
{
return std::string(platform_str);
}
virtual ~IStatementPutGet()
{
}
};
}
}
#endif //SNOWFLAKECLIENT_ISTATEMENT_HPP