BLPAPI C++ 3.26.7
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
561namespace util {
562
566
567constexpr const char *to_string(DataType::Value type);
571
573
574} // close namespace util
575
576//=============================================================================
577// INLINE FUNCTION DEFINITIONS
578//=============================================================================
579
580// -----------
581// class Bytes
582// -----------
583
584inline Bytes::Bytes() noexcept
585 : d_ptr(nullptr)
586 , d_length(0)
587{
588}
589
590inline Bytes::Bytes(pointer ptr, size_type length) noexcept
591 : d_ptr(ptr)
592 , d_length(length)
593{
594}
595
596inline void Bytes::assign(pointer ptr, size_type length) noexcept
597{
598 d_ptr = ptr;
599 d_length = length;
600}
601
602inline Bytes::iterator Bytes::begin() const noexcept { return d_ptr; }
603
604inline Bytes::iterator Bytes::end() const noexcept { return d_ptr + d_length; }
605
607{
608 return reverse_iterator(end());
609}
610
612{
613 return reverse_iterator(begin());
614}
615
617{
618 assert(d_ptr);
619 assert(d_length);
620 return d_ptr[0];
621}
622
624{
625 assert(d_ptr);
626 assert(d_length);
627 return d_ptr[d_length - 1];
628}
629
631{
632 assert(d_ptr);
633 assert(index < d_length);
634 return d_ptr[index];
635}
636
637inline Bytes::pointer Bytes::data() const noexcept { return d_ptr; }
638
639inline Bytes::size_type Bytes::size() const noexcept { return d_length; }
640
641inline bool Bytes::empty() const noexcept { return 0 == d_length; }
642
643inline Bytes Bytes::first(size_type count) const
644{
645 assert(count <= d_length);
646 return Bytes(d_ptr, count);
647}
648
649inline Bytes Bytes::last(size_type count) const
650{
651 assert(count <= d_length);
652 return Bytes(d_ptr + d_length - count, count);
653}
654
655inline Bytes Bytes::subspan(size_type offset, size_type count) const
656{
657 assert(offset <= d_length);
658 assert(count == static_cast<std::size_t>(-1)
659 || count <= d_length - offset);
660 return Bytes(d_ptr + offset,
661 count == static_cast<std::size_t>(-1) ? d_length - offset : count);
662}
663
664template <typename BYTE_CONTAINER,
665 typename std::enable_if<
666 IsByteContainer<BYTE_CONTAINER, Bytes::iterator>::value,
667 bool>::type>
668inline Bytes::operator BYTE_CONTAINER() const
669{
670 assert(d_ptr || d_length == 0);
671 return BYTE_CONTAINER(begin(), end());
672}
673
674// --------------
675// namespace util
676// --------------
677constexpr const char *util::to_string(DataType::Value type)
678{
679 switch (type) {
680 case DataType::BOOL:
681 return "BOOL";
682 case DataType::CHAR:
683 return "CHAR";
684 case DataType::BYTE:
685 return "BYTE";
686 case DataType::INT32:
687 return "INT32";
688 case DataType::INT64:
689 return "INT64";
691 return "FLOAT32";
693 return "FLOAT64";
694 case DataType::STRING:
695 return "STRING";
697 return "BYTEARRAY";
698 case DataType::DATE:
699 return "DATE";
700 case DataType::TIME:
701 return "TIME";
703 return "DECIMAL";
705 return "DATETIME";
707 return "ENUMERATION";
709 return "SEQUENCE";
710 case DataType::CHOICE:
711 return "CHOICE";
713 return "CORRELATION_ID";
714 }
715 // Silence warnings on some compilers
716 return "UNDEFINED";
717}
718
719} // close namespace blpapi
720} // close namespace BloombergLP
721
722#endif // ifdef __cplusplus
723
724#endif // #ifndef INCLUDED_BLPAPI_TYPES
void assign(pointer ptr, size_type length) noexcept
Definition blpapi_types.h:596
iterator begin() const noexcept
Definition blpapi_types.h:602
const char * iterator
Iterator type (const char*).
Definition blpapi_types.h:406
Bytes first(size_type count) const
Definition blpapi_types.h:643
reference back() const
Definition blpapi_types.h:623
Bytes last(size_type count) const
Definition blpapi_types.h:649
const char * const_iterator
Const iterator type (const char*).
Definition blpapi_types.h:407
Bytes() noexcept
Definition blpapi_types.h:584
const char element_type
The element type (const char).
Definition blpapi_types.h:398
reference operator[](size_type index) const
Definition blpapi_types.h:630
bool empty() const noexcept
Definition blpapi_types.h:641
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:611
Bytes subspan(size_type offset, size_type count=static_cast< std::size_t >(-1)) const
Definition blpapi_types.h:655
pointer data() const noexcept
Definition blpapi_types.h:637
const char & reference
Reference to element.
Definition blpapi_types.h:404
reverse_iterator rbegin() const noexcept
Definition blpapi_types.h:606
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:639
const char & const_reference
Const reference to element.
Definition blpapi_types.h:405
reference front() const
Definition blpapi_types.h:616
const char * pointer
Pointer to element.
Definition blpapi_types.h:402
iterator end() const noexcept
Definition blpapi_types.h:604
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
constexpr const char * to_string(CorrelationId::ValueType valueType)
Definition blpapi_correlationid.h:830
Definition blpapi_correlationid.h:499
Definition blpapi_abstractsession.h:448
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:447
Definition blpapi_correlationidhash.h:63
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