BLPAPI C++ 3.26.5
Loading...
Searching...
No Matches
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
35
36#ifndef INCLUDED_BLPAPI_TYPES
37#define INCLUDED_BLPAPI_TYPES
38
69
71
77
78typedef int blpapi_Bool_t;
79typedef char blpapi_Char_t;
80typedef unsigned char blpapi_UChar_t;
81typedef short blpapi_Int16_t;
82typedef unsigned short blpapi_UInt16_t;
83typedef int blpapi_Int32_t;
84typedef unsigned int blpapi_UInt32_t;
85typedef long long blpapi_Int64_t;
86typedef unsigned long long blpapi_UInt64_t;
87typedef float blpapi_Float32_t;
88typedef double blpapi_Float64_t;
89enum blpapi_DataType_t {
90 BLPAPI_DATATYPE_BOOL = 1
91 ,
92 BLPAPI_DATATYPE_CHAR = 2
93 ,
94 BLPAPI_DATATYPE_BYTE = 3
95 ,
96 BLPAPI_DATATYPE_INT32 = 4
97 ,
98 BLPAPI_DATATYPE_INT64 = 5
99 ,
100 BLPAPI_DATATYPE_FLOAT32 = 6
101 ,
102 BLPAPI_DATATYPE_FLOAT64 = 7
103 ,
104 BLPAPI_DATATYPE_STRING = 8
105 ,
106 BLPAPI_DATATYPE_BYTEARRAY = 9
107 ,
108 BLPAPI_DATATYPE_DATE = 10
109 ,
110 BLPAPI_DATATYPE_TIME = 11
111 ,
112 BLPAPI_DATATYPE_DECIMAL = 12
113 ,
114 BLPAPI_DATATYPE_DATETIME = 13
115 ,
116 BLPAPI_DATATYPE_ENUMERATION = 14
117 ,
118 BLPAPI_DATATYPE_SEQUENCE = 15
119 ,
120 BLPAPI_DATATYPE_CHOICE = 16
121 ,
122 BLPAPI_DATATYPE_CORRELATION_ID = 17
123};
124
125typedef enum blpapi_Logging_Severity_t {
126 blpapi_Logging_SEVERITY_OFF = 0,
127 blpapi_Logging_SEVERITY_FATAL = 1,
128 blpapi_Logging_SEVERITY_ERROR = 2,
129 blpapi_Logging_SEVERITY_WARN = 3,
130 blpapi_Logging_SEVERITY_INFO = 4,
131 blpapi_Logging_SEVERITY_DEBUG = 5,
132 blpapi_Logging_SEVERITY_TRACE = 6
133} blpapi_Logging_Severity_t;
134
135struct blpapi_AbstractSession;
136typedef struct blpapi_AbstractSession blpapi_AbstractSession_t;
137
138struct blpapi_Constant;
139typedef struct blpapi_Constant blpapi_Constant_t;
140
141struct blpapi_ConstantList;
142typedef struct blpapi_ConstantList blpapi_ConstantList_t;
143
144struct blpapi_Element;
145typedef struct blpapi_Element blpapi_Element_t;
146
147struct blpapi_Event;
148typedef struct blpapi_Event blpapi_Event_t;
149
150struct blpapi_EventDispatcher;
151typedef struct blpapi_EventDispatcher blpapi_EventDispatcher_t;
152
153struct blpapi_EventFormatter;
154typedef struct blpapi_EventFormatter blpapi_EventFormatter_t;
155
156struct blpapi_EventQueue;
157typedef struct blpapi_EventQueue blpapi_EventQueue_t;
158
159struct blpapi_MessageIterator;
160typedef struct blpapi_MessageIterator blpapi_MessageIterator_t;
161
162struct blpapi_Name;
163typedef struct blpapi_Name blpapi_Name_t;
164
165struct blpapi_Operation;
166typedef struct blpapi_Operation blpapi_Operation_t;
167
168struct blpapi_ProviderSession;
169typedef struct blpapi_ProviderSession blpapi_ProviderSession_t;
170
171struct blpapi_RequestTemplate;
172typedef struct blpapi_RequestTemplate blpapi_RequestTemplate_t;
173
174struct blpapi_Service;
175typedef struct blpapi_Service blpapi_Service_t;
176
177struct blpapi_Session;
178typedef struct blpapi_Session blpapi_Session_t;
179
180struct blpapi_SessionOptions;
181typedef struct blpapi_SessionOptions blpapi_SessionOptions_t;
182
183struct blpapi_Socks5Config;
184typedef struct blpapi_Socks5Config blpapi_Socks5Config_t;
185
186struct blpapi_TlsOptions;
187typedef struct blpapi_TlsOptions blpapi_TlsOptions_t;
188
189struct blpapi_SubscriptionItrerator;
190typedef struct blpapi_SubscriptionItrerator blpapi_SubscriptionIterator_t;
191
192struct blpapi_Identity;
193typedef struct blpapi_Identity blpapi_UserHandle;
194typedef struct blpapi_Identity blpapi_UserHandle_t;
195
196struct blpapi_Identity;
197typedef struct blpapi_Identity blpapi_Identity_t;
198
199struct blpapi_SchemaElementDefinition;
200typedef struct blpapi_SchemaElementDefinition blpapi_SchemaElementDefinition_t;
201
202struct blpapi_Datetime_tag;
203typedef struct blpapi_Datetime_tag blpapi_Datetime_t;
204
205struct blpapi_MessageFormatter;
206typedef struct blpapi_MessageFormatter blpapi_MessageFormatter_t;
207
208struct blpapi_MessageProperties;
209typedef struct blpapi_MessageProperties blpapi_MessageProperties_t;
210
211struct blpapi_AuthOptions;
212typedef struct blpapi_AuthOptions blpapi_AuthOptions_t;
213
214struct blpapi_AuthUser;
215typedef struct blpapi_AuthUser blpapi_AuthUser_t;
216
217struct blpapi_AuthApplication;
218typedef struct blpapi_AuthApplication blpapi_AuthApplication_t;
219
220struct blpapi_AuthToken;
221typedef struct blpapi_AuthToken blpapi_AuthToken_t;
222
226
227#ifdef __cplusplus
228
229#include <cassert>
230#include <cstddef>
231#include <iterator>
232#include <type_traits>
233#include <utility>
234
241
242namespace BloombergLP {
243namespace blpapi {
244
252struct DataType {
253
254 public:
256 enum Value {
257 BOOL = BLPAPI_DATATYPE_BOOL,
258 CHAR = BLPAPI_DATATYPE_CHAR,
259 BYTE = BLPAPI_DATATYPE_BYTE,
260 INT32 = BLPAPI_DATATYPE_INT32,
261 INT64 = BLPAPI_DATATYPE_INT64,
262 FLOAT32 = BLPAPI_DATATYPE_FLOAT32,
263 FLOAT64 = BLPAPI_DATATYPE_FLOAT64,
264 STRING = BLPAPI_DATATYPE_STRING,
265 BYTEARRAY = BLPAPI_DATATYPE_BYTEARRAY,
266 DATE = BLPAPI_DATATYPE_DATE,
267 TIME = BLPAPI_DATATYPE_TIME,
268 DECIMAL = BLPAPI_DATATYPE_DECIMAL,
269 DATETIME = BLPAPI_DATATYPE_DATETIME,
270 ENUMERATION = BLPAPI_DATATYPE_ENUMERATION,
271 SEQUENCE = BLPAPI_DATATYPE_SEQUENCE,
272 CHOICE = BLPAPI_DATATYPE_CHOICE,
273 CORRELATION_ID = BLPAPI_DATATYPE_CORRELATION_ID
275 };
276};
277
278#ifndef DOXYGEN_SHOULD_SKIP_THIS
279
280template <typename T, typename U = bool> struct IsString : std::false_type { };
281
282template <typename T>
283struct IsString<T,
284 typename std::enable_if<
285 std::is_member_function_pointer<decltype(&T::c_str)>::value,
286 bool>::type> : std::true_type { };
287
288template <typename T, typename U = bool>
289struct IsByteSequence : std::false_type { };
290
291template <typename T>
292struct IsByteSequence<T,
293 typename std::enable_if<
294 std::is_member_function_pointer<
295 decltype(static_cast<const typename T::value_type *(
296 T::*)() const>(&T::data))>::value
297 && sizeof(typename T::value_type) == 1
298 && !IsString<T>::value,
299 bool>::type> : std::true_type { };
300
301template <typename T, typename ITER, typename U = bool>
302struct IsByteContainer : std::false_type { };
303
304template <typename T, typename ITER>
305struct IsByteContainer<T,
306 ITER,
307 typename std::enable_if<std::is_constructible<T, ITER, ITER>::value
308 && sizeof(typename T::value_type) == 1,
309 bool>::type> : std::true_type { };
310
311#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS
312
323class Bytes {
324
325 public:
326 typedef const char element_type;
327 typedef char value_type;
328 typedef std::size_t size_type;
329 typedef std::ptrdiff_t difference_type;
330 typedef const char *pointer;
331 typedef const char *const_pointer;
332 typedef const char& reference;
333 typedef const char& const_reference;
334 typedef const char *iterator;
335 typedef const char *const_iterator;
336 typedef std::reverse_iterator<iterator> reverse_iterator;
337 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
338
339 private:
341 const value_type *d_ptr;
343 size_type d_length;
344
345 public:
346 Bytes() noexcept;
350
351 Bytes(pointer ptr, size_type length) noexcept;
357
358 void assign(pointer ptr, size_type length) noexcept;
364
365 iterator begin() const noexcept;
371
372 iterator end() const noexcept;
378
379 reverse_iterator rbegin() const noexcept;
386
387 reverse_iterator rend() const noexcept;
394
395 reference front() const;
400
401 reference back() const;
406
407 reference operator[](size_type index) const;
413
414 pointer data() const noexcept;
418
419 size_type size() const noexcept;
423
424 bool empty() const noexcept;
428
429 Bytes first(size_type count) const;
435
436 Bytes last(size_type count) const;
442
443 Bytes subspan(size_type offset,
444 size_type count = static_cast<std::size_t>(-1)) const;
455
456 template <typename BYTE_CONTAINER,
457 typename std::enable_if<
458 IsByteContainer<BYTE_CONTAINER, iterator>::value,
459 bool>::type
460 = true>
461 operator BYTE_CONTAINER() const;
470};
471
474
475typedef blpapi_Bool_t Bool;
476typedef blpapi_Char_t Char;
477typedef blpapi_UChar_t UChar;
478typedef blpapi_Int16_t Int16;
479typedef blpapi_UInt16_t UInt16;
480typedef blpapi_Int32_t Int32;
481typedef blpapi_UInt32_t UInt32;
482typedef blpapi_Int64_t Int64;
483typedef blpapi_UInt64_t UInt64;
484typedef blpapi_Float32_t Float32;
485typedef blpapi_Float64_t Float64;
486
487//=============================================================================
488// INLINE FUNCTION DEFINITIONS
489//=============================================================================
490
491// -----------
492// class Bytes
493// -----------
494
495inline Bytes::Bytes() noexcept
496 : d_ptr(nullptr)
497 , d_length(0)
498{
499}
500
501inline Bytes::Bytes(pointer ptr, size_type length) noexcept
502 : d_ptr(ptr)
503 , d_length(length)
504{
505}
506
507inline void Bytes::assign(pointer ptr, size_type length) noexcept
508{
509 d_ptr = ptr;
510 d_length = length;
511}
512
513inline Bytes::iterator Bytes::begin() const noexcept { return d_ptr; }
514
515inline Bytes::iterator Bytes::end() const noexcept { return d_ptr + d_length; }
516
518{
519 return reverse_iterator(end());
520}
521
523{
524 return reverse_iterator(begin());
525}
526
528{
529 assert(d_ptr);
530 assert(d_length);
531 return d_ptr[0];
532}
533
535{
536 assert(d_ptr);
537 assert(d_length);
538 return d_ptr[d_length - 1];
539}
540
542{
543 assert(d_ptr);
544 assert(index < d_length);
545 return d_ptr[index];
546}
547
548inline Bytes::pointer Bytes::data() const noexcept { return d_ptr; }
549
550inline Bytes::size_type Bytes::size() const noexcept { return d_length; }
551
552inline bool Bytes::empty() const noexcept { return 0 == d_length; }
553
554inline Bytes Bytes::first(size_type count) const
555{
556 assert(count <= d_length);
557 return Bytes(d_ptr, count);
558}
559
560inline Bytes Bytes::last(size_type count) const
561{
562 assert(count <= d_length);
563 return Bytes(d_ptr + d_length - count, count);
564}
565
566inline Bytes Bytes::subspan(size_type offset, size_type count) const
567{
568 assert(offset <= d_length);
569 assert(count == static_cast<std::size_t>(-1)
570 || count <= d_length - offset);
571 return Bytes(d_ptr + offset,
572 count == static_cast<std::size_t>(-1) ? d_length - offset : count);
573}
574
575template <typename BYTE_CONTAINER,
576 typename std::enable_if<
577 IsByteContainer<BYTE_CONTAINER, Bytes::iterator>::value,
578 bool>::type>
579inline Bytes::operator BYTE_CONTAINER() const
580{
581 assert(d_ptr || d_length == 0);
582 return BYTE_CONTAINER(begin(), end());
583}
584
585} // close namespace blpapi
586} // close namespace BloombergLP
587
588#endif // ifdef __cplusplus
589
590#endif // #ifndef INCLUDED_BLPAPI_TYPES
void assign(pointer ptr, size_type length) noexcept
Definition blpapi_types.h:507
iterator begin() const noexcept
Definition blpapi_types.h:513
const char * iterator
Definition blpapi_types.h:334
Bytes first(size_type count) const
Definition blpapi_types.h:554
reference back() const
Definition blpapi_types.h:534
Bytes last(size_type count) const
Definition blpapi_types.h:560
const char * const_iterator
Definition blpapi_types.h:335
Bytes() noexcept
Definition blpapi_types.h:495
const char element_type
Definition blpapi_types.h:326
reference operator[](size_type index) const
Definition blpapi_types.h:541
bool empty() const noexcept
Definition blpapi_types.h:552
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition blpapi_types.h:337
reverse_iterator rend() const noexcept
Definition blpapi_types.h:522
Bytes subspan(size_type offset, size_type count=static_cast< std::size_t >(-1)) const
Definition blpapi_types.h:566
pointer data() const noexcept
Definition blpapi_types.h:548
const char & reference
Definition blpapi_types.h:332
reverse_iterator rbegin() const noexcept
Definition blpapi_types.h:517
std::size_t size_type
Definition blpapi_types.h:328
std::reverse_iterator< iterator > reverse_iterator
Definition blpapi_types.h:336
size_type size() const noexcept
Definition blpapi_types.h:550
const char & const_reference
Definition blpapi_types.h:333
reference front() const
Definition blpapi_types.h:527
const char * pointer
Definition blpapi_types.h:330
iterator end() const noexcept
Definition blpapi_types.h:515
char value_type
Definition blpapi_types.h:327
std::ptrdiff_t difference_type
Definition blpapi_types.h:329
const char * const_pointer
Definition blpapi_types.h:331
Definition blpapi_abstractsession.h:212
blpapi_Char_t Char
Definition blpapi_types.h:476
blpapi_UInt32_t UInt32
Definition blpapi_types.h:481
blpapi_Bool_t Bool
Definition blpapi_types.h:475
blpapi_Float64_t Float64
Definition blpapi_types.h:485
blpapi_Float32_t Float32
Definition blpapi_types.h:484
blpapi_UInt64_t UInt64
Definition blpapi_types.h:483
blpapi_UInt16_t UInt16
Definition blpapi_types.h:479
blpapi_Int64_t Int64
Definition blpapi_types.h:482
blpapi_UChar_t UChar
Definition blpapi_types.h:477
blpapi_Int32_t Int32
Definition blpapi_types.h:480
blpapi_Int16_t Int16
Definition blpapi_types.h:478
Definition blpapi_abstractsession.h:211
Definition blpapi_types.h:252
Value
The possible data types which can be represented in an Element.
Definition blpapi_types.h:256
@ DATE
Date.
Definition blpapi_types.h:266
@ FLOAT32
32 bit Floating point
Definition blpapi_types.h:262
@ INT64
64 bit Integer
Definition blpapi_types.h:261
@ CHAR
Char.
Definition blpapi_types.h:258
@ DATETIME
Date and time.
Definition blpapi_types.h:269
@ FLOAT64
64 bit Floating point
Definition blpapi_types.h:263
@ BYTE
Unsigned 8 bit value.
Definition blpapi_types.h:259
@ CHOICE
Choice type.
Definition blpapi_types.h:272
@ SEQUENCE
Sequence type.
Definition blpapi_types.h:271
@ INT32
32 bit Integer
Definition blpapi_types.h:260
@ ENUMERATION
An opaque enumeration.
Definition blpapi_types.h:270
@ BYTEARRAY
Opaque binary data.
Definition blpapi_types.h:265
@ BOOL
Boolean.
Definition blpapi_types.h:257
@ TIME
Timestamp.
Definition blpapi_types.h:267
@ STRING
ASCIIZ string.
Definition blpapi_types.h:264
@ DECIMAL
Currently Unsupported.
Definition blpapi_types.h:268
@ CORRELATION_ID
Definition blpapi_types.h:273