BLPAPI C++ 3.26.6
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
37
38#ifndef INCLUDED_BLPAPI_TYPES
39#define INCLUDED_BLPAPI_TYPES
40
70
72
78
80typedef int blpapi_Bool_t;
82typedef char blpapi_Char_t;
84typedef unsigned char blpapi_UChar_t;
86typedef short blpapi_Int16_t;
88typedef unsigned short blpapi_UInt16_t;
90typedef int blpapi_Int32_t;
92typedef unsigned int blpapi_UInt32_t;
94typedef long long blpapi_Int64_t;
96typedef unsigned long long blpapi_UInt64_t;
98typedef float blpapi_Float32_t;
100typedef double blpapi_Float64_t;
102enum blpapi_DataType_t {
104 BLPAPI_DATATYPE_BOOL = 1,
106 BLPAPI_DATATYPE_CHAR = 2,
108 BLPAPI_DATATYPE_BYTE = 3,
110 BLPAPI_DATATYPE_INT32 = 4,
112 BLPAPI_DATATYPE_INT64 = 5,
114 BLPAPI_DATATYPE_FLOAT32 = 6,
116 BLPAPI_DATATYPE_FLOAT64 = 7,
118 BLPAPI_DATATYPE_STRING = 8,
120 BLPAPI_DATATYPE_BYTEARRAY = 9,
122 BLPAPI_DATATYPE_DATE = 10,
124 BLPAPI_DATATYPE_TIME = 11,
126 BLPAPI_DATATYPE_DECIMAL = 12,
128 BLPAPI_DATATYPE_DATETIME = 13,
130 BLPAPI_DATATYPE_ENUMERATION = 14,
132 BLPAPI_DATATYPE_SEQUENCE = 15,
134 BLPAPI_DATATYPE_CHOICE = 16,
136 BLPAPI_DATATYPE_CORRELATION_ID = 17
137};
138
140typedef enum blpapi_Logging_Severity_t {
142 blpapi_Logging_SEVERITY_OFF = 0,
144 blpapi_Logging_SEVERITY_FATAL = 1,
146 blpapi_Logging_SEVERITY_ERROR = 2,
148 blpapi_Logging_SEVERITY_WARN = 3,
150 blpapi_Logging_SEVERITY_INFO = 4,
152 blpapi_Logging_SEVERITY_DEBUG = 5,
154 blpapi_Logging_SEVERITY_TRACE = 6
155} blpapi_Logging_Severity_t;
156
157struct blpapi_AbstractSession;
159typedef struct blpapi_AbstractSession blpapi_AbstractSession_t;
160
161struct blpapi_Constant;
163typedef struct blpapi_Constant blpapi_Constant_t;
164
165struct blpapi_ConstantList;
167typedef struct blpapi_ConstantList blpapi_ConstantList_t;
168
169struct blpapi_Element;
171typedef struct blpapi_Element blpapi_Element_t;
172
173struct blpapi_Event;
175typedef struct blpapi_Event blpapi_Event_t;
176
177struct blpapi_EventDispatcher;
179typedef struct blpapi_EventDispatcher blpapi_EventDispatcher_t;
180
181struct blpapi_EventFormatter;
183typedef struct blpapi_EventFormatter blpapi_EventFormatter_t;
184
185struct blpapi_EventQueue;
187typedef struct blpapi_EventQueue blpapi_EventQueue_t;
188
189struct blpapi_MessageIterator;
191typedef struct blpapi_MessageIterator blpapi_MessageIterator_t;
192
193struct blpapi_Name;
195typedef struct blpapi_Name blpapi_Name_t;
196
197struct blpapi_Operation;
199typedef struct blpapi_Operation blpapi_Operation_t;
200
201struct blpapi_ProviderSession;
203typedef struct blpapi_ProviderSession blpapi_ProviderSession_t;
204
205struct blpapi_RequestTemplate;
207typedef struct blpapi_RequestTemplate blpapi_RequestTemplate_t;
208
209struct blpapi_Service;
211typedef struct blpapi_Service blpapi_Service_t;
212
213struct blpapi_Session;
215typedef struct blpapi_Session blpapi_Session_t;
216
217struct blpapi_SessionOptions;
219typedef struct blpapi_SessionOptions blpapi_SessionOptions_t;
220
221struct blpapi_Socks5Config;
223typedef struct blpapi_Socks5Config blpapi_Socks5Config_t;
224
225struct blpapi_TlsOptions;
227typedef struct blpapi_TlsOptions blpapi_TlsOptions_t;
228
229struct blpapi_SubscriptionItrerator;
231typedef struct blpapi_SubscriptionItrerator blpapi_SubscriptionIterator_t;
232
233struct blpapi_Identity;
238typedef struct blpapi_Identity blpapi_UserHandle;
243typedef struct blpapi_Identity blpapi_UserHandle_t;
245typedef struct blpapi_Identity blpapi_Identity_t;
246
247struct blpapi_SchemaElementDefinition;
249typedef struct blpapi_SchemaElementDefinition blpapi_SchemaElementDefinition_t;
250
251struct blpapi_Datetime_tag;
253typedef struct blpapi_Datetime_tag blpapi_Datetime_t;
254
255struct blpapi_MessageFormatter;
257typedef struct blpapi_MessageFormatter blpapi_MessageFormatter_t;
258
259struct blpapi_MessageProperties;
261typedef struct blpapi_MessageProperties blpapi_MessageProperties_t;
262
263struct blpapi_AuthOptions;
265typedef struct blpapi_AuthOptions blpapi_AuthOptions_t;
266
267struct blpapi_AuthUser;
269typedef struct blpapi_AuthUser blpapi_AuthUser_t;
270
271struct blpapi_AuthApplication;
273typedef struct blpapi_AuthApplication blpapi_AuthApplication_t;
274
275struct blpapi_AuthToken;
277typedef struct blpapi_AuthToken blpapi_AuthToken_t;
278
282
283#ifdef __cplusplus
284
285#include <cassert>
286#include <cstddef>
287#include <iterator>
288#include <type_traits>
289#include <utility>
290
291namespace BloombergLP {
292namespace blpapi {
299
307struct DataType {
308
309 public:
311 enum Value {
313 BOOL = BLPAPI_DATATYPE_BOOL,
315 CHAR = BLPAPI_DATATYPE_CHAR,
317 BYTE = BLPAPI_DATATYPE_BYTE,
319 INT32 = BLPAPI_DATATYPE_INT32,
321 INT64 = BLPAPI_DATATYPE_INT64,
323 FLOAT32 = BLPAPI_DATATYPE_FLOAT32,
325 FLOAT64 = BLPAPI_DATATYPE_FLOAT64,
327 STRING = BLPAPI_DATATYPE_STRING,
329 BYTEARRAY = BLPAPI_DATATYPE_BYTEARRAY,
331 DATE = BLPAPI_DATATYPE_DATE,
333 TIME = BLPAPI_DATATYPE_TIME,
335 DECIMAL = BLPAPI_DATATYPE_DECIMAL,
337 DATETIME = BLPAPI_DATATYPE_DATETIME,
339 ENUMERATION = BLPAPI_DATATYPE_ENUMERATION,
341 SEQUENCE = BLPAPI_DATATYPE_SEQUENCE,
343 CHOICE = BLPAPI_DATATYPE_CHOICE,
345 CORRELATION_ID = BLPAPI_DATATYPE_CORRELATION_ID
347 };
348};
349
350#ifndef DOXYGEN_SHOULD_SKIP_THIS
351
352template <typename T, typename U = bool> struct IsString : std::false_type { };
353
354template <typename T>
355struct IsString<T,
356 typename std::enable_if<
357 std::is_member_function_pointer<decltype(&T::c_str)>::value,
358 bool>::type> : std::true_type { };
359
360template <typename T, typename U = bool>
361struct IsByteSequence : std::false_type { };
362
363template <typename T>
364struct IsByteSequence<T,
365 typename std::enable_if<
366 std::is_member_function_pointer<
367 decltype(static_cast<const typename T::value_type *(
368 T::*)() const>(&T::data))>::value
369 && sizeof(typename T::value_type) == 1
370 && !IsString<T>::value,
371 bool>::type> : std::true_type { };
372
373template <typename T, typename ITER, typename U = bool>
374struct IsByteContainer : std::false_type { };
375
376template <typename T, typename ITER>
377struct IsByteContainer<T,
378 ITER,
379 typename std::enable_if<std::is_constructible<T, ITER, ITER>::value
380 && sizeof(typename T::value_type) == 1,
381 bool>::type> : std::true_type { };
382
383#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS
384
395class Bytes {
396
397 public:
398 typedef const char element_type;
399 typedef char value_type;
400 typedef std::size_t size_type;
401 typedef std::ptrdiff_t difference_type;
402 typedef const char *pointer;
403 typedef const char *const_pointer;
404 typedef const char& reference;
405 typedef const char& const_reference;
406 typedef const char *iterator;
407 typedef const char *const_iterator;
408 typedef std::reverse_iterator<iterator>
410 typedef std::reverse_iterator<const_iterator>
412
413 private:
415 const value_type *d_ptr;
417 size_type d_length;
418
419 public:
420 Bytes() noexcept;
424
425 Bytes(pointer ptr, size_type length) noexcept;
431
432 void assign(pointer ptr, size_type length) noexcept;
438
439 iterator begin() const noexcept;
445
446 iterator end() const noexcept;
452
453 reverse_iterator rbegin() const noexcept;
460
461 reverse_iterator rend() const noexcept;
468
469 reference front() const;
474
475 reference back() const;
480
481 reference operator[](size_type index) const;
487
488 pointer data() const noexcept;
492
493 size_type size() const noexcept;
497
498 bool empty() const noexcept;
502
503 Bytes first(size_type count) const;
509
510 Bytes last(size_type count) const;
516
517 Bytes subspan(size_type offset,
518 size_type count = static_cast<std::size_t>(-1)) const;
529
530 template <typename BYTE_CONTAINER,
531 typename std::enable_if<
532 IsByteContainer<BYTE_CONTAINER, iterator>::value,
533 bool>::type
534 = true>
535 operator BYTE_CONTAINER() const;
544};
545
548
549typedef blpapi_Bool_t Bool;
550typedef blpapi_Char_t Char;
551typedef blpapi_UChar_t UChar;
552typedef blpapi_Int16_t Int16;
553typedef blpapi_UInt16_t UInt16;
554typedef blpapi_Int32_t Int32;
555typedef blpapi_UInt32_t UInt32;
556typedef blpapi_Int64_t Int64;
557typedef blpapi_UInt64_t UInt64;
558typedef blpapi_Float32_t Float32;
559typedef blpapi_Float64_t Float64;
560
561//=============================================================================
562// INLINE FUNCTION DEFINITIONS
563//=============================================================================
564
565// -----------
566// class Bytes
567// -----------
568
569inline Bytes::Bytes() noexcept
570 : d_ptr(nullptr)
571 , d_length(0)
572{
573}
574
575inline Bytes::Bytes(pointer ptr, size_type length) noexcept
576 : d_ptr(ptr)
577 , d_length(length)
578{
579}
580
581inline void Bytes::assign(pointer ptr, size_type length) noexcept
582{
583 d_ptr = ptr;
584 d_length = length;
585}
586
587inline Bytes::iterator Bytes::begin() const noexcept { return d_ptr; }
588
589inline Bytes::iterator Bytes::end() const noexcept { return d_ptr + d_length; }
590
592{
593 return reverse_iterator(end());
594}
595
597{
598 return reverse_iterator(begin());
599}
600
602{
603 assert(d_ptr);
604 assert(d_length);
605 return d_ptr[0];
606}
607
609{
610 assert(d_ptr);
611 assert(d_length);
612 return d_ptr[d_length - 1];
613}
614
616{
617 assert(d_ptr);
618 assert(index < d_length);
619 return d_ptr[index];
620}
621
622inline Bytes::pointer Bytes::data() const noexcept { return d_ptr; }
623
624inline Bytes::size_type Bytes::size() const noexcept { return d_length; }
625
626inline bool Bytes::empty() const noexcept { return 0 == d_length; }
627
628inline Bytes Bytes::first(size_type count) const
629{
630 assert(count <= d_length);
631 return Bytes(d_ptr, count);
632}
633
634inline Bytes Bytes::last(size_type count) const
635{
636 assert(count <= d_length);
637 return Bytes(d_ptr + d_length - count, count);
638}
639
640inline Bytes Bytes::subspan(size_type offset, size_type count) const
641{
642 assert(offset <= d_length);
643 assert(count == static_cast<std::size_t>(-1)
644 || count <= d_length - offset);
645 return Bytes(d_ptr + offset,
646 count == static_cast<std::size_t>(-1) ? d_length - offset : count);
647}
648
649template <typename BYTE_CONTAINER,
650 typename std::enable_if<
651 IsByteContainer<BYTE_CONTAINER, Bytes::iterator>::value,
652 bool>::type>
653inline Bytes::operator BYTE_CONTAINER() const
654{
655 assert(d_ptr || d_length == 0);
656 return BYTE_CONTAINER(begin(), end());
657}
658
659} // close namespace blpapi
660} // close namespace BloombergLP
661
662#endif // ifdef __cplusplus
663
664#endif // #ifndef INCLUDED_BLPAPI_TYPES
void assign(pointer ptr, size_type length) noexcept
Definition blpapi_types.h:581
iterator begin() const noexcept
Definition blpapi_types.h:587
const char * iterator
Iterator type (const char*).
Definition blpapi_types.h:406
Bytes first(size_type count) const
Definition blpapi_types.h:628
reference back() const
Definition blpapi_types.h:608
Bytes last(size_type count) const
Definition blpapi_types.h:634
const char * const_iterator
Const iterator type (const char*).
Definition blpapi_types.h:407
Bytes() noexcept
Definition blpapi_types.h:569
const char element_type
The element type (const char).
Definition blpapi_types.h:398
reference operator[](size_type index) const
Definition blpapi_types.h:615
bool empty() const noexcept
Definition blpapi_types.h:626
std::reverse_iterator< const_iterator > const_reverse_iterator
Const reverse iterator type.
Definition blpapi_types.h:411
reverse_iterator rend() const noexcept
Definition blpapi_types.h:596
Bytes subspan(size_type offset, size_type count=static_cast< std::size_t >(-1)) const
Definition blpapi_types.h:640
pointer data() const noexcept
Definition blpapi_types.h:622
const char & reference
Reference to element.
Definition blpapi_types.h:404
reverse_iterator rbegin() const noexcept
Definition blpapi_types.h:591
std::size_t size_type
Unsigned size type.
Definition blpapi_types.h:400
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator type.
Definition blpapi_types.h:409
size_type size() const noexcept
Definition blpapi_types.h:624
const char & const_reference
Const reference to element.
Definition blpapi_types.h:405
reference front() const
Definition blpapi_types.h:601
const char * pointer
Pointer to element.
Definition blpapi_types.h:402
iterator end() const noexcept
Definition blpapi_types.h:589
char value_type
The value type (char).
Definition blpapi_types.h:399
std::ptrdiff_t difference_type
Signed difference type.
Definition blpapi_types.h:401
const char * const_pointer
Const pointer to element.
Definition blpapi_types.h:403
Definition blpapi_abstractsession.h:452
blpapi_Char_t Char
8-bit character type alias.
Definition blpapi_types.h:550
blpapi_UInt32_t UInt32
32-bit unsigned integer type alias.
Definition blpapi_types.h:555
blpapi_Bool_t Bool
Boolean type alias.
Definition blpapi_types.h:549
blpapi_Float64_t Float64
64-bit IEEE 754 float type alias.
Definition blpapi_types.h:559
blpapi_Float32_t Float32
32-bit IEEE 754 float type alias.
Definition blpapi_types.h:558
blpapi_UInt64_t UInt64
64-bit unsigned integer type alias.
Definition blpapi_types.h:557
blpapi_UInt16_t UInt16
16-bit unsigned integer type alias.
Definition blpapi_types.h:553
blpapi_Int64_t Int64
64-bit signed integer type alias.
Definition blpapi_types.h:556
blpapi_UChar_t UChar
8-bit unsigned integer type alias.
Definition blpapi_types.h:551
blpapi_Int32_t Int32
32-bit signed integer type alias.
Definition blpapi_types.h:554
blpapi_Int16_t Int16
16-bit signed integer type alias.
Definition blpapi_types.h:552
Definition blpapi_abstractsession.h:451
Definition blpapi_types.h:307
Value
The possible data types which can be represented in an Element.
Definition blpapi_types.h:311
@ DATE
Date.
Definition blpapi_types.h:331
@ FLOAT32
32 bit Floating point
Definition blpapi_types.h:323
@ INT64
64 bit Integer
Definition blpapi_types.h:321
@ CHAR
Char.
Definition blpapi_types.h:315
@ DATETIME
Date and time.
Definition blpapi_types.h:337
@ FLOAT64
64 bit Floating point
Definition blpapi_types.h:325
@ BYTE
Unsigned 8 bit value.
Definition blpapi_types.h:317
@ CHOICE
Choice type.
Definition blpapi_types.h:343
@ SEQUENCE
Sequence type.
Definition blpapi_types.h:341
@ INT32
32 bit Integer
Definition blpapi_types.h:319
@ ENUMERATION
An opaque enumeration.
Definition blpapi_types.h:339
@ BYTEARRAY
Opaque binary data.
Definition blpapi_types.h:329
@ BOOL
Boolean.
Definition blpapi_types.h:313
@ TIME
Timestamp.
Definition blpapi_types.h:333
@ STRING
ASCIIZ string.
Definition blpapi_types.h:327
@ DECIMAL
Currently Unsupported.
Definition blpapi_types.h:335
@ CORRELATION_ID
Used for some.
Definition blpapi_types.h:345