BLPAPI C++ 3.25.10
Loading...
Searching...
No Matches
blpapi_subscriptionlist.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_SUBSCRIPTIONLIST
29#define INCLUDED_BLPAPI_SUBSCRIPTIONLIST
30
201#include <blpapi_call.h>
202#include <blpapi_correlationid.h>
203#include <blpapi_defs.h>
204#include <blpapi_deprecate.h>
205#include <blpapi_exception.h>
206#include <blpapi_types.h>
207#include <stddef.h>
208
209struct blpapi_SubscriptionList;
210typedef struct blpapi_SubscriptionList blpapi_SubscriptionList_t;
211
212#ifdef __cplusplus
213extern "C" {
214#endif
215
218
221
224 const char *subscriptionString,
225 const blpapi_CorrelationId_t *correlationId,
226 const char **fields,
227 const char **options,
228 size_t numfields,
229 size_t numOptions);
230
233 const char *subscriptionString,
234 const blpapi_CorrelationId_t *correlationId);
235
238
242
245
248 const blpapi_SubscriptionList_t *list,
249 blpapi_CorrelationId_t *result,
250 size_t index);
251
254 blpapi_SubscriptionList_t *list, const char **result, size_t index);
255
258 blpapi_SubscriptionList_t *list, int *result, size_t index);
259
260#ifdef __cplusplus
261}
262
263#ifndef INCLUDED_CSTRING
264#include <cstring>
265#define INCLUDED_CSTRING
266#endif
267
268#ifndef INCLUDED_STRING
269#include <string>
270#define INCLUDED_STRING
271#endif
272
273#ifndef INCLUDED_VECTOR
274#include <vector>
275#define INCLUDED_VECTOR
276#endif
277
285namespace BloombergLP {
286namespace blpapi {
287
288// ======================
289// class SubscriptionList
290// ======================
291
301
302 blpapi_SubscriptionList_t *d_handle_p;
303
304 public:
309 SubscriptionList(const SubscriptionList& original);
320 // MANIPULATORS
321
322 int add(const char *subscriptionString);
332 int add(const char *subscriptionString,
333 const CorrelationId& correlationId);
343 int add(const char *subscriptionWithoutOptions,
344 const std::vector<std::string>& fields,
345 const std::vector<std::string>& options,
346 const CorrelationId& correlationId);
354 int add(const char *subscriptionWithoutOptions,
355 const char *fields,
356 const char *options,
357 const CorrelationId& correlationId);
366 int add(const CorrelationId& correlationId);
374 BLPAPI_DEPRECATE_PRERESOLVED_TOPICS int addResolved(
375 const char *subscriptionString);
392 BLPAPI_DEPRECATE_PRERESOLVED_TOPICS int addResolved(
393 const char *subscriptionString,
394 const CorrelationId& correlationId);
411 int append(const SubscriptionList& other);
420 void clear();
434 // ACCESSORS
435
436 size_t size() const;
441 CorrelationId correlationIdAt(size_t index) const;
448 const char *topicStringAt(size_t index) const;
458 BLPAPI_DEPRECATE_PRERESOLVED_TOPICS bool isResolvedTopicAt(
459 size_t index) const;
472 const blpapi_SubscriptionList_t *impl() const;
474};
475
479// ============================================================================
480// INLINE FUNCTION DEFINITIONS
481// ============================================================================
482
483// ----------------------
484// class SubscriptionList
485// ----------------------
490
492 : d_handle_p(blpapi_SubscriptionList_create())
493{
494 blpapi_SubscriptionList_append(d_handle_p, original.d_handle_p);
495}
496
501
502inline int SubscriptionList::add(const char *subscriptionString)
503{
504 blpapi_CorrelationId_t correlationId;
505 std::memset(&correlationId, 0, sizeof(correlationId));
507 d_handle_p, subscriptionString, &correlationId, 0, 0, 0, 0);
508}
509
511 const char *subscriptionString, const CorrelationId& correlationId)
512{
514 d_handle_p, subscriptionString, &correlationId.impl(), 0, 0, 0, 0);
515}
516
517inline int SubscriptionList::add(const char *subscriptionString,
518 const std::vector<std::string>& fields,
519 const std::vector<std::string>& options,
520 const CorrelationId& correlationId)
521{
522 std::vector<const char *> tmpVector;
523 const char *arena[256];
524 const char **tmpArray = arena;
525 size_t sizeNeeded = fields.size() + options.size();
526
527 if (sizeNeeded > sizeof(arena) / sizeof(arena[0])) {
528 tmpVector.resize(sizeNeeded);
529 tmpArray = &tmpVector[0];
530 }
531
532 const char **p = tmpArray;
533 for (std::vector<std::string>::const_iterator itr = fields.begin(),
534 end = fields.end();
535 itr != end;
536 ++itr, ++p) {
537 *p = itr->c_str();
538 }
539
540 for (std::vector<std::string>::const_iterator itr = options.begin(),
541 end = options.end();
542 itr != end;
543 ++itr, ++p) {
544 *p = itr->c_str();
545 }
546
547 return blpapi_SubscriptionList_add(d_handle_p,
548 subscriptionString,
549 &correlationId.impl(),
550 tmpArray,
551 tmpArray + fields.size(),
552 fields.size(),
553 options.size());
554}
555
556inline int SubscriptionList::add(const char *subscriptionString,
557 const char *fields,
558 const char *options,
559 const CorrelationId& correlationId)
560{
561 return blpapi_SubscriptionList_add(d_handle_p,
562 subscriptionString,
563 &correlationId.impl(),
564 &fields,
565 &options,
566 fields ? 1u : 0u,
567 options ? 1u : 0u);
568}
569
570inline int SubscriptionList::add(const CorrelationId& correlationId)
571{
573 d_handle_p, "", &correlationId.impl(), 0, 0, 0, 0);
574}
575
576inline int SubscriptionList::addResolved(const char *subscriptionString)
577{
578 blpapi_CorrelationId_t correlationId;
579 std::memset(&correlationId, 0, sizeof(correlationId));
581 d_handle_p, subscriptionString, &correlationId);
582}
583
585 const char *subscriptionString, const CorrelationId& correlationId)
586{
588 d_handle_p, subscriptionString, &correlationId.impl());
589}
590
592{
593 return blpapi_SubscriptionList_append(d_handle_p, other.d_handle_p);
594}
595
597{
599}
600
602 const SubscriptionList& rhs)
603{
604 if (d_handle_p != rhs.d_handle_p) {
606 blpapi_SubscriptionList_append(d_handle_p, rhs.d_handle_p);
607 }
608 return *this;
609}
610
611inline size_t SubscriptionList::size() const
612{
613 return static_cast<size_t>(blpapi_SubscriptionList_size(d_handle_p));
614}
615
617{
618 blpapi_CorrelationId_t correlationId;
619
621 d_handle_p, &correlationId, index));
622
623 return CorrelationId(correlationId);
624}
625
626inline const char *SubscriptionList::topicStringAt(size_t index) const
627{
628 const char *result = 0;
629
631 blpapi_SubscriptionList_topicStringAt(d_handle_p, &result, index));
632
633 return result;
634}
635
636inline bool SubscriptionList::isResolvedTopicAt(size_t index) const
637{
638 int result = 0;
639
641 d_handle_p, &result, index));
642
643 return result ? true : false;
644}
645
646inline const blpapi_SubscriptionList_t *SubscriptionList::impl() const
647{
648 return d_handle_p;
649}
650
651} // close package namespace
652} // close enterprise namespace
653
654#endif // ifdef __cplusplus
655
656#endif // #ifndef INCLUDED_BLPAPI_SUBSCRIPTIONLIST
Provide functions for dispatchtbl.
#define BLPAPI_CALL_SUBSCRIPTIONLIST_ADDRESOLVED(a1, a2, a3)
Definition blpapi_call.h:415
#define BLPAPI_CALL_SUBSCRIPTIONLIST_ISRESOLVEDAT(a1, a2, a3)
Definition blpapi_call.h:417
Provide a key to identify individual subscriptions or requests.
Common definitions used by the library.
#define BLPAPI_EXPORT
Definition blpapi_defs.h:171
struct blpapi_SubscriptionList blpapi_SubscriptionList_t
Definition blpapi_dispatchtbl.h:90
Defines Exceptions that can be thrown by the blpapi library.
BLPAPI_EXPORT int blpapi_SubscriptionList_isResolvedAt(blpapi_SubscriptionList_t *list, int *result, size_t index)
BLPAPI_EXPORT int blpapi_SubscriptionList_append(blpapi_SubscriptionList_t *dest, const blpapi_SubscriptionList_t *src)
BLPAPI_EXPORT int blpapi_SubscriptionList_size(const blpapi_SubscriptionList_t *list)
BLPAPI_EXPORT int blpapi_SubscriptionList_addResolved(blpapi_SubscriptionList_t *list, const char *subscriptionString, const blpapi_CorrelationId_t *correlationId)
BLPAPI_EXPORT int blpapi_SubscriptionList_add(blpapi_SubscriptionList_t *list, const char *subscriptionString, const blpapi_CorrelationId_t *correlationId, const char **fields, const char **options, size_t numfields, size_t numOptions)
BLPAPI_EXPORT int blpapi_SubscriptionList_topicStringAt(blpapi_SubscriptionList_t *list, const char **result, size_t index)
BLPAPI_EXPORT blpapi_SubscriptionList_t * blpapi_SubscriptionList_create(void)
BLPAPI_EXPORT int blpapi_SubscriptionList_clear(blpapi_SubscriptionList_t *list)
BLPAPI_EXPORT void blpapi_SubscriptionList_destroy(blpapi_SubscriptionList_t *list)
BLPAPI_EXPORT int blpapi_SubscriptionList_correlationIdAt(const blpapi_SubscriptionList_t *list, blpapi_CorrelationId_t *result, size_t index)
Provide BLPAPI types.
Definition blpapi_correlationid.h:201
static void throwOnError(int errorCode)
Definition blpapi_exception.h:526
Definition blpapi_subscriptionlist.h:300
const char * topicStringAt(size_t index) const
Definition blpapi_subscriptionlist.h:626
size_t size() const
Definition blpapi_subscriptionlist.h:611
SubscriptionList()
Definition blpapi_subscriptionlist.h:486
SubscriptionList & operator=(const SubscriptionList &rhs)
Definition blpapi_subscriptionlist.h:601
~SubscriptionList()
Definition blpapi_subscriptionlist.h:497
int append(const SubscriptionList &other)
Definition blpapi_subscriptionlist.h:591
CorrelationId correlationIdAt(size_t index) const
Definition blpapi_subscriptionlist.h:616
BLPAPI_DEPRECATE_PRERESOLVED_TOPICS int addResolved(const char *subscriptionString)
Definition blpapi_subscriptionlist.h:576
int add(const char *subscriptionString)
Definition blpapi_subscriptionlist.h:502
void clear()
Definition blpapi_subscriptionlist.h:596
BLPAPI_DEPRECATE_PRERESOLVED_TOPICS bool isResolvedTopicAt(size_t index) const
Definition blpapi_subscriptionlist.h:636
Definition blpapi_abstractsession.h:195