BLPAPI C++  3.24.4
blpapi_types.h
Go to the documentation of this file.
1 /* Copyright 2012. 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_TYPES
29 #define INCLUDED_BLPAPI_TYPES
30 
62 typedef int blpapi_Bool_t;
63 typedef char blpapi_Char_t;
64 typedef unsigned char blpapi_UChar_t;
65 typedef short blpapi_Int16_t;
66 typedef unsigned short blpapi_UInt16_t;
67 typedef int blpapi_Int32_t;
68 typedef unsigned int blpapi_UInt32_t;
69 typedef long long blpapi_Int64_t;
70 typedef unsigned long long blpapi_UInt64_t;
71 typedef float blpapi_Float32_t;
72 typedef double blpapi_Float64_t;
73 
82  ,
84  ,
86  ,
88  ,
90  ,
92  ,
94  ,
96  ,
98  ,
100  ,
102  ,
104  ,
106  ,
108  ,
110  ,
112  ,
114 };
115 
125 
126 struct blpapi_AbstractSession;
127 typedef struct blpapi_AbstractSession blpapi_AbstractSession_t;
128 
129 struct blpapi_Constant;
130 typedef struct blpapi_Constant blpapi_Constant_t;
131 
132 struct blpapi_ConstantList;
133 typedef struct blpapi_ConstantList blpapi_ConstantList_t;
134 
135 struct blpapi_Element;
136 typedef struct blpapi_Element blpapi_Element_t;
137 
138 struct blpapi_Event;
139 typedef struct blpapi_Event blpapi_Event_t;
140 
141 struct blpapi_EventDispatcher;
142 typedef struct blpapi_EventDispatcher blpapi_EventDispatcher_t;
143 
144 struct blpapi_EventFormatter;
145 typedef struct blpapi_EventFormatter blpapi_EventFormatter_t;
146 
147 struct blpapi_EventQueue;
148 typedef struct blpapi_EventQueue blpapi_EventQueue_t;
149 
150 struct blpapi_MessageIterator;
151 typedef struct blpapi_MessageIterator blpapi_MessageIterator_t;
152 
153 struct blpapi_Name;
154 typedef struct blpapi_Name blpapi_Name_t;
155 
156 struct blpapi_Operation;
157 typedef struct blpapi_Operation blpapi_Operation_t;
158 
159 struct blpapi_ProviderSession;
160 typedef struct blpapi_ProviderSession blpapi_ProviderSession_t;
161 
162 struct blpapi_RequestTemplate;
163 typedef struct blpapi_RequestTemplate blpapi_RequestTemplate_t;
164 
165 struct blpapi_Service;
166 typedef struct blpapi_Service blpapi_Service_t;
167 
168 struct blpapi_Session;
169 typedef struct blpapi_Session blpapi_Session_t;
170 
171 struct blpapi_SessionOptions;
172 typedef struct blpapi_SessionOptions blpapi_SessionOptions_t;
173 
174 struct blpapi_Socks5Config;
175 typedef struct blpapi_Socks5Config blpapi_Socks5Config_t;
176 
177 struct blpapi_TlsOptions;
178 typedef struct blpapi_TlsOptions blpapi_TlsOptions_t;
179 
180 struct blpapi_SubscriptionItrerator;
181 typedef struct blpapi_SubscriptionItrerator blpapi_SubscriptionIterator_t;
182 
183 struct blpapi_Identity;
184 typedef struct blpapi_Identity blpapi_UserHandle;
185 typedef struct blpapi_Identity blpapi_UserHandle_t;
186 
187 struct blpapi_Identity;
188 typedef struct blpapi_Identity blpapi_Identity_t;
189 
190 struct blpapi_SchemaElementDefinition;
191 typedef struct blpapi_SchemaElementDefinition blpapi_SchemaElementDefinition_t;
192 
193 struct blpapi_Datetime_tag;
195 
196 struct blpapi_MessageFormatter;
197 typedef struct blpapi_MessageFormatter blpapi_MessageFormatter_t;
198 
199 struct blpapi_MessageProperties;
200 typedef struct blpapi_MessageProperties blpapi_MessageProperties_t;
201 
202 struct blpapi_AuthOptions;
203 typedef struct blpapi_AuthOptions blpapi_AuthOptions_t;
204 
205 struct blpapi_AuthUser;
206 typedef struct blpapi_AuthUser blpapi_AuthUser_t;
207 
208 struct blpapi_AuthApplication;
209 typedef struct blpapi_AuthApplication blpapi_AuthApplication_t;
210 
211 struct blpapi_AuthToken;
212 typedef struct blpapi_AuthToken blpapi_AuthToken_t;
213 
214 #ifdef __cplusplus
215 
218 #include <cassert>
219 #include <cstddef>
220 #include <iterator>
221 #include <type_traits>
222 #include <utility>
223 
231 namespace BloombergLP {
232 namespace blpapi {
233 
241 struct DataType {
242 
243  public:
245  enum Value {
263  };
265 };
266 
267 #ifndef DOXYGEN_SHOULD_SKIP_THIS
268 
269 template <typename T, typename U = bool> struct IsString : std::false_type { };
270 
271 template <typename T>
272 struct IsString<T,
273  typename std::enable_if<
274  std::is_member_function_pointer<decltype(&T::c_str)>::value,
275  bool>::type> : std::true_type { };
276 
277 template <typename T, typename U = bool>
278 struct IsByteSequence : std::false_type { };
279 
280 template <typename T>
281 struct IsByteSequence<T,
282  typename std::enable_if<
283  std::is_member_function_pointer<
284  decltype(static_cast<const typename T::value_type *(
285  T::*)() const>(&T::data))>::value
286  && sizeof(typename T::value_type) == 1
287  && !IsString<T>::value,
288  bool>::type> : std::true_type { };
289 
290 template <typename T, typename ITER, typename U = bool>
291 struct IsByteContainer : std::false_type { };
292 
293 template <typename T, typename ITER>
294 struct IsByteContainer<T,
295  ITER,
296  typename std::enable_if<std::is_constructible<T, ITER, ITER>::value
297  && sizeof(typename T::value_type) == 1,
298  bool>::type> : std::true_type { };
299 
300 #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS
301 
312 class Bytes {
313 
314  public:
315  typedef const char element_type;
316  typedef char value_type;
317  typedef std::size_t size_type;
318  typedef std::ptrdiff_t difference_type;
319  typedef const char *pointer;
320  typedef const char *const_pointer;
321  typedef const char& reference;
322  typedef const char& const_reference;
323  typedef const char *iterator;
324  typedef const char *const_iterator;
325  typedef std::reverse_iterator<iterator> reverse_iterator;
326  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
327 
328  private:
330  const value_type *d_ptr;
332  size_type d_length;
333 
334  public:
335  Bytes() noexcept;
340  Bytes(pointer ptr, size_type length) noexcept;
347  void assign(pointer ptr, size_type length) noexcept;
354  iterator begin() const noexcept;
361  iterator end() const noexcept;
368  reverse_iterator rbegin() const noexcept;
376  reverse_iterator rend() const noexcept;
384  reference front() const;
390  reference back() const;
396  reference operator[](size_type index) const;
403  pointer data() const noexcept;
408  size_type size() const noexcept;
413  bool empty() const noexcept;
418  Bytes first(size_type count) const;
425  Bytes last(size_type count) const;
432  Bytes subspan(size_type offset,
433  size_type count = static_cast<std::size_t>(-1)) const;
445  template <typename BYTE_CONTAINER,
446  typename std::enable_if<
447  IsByteContainer<BYTE_CONTAINER, iterator>::value,
448  bool>::type
449  = true>
450  operator BYTE_CONTAINER() const;
459 };
460 
475 
476 //=============================================================================
477 // INLINE FUNCTION DEFINITIONS
478 //=============================================================================
479 
480 // -----------
481 // class Bytes
482 // -----------
483 
484 inline Bytes::Bytes() noexcept
485  : d_ptr(nullptr)
486  , d_length(0)
487 {
488 }
489 
490 inline Bytes::Bytes(pointer ptr, size_type length) noexcept
491  : d_ptr(ptr)
492  , d_length(length)
493 {
494 }
495 
496 inline void Bytes::assign(pointer ptr, size_type length) noexcept
497 {
498  d_ptr = ptr;
499  d_length = length;
500 }
501 
502 inline Bytes::iterator Bytes::begin() const noexcept { return d_ptr; }
503 
504 inline Bytes::iterator Bytes::end() const noexcept { return d_ptr + d_length; }
505 
506 inline Bytes::reverse_iterator Bytes::rbegin() const noexcept
507 {
508  return reverse_iterator(end());
509 }
510 
511 inline Bytes::reverse_iterator Bytes::rend() const noexcept
512 {
513  return reverse_iterator(begin());
514 }
515 
517 {
518  assert(d_ptr);
519  assert(d_length);
520  return d_ptr[0];
521 }
522 
524 {
525  assert(d_ptr);
526  assert(d_length);
527  return d_ptr[d_length - 1];
528 }
529 
531 {
532  assert(d_ptr);
533  assert(index < d_length);
534  return d_ptr[index];
535 }
536 
537 inline Bytes::pointer Bytes::data() const noexcept { return d_ptr; }
538 
539 inline Bytes::size_type Bytes::size() const noexcept { return d_length; }
540 
541 inline bool Bytes::empty() const noexcept { return 0 == d_length; }
542 
543 inline Bytes Bytes::first(size_type count) const
544 {
545  assert(count <= d_length);
546  return Bytes(d_ptr, count);
547 }
548 
549 inline Bytes Bytes::last(size_type count) const
550 {
551  assert(count <= d_length);
552  return Bytes(d_ptr + d_length - count, count);
553 }
554 
555 inline Bytes Bytes::subspan(size_type offset, size_type count) const
556 {
557  assert(offset <= d_length);
558  assert(count == static_cast<std::size_t>(-1)
559  || count <= d_length - offset);
560  return Bytes(d_ptr + offset,
561  count == static_cast<std::size_t>(-1) ? d_length - offset : count);
562 }
563 
564 template <typename BYTE_CONTAINER,
565  typename std::enable_if<
566  IsByteContainer<BYTE_CONTAINER, Bytes::iterator>::value,
567  bool>::type>
568 inline Bytes::operator BYTE_CONTAINER() const
569 {
570  assert(d_ptr || d_length == 0);
571  return BYTE_CONTAINER(begin(), end());
572 }
573 
574 } // close namespace blpapi
575 } // close namespace BloombergLP
576 
577 #endif // ifdef __cplusplus
578 
579 #endif // #ifndef INCLUDED_BLPAPI_TYPES
struct blpapi_Identity blpapi_UserHandle_t
Definition: blpapi_types.h:185
32 bit Floating point
Definition: blpapi_types.h:251
Definition: blpapi_types.h:241
Timestamp.
Definition: blpapi_types.h:256
reverse_iterator rbegin() const noexcept
Definition: blpapi_types.h:506
Unsigned 8 bit value.
Definition: blpapi_types.h:248
Definition: blpapi_types.h:120
blpapi_UInt16_t UInt16
Definition: blpapi_types.h:468
struct blpapi_AuthUser blpapi_AuthUser_t
Definition: blpapi_types.h:206
Char.
Definition: blpapi_types.h:247
blpapi_UInt32_t UInt32
Definition: blpapi_types.h:470
blpapi_Int16_t Int16
Definition: blpapi_types.h:467
unsigned short blpapi_UInt16_t
Definition: blpapi_types.h:66
struct blpapi_Element blpapi_Element_t
Definition: blpapi_types.h:136
Definition: blpapi_types.h:103
blpapi_Logging_Severity_t
Definition: blpapi_types.h:116
struct blpapi_Operation blpapi_Operation_t
Definition: blpapi_types.h:157
std::reverse_iterator< iterator > reverse_iterator
Definition: blpapi_types.h:325
iterator begin() const noexcept
Definition: blpapi_types.h:502
struct blpapi_Event blpapi_Event_t
Definition: blpapi_types.h:139
An opaque enumeration.
Definition: blpapi_types.h:107
blpapi_Int32_t Int32
Definition: blpapi_types.h:469
const char * const_pointer
Definition: blpapi_types.h:320
size_type size() const noexcept
Definition: blpapi_types.h:539
Definition: blpapi_types.h:121
Definition: blpapi_abstractsession.h:220
Definition: blpapi_types.h:117
Date.
Definition: blpapi_types.h:99
Choice type.
Definition: blpapi_types.h:261
struct blpapi_AuthToken blpapi_AuthToken_t
Definition: blpapi_types.h:212
An opaque enumeration.
Definition: blpapi_types.h:259
blpapi_Float64_t Float64
Definition: blpapi_types.h:474
64 bit Floating point
Definition: blpapi_types.h:252
reference operator[](size_type index) const
Definition: blpapi_types.h:530
pointer data() const noexcept
Definition: blpapi_types.h:537
struct blpapi_Socks5Config blpapi_Socks5Config_t
Definition: blpapi_types.h:175
Sequence type.
Definition: blpapi_types.h:260
Date and time.
Definition: blpapi_types.h:258
const char * const_iterator
Definition: blpapi_types.h:324
const char & const_reference
Definition: blpapi_types.h:322
Choice type.
Definition: blpapi_types.h:111
int blpapi_Int32_t
Definition: blpapi_types.h:67
struct blpapi_Name blpapi_Name_t
Definition: blpapi_types.h:154
Currently Unsupported.
Definition: blpapi_types.h:257
64 bit Integer
Definition: blpapi_types.h:250
Definition: blpapi_types.h:118
iterator end() const noexcept
Definition: blpapi_types.h:504
int blpapi_Bool_t
Definition: blpapi_types.h:62
blpapi_Float32_t Float32
Definition: blpapi_types.h:473
Definition: blpapi_types.h:262
64 bit Floating point - IEEE
Definition: blpapi_types.h:93
Opaque binary data.
Definition: blpapi_types.h:97
const char * pointer
Definition: blpapi_types.h:319
struct blpapi_EventQueue blpapi_EventQueue_t
Definition: blpapi_types.h:148
reverse_iterator rend() const noexcept
Definition: blpapi_types.h:511
struct blpapi_SchemaElementDefinition blpapi_SchemaElementDefinition_t
Definition: blpapi_types.h:191
char value_type
Definition: blpapi_types.h:316
ASCIIZ string.
Definition: blpapi_types.h:95
struct blpapi_ConstantList blpapi_ConstantList_t
Definition: blpapi_types.h:133
struct blpapi_Constant blpapi_Constant_t
Definition: blpapi_types.h:130
std::ptrdiff_t difference_type
Definition: blpapi_types.h:318
Boolean.
Definition: blpapi_types.h:246
struct blpapi_AuthOptions blpapi_AuthOptions_t
Definition: blpapi_types.h:203
Date and time.
Definition: blpapi_types.h:105
struct blpapi_Identity blpapi_Identity_t
Definition: blpapi_types.h:188
Definition: blpapi_types.h:122
struct blpapi_EventDispatcher blpapi_EventDispatcher_t
Definition: blpapi_types.h:142
reference front() const
Definition: blpapi_types.h:516
unsigned long long blpapi_UInt64_t
Definition: blpapi_types.h:70
ASCIIZ string.
Definition: blpapi_types.h:253
struct blpapi_MessageIterator blpapi_MessageIterator_t
Definition: blpapi_types.h:151
Used for some internal messages.
Definition: blpapi_types.h:113
Bytes last(size_type count) const
Definition: blpapi_types.h:549
const char & reference
Definition: blpapi_types.h:321
bool empty() const noexcept
Definition: blpapi_types.h:541
blpapi_Bool_t Bool
Definition: blpapi_types.h:464
Bool.
Definition: blpapi_types.h:81
blpapi_Int64_t Int64
Definition: blpapi_types.h:471
struct blpapi_MessageProperties blpapi_MessageProperties_t
Definition: blpapi_types.h:200
32 bit Integer
Definition: blpapi_types.h:87
blpapi_DataType_t
Definition: blpapi_types.h:80
struct blpapi_TlsOptions blpapi_TlsOptions_t
Definition: blpapi_types.h:178
Unsigned 8 bit value.
Definition: blpapi_types.h:85
Definition: blpapi_datetime.h:102
Char.
Definition: blpapi_types.h:83
Bytes() noexcept
Definition: blpapi_types.h:484
Opaque binary data.
Definition: blpapi_types.h:254
struct blpapi_EventFormatter blpapi_EventFormatter_t
Definition: blpapi_types.h:145
Definition: blpapi_types.h:123
short blpapi_Int16_t
Definition: blpapi_types.h:65
double blpapi_Float64_t
Definition: blpapi_types.h:72
void assign(pointer ptr, size_type length) noexcept
Definition: blpapi_types.h:496
const char * iterator
Definition: blpapi_types.h:323
struct blpapi_RequestTemplate blpapi_RequestTemplate_t
Definition: blpapi_types.h:163
std::size_t size_type
Definition: blpapi_types.h:317
char blpapi_Char_t
Definition: blpapi_types.h:63
long long blpapi_Int64_t
Definition: blpapi_types.h:69
struct blpapi_SubscriptionItrerator blpapi_SubscriptionIterator_t
Definition: blpapi_types.h:181
32 bit Integer
Definition: blpapi_types.h:249
blpapi_UInt64_t UInt64
Definition: blpapi_types.h:472
blpapi_Char_t Char
Definition: blpapi_types.h:465
Bytes subspan(size_type offset, size_type count=static_cast< std::size_t >(-1)) const
Definition: blpapi_types.h:555
struct blpapi_AbstractSession blpapi_AbstractSession_t
Definition: blpapi_types.h:127
unsigned char blpapi_UChar_t
Definition: blpapi_types.h:64
struct blpapi_Session blpapi_Session_t
Definition: blpapi_types.h:169
struct blpapi_Identity blpapi_UserHandle
Definition: blpapi_types.h:184
float blpapi_Float32_t
Definition: blpapi_types.h:71
struct blpapi_ProviderSession blpapi_ProviderSession_t
Definition: blpapi_types.h:160
64 bit Integer
Definition: blpapi_types.h:89
32 bit Floating point - IEEE
Definition: blpapi_types.h:91
struct blpapi_AuthApplication blpapi_AuthApplication_t
Definition: blpapi_types.h:209
unsigned int blpapi_UInt32_t
Definition: blpapi_types.h:68
blpapi_UChar_t UChar
Definition: blpapi_types.h:466
struct blpapi_MessageFormatter blpapi_MessageFormatter_t
Definition: blpapi_types.h:197
struct blpapi_Service blpapi_Service_t
Definition: blpapi_types.h:166
Value
The possible data types which can be represented in an Element.
Definition: blpapi_types.h:245
const char element_type
Definition: blpapi_types.h:315
struct blpapi_SessionOptions blpapi_SessionOptions_t
Definition: blpapi_types.h:172
Timestamp.
Definition: blpapi_types.h:101
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: blpapi_types.h:326
Definition: blpapi_types.h:119
Bytes first(size_type count) const
Definition: blpapi_types.h:543
Definition: blpapi_types.h:312
Sequence type.
Definition: blpapi_types.h:109
Date.
Definition: blpapi_types.h:255
reference back() const
Definition: blpapi_types.h:523