BLPAPI C++  3.24.10
blpapi_socks5config.h
Go to the documentation of this file.
1 /* Copyright 2022. Bloomberg Finance L.P.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions: The above
9  * copyright notice and this permission notice shall be included in all copies
10  * or substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18  * IN THE SOFTWARE.
19  */
20 
28 #ifndef INCLUDED_BLPAPI_SOCKS5CONFIG
29 #define INCLUDED_BLPAPI_SOCKS5CONFIG
30 
60 #include <blpapi_call.h>
61 #include <blpapi_defs.h>
62 #include <blpapi_exception.h>
63 #include <blpapi_streamproxy.h>
64 #include <blpapi_types.h>
65 
66 #ifdef __cplusplus
67 
68 extern "C" {
69 #endif
72  const char *hostname, size_t hostname_size, unsigned short port);
73 
76  blpapi_Socks5Config_t *srcSocks5Config);
77 
80 
83  blpapi_StreamWriter_t streamWriter,
84  void *userStream,
85  int indentLevel,
86  int spacesPerLevel);
87 #ifdef __cplusplus
88 }
89 
90 #include <algorithm>
91 #include <string>
92 
100 namespace BloombergLP {
101 namespace blpapi {
102 
103 class SessionOptions;
104 
113 
114  blpapi_Socks5Config_t *d_handle;
115  // Handle to the internal representation.
116 
117  public:
118  Socks5Config();
119  Socks5Config(const Socks5Config&);
121 
122  Socks5Config(const std::string& hostName, unsigned short port);
129  ~Socks5Config();
134  std::ostream& print(
135  std::ostream& stream, int indentLevel, int spacesPerLevel) const;
136 
138  blpapi_Socks5Config_t *impl() const;
142 };
144 
149  : d_handle(0)
150 {
151 }
152 
153 inline Socks5Config::Socks5Config(const Socks5Config& socks5Config)
154 {
156  &d_handle, socks5Config.d_handle));
157 }
158 
160 {
161  Socks5Config copy(socks5Config);
162  std::swap(d_handle, copy.d_handle);
163  return *this;
164 }
165 
166 inline std::ostream& Socks5Config::print(std::ostream& stream,
167  int indentLevel = 0,
168  int spacesPerLevel = 4) const
169 {
171  (d_handle,
173  &stream,
174  indentLevel,
175  spacesPerLevel);
176  return stream;
177 }
178 
179 std::ostream& operator<<(
180  std::ostream& stream, const Socks5Config& socks5Config);
181 
183  const std::string& hostname, unsigned short port)
184 {
186  hostname.c_str(), hostname.size(), port);
187 }
188 
190 {
192 }
193 
194 inline blpapi_Socks5Config_t *Socks5Config::impl() const { return d_handle; }
195 
196 inline std::ostream& operator<<(
197  std::ostream& stream, const Socks5Config& socks5Config)
198 {
199  socks5Config.print(stream, 0, -1);
200  return stream;
201 }
202 
203 } // end namespace blpapi
204 } // end namespace BloombergLP
205 
206 #endif // #ifdef __cplusplus
207 #endif // #ifndef INCLUDED_BLPAPI_SOCKS5CONFIG
~Socks5Config()
Definition: blpapi_socks5config.h:189
blpapi_Socks5Config_t * blpapi_Socks5Config_create(const char *hostname, size_t hostname_size, unsigned short port)
std::ostream & print(std::ostream &stream, int indentLevel, int spacesPerLevel) const
Definition: blpapi_socks5config.h:166
int blpapi_Socks5Config_print(blpapi_Socks5Config_t *socks5Config, blpapi_StreamWriter_t streamWriter, void *userStream, int indentLevel, int spacesPerLevel)
int blpapi_Socks5Config_copy(blpapi_Socks5Config_t **socks5Config, blpapi_Socks5Config_t *srcSocks5Config)
Common definitions used by the library.
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition: blpapi_event.h:723
Definition: blpapi_abstractsession.h:187
#define BLPAPI_CALL(FUNCNAME)
Definition: blpapi_call.h:353
struct blpapi_Socks5Config blpapi_Socks5Config_t
Definition: blpapi_types.h:175
Definition: blpapi_socks5config.h:112
int(* blpapi_StreamWriter_t)(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:53
static void throwOnError(int errorCode)
Definition: blpapi_exception.h:526
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition: blpapi_correlationid.h:592
Socks5Config & operator=(const Socks5Config &)
Definition: blpapi_socks5config.h:159
void blpapi_Socks5Config_destroy(blpapi_Socks5Config_t *socks5Config)
A signature for callback on print and default C++ implementation.
Socks5Config()
Definition: blpapi_socks5config.h:148
Defines Exceptions that can be thrown by the blpapi library.
#define BLPAPI_CALL_UNCHECKED(FUNCNAME)
Definition: blpapi_call.h:354
static int writeToStream(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:93
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
Provide functions for dispatchtbl.
Provide BLPAPI types.