BLPAPI C++  3.23.2
blpapi_constant.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_CONSTANT
29 #define INCLUDED_BLPAPI_CONSTANT
30 
65 #ifndef INCLUDED_BLPAPI_TYPES
66 #include <blpapi_types.h>
67 #endif
68 
69 #ifndef INCLUDED_BLPAPI_NAME
70 #include <blpapi_name.h>
71 #endif
72 
73 #ifndef INCLUDED_BLPAPI_DEFS
74 #include <blpapi_defs.h>
75 #endif
76 
77 #ifndef INCLUDED_BLPAPI_DATETIME
78 #include <blpapi_datetime.h>
79 #endif
80 
81 #ifndef INCLUDED_BLPAPI_EXCEPTION
82 #include <blpapi_exception.h>
83 #endif
84 
85 #include <stddef.h>
86 
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
92 void blpapi_Constant_setUserData(blpapi_Constant_t *constant, void *userdata);
93 
96 
98 const char *blpapi_Constant_description(const blpapi_Constant_t *constant);
99 
101 int blpapi_Constant_status(const blpapi_Constant_t *constant);
102 
104 int blpapi_Constant_datatype(const blpapi_Constant_t *constant);
105 
108  const blpapi_Constant_t *constant, blpapi_Char_t *buffer);
109 
112  const blpapi_Constant_t *constant, blpapi_Int32_t *buffer);
113 
116  const blpapi_Constant_t *constant, blpapi_Int64_t *buffer);
117 
120  const blpapi_Constant_t *constant, blpapi_Float32_t *buffer);
121 
124  const blpapi_Constant_t *constant, blpapi_Float64_t *buffer);
125 
128  const blpapi_Constant_t *constant, blpapi_Datetime_t *buffer);
129 
132  const blpapi_Constant_t *constant, const char **buffer);
133 
135 void *blpapi_Constant_userData(const blpapi_Constant_t *constant);
136 
139  blpapi_ConstantList_t *constant, void *userdata);
140 
143 
146 
149 
152 
155 
158  const blpapi_ConstantList_t *constant,
159  const char *nameString,
160  const blpapi_Name_t *name);
161 
164  const blpapi_ConstantList_t *constant, size_t index);
165 
168 
169 #ifdef __cplusplus
170 }
171 
172 #include <cassert>
173 
181 namespace BloombergLP {
182 namespace blpapi {
183 
210 class Constant {
211 
212  blpapi_Constant_t *d_impl_p;
213 
214  public:
215  Constant(blpapi_Constant_t *handle);
216  /*
217  * Create a <code>Constant</code> object having the same value as the
218  * specified <code>original</code>. Note that this function does
219  * <em>not</em> require cross-object thread synchronization, as it does not
220  * directly read or modify the <code>userData</code> field.
221  */
222 
223  void setUserData(void *userData);
232  Name name() const;
237  const char *description() const;
244  int status() const;
250  int datatype() const;
257  int getValueAs(char *buffer) const;
265  int getValueAs(Int32 *buffer) const;
273  int getValueAs(Int64 *buffer) const;
281  int getValueAs(Float32 *buffer) const;
289  int getValueAs(Float64 *buffer) const;
297  int getValueAs(Datetime *buffer) const;
305  int getValueAs(std::string *buffer) const;
313  char getValueAsChar() const;
319  Int32 getValueAsInt32() const;
325  Int64 getValueAsInt64() const;
331  Float32 getValueAsFloat32() const;
337  Float64 getValueAsFloat64() const;
349  std::string getValueAsString() const;
355  void *userData() const;
367  const blpapi_Constant_t *impl() const;
368 };
369 
397 
398  blpapi_ConstantList_t *d_impl_p;
399 
400  public:
402  /*
403  * Create a <code>ConstantList</code> object having the same value as
404  * the specified <code>original</code>. Note that this function does
405  * <em>not</em> require cross-object thread synchronization, as it does not
406  * directly read or modify the <code>userData</code> field.
407  */
408 
409  void setUserData(void *userData);
418  Name name() const;
423  const char *description() const;
430  int status() const;
436  int numConstants() const;
442  int datatype() const;
449  Constant getConstant(const Name& name) const;
457  Constant getConstant(const char *name) const;
465  Constant getConstantAt(size_t index) const;
473  void *userData() const;
485  const blpapi_ConstantList_t *impl() const;
489 };
490 
494 //=============================================================================
495 // INLINE FUNCTION DEFINITIONS
496 //=============================================================================
497 
499  : d_impl_p(handle)
500 {
501 }
502 
503 inline Name Constant::name() const { return blpapi_Constant_name(d_impl_p); }
504 
505 inline const char *Constant::description() const
506 {
507  return blpapi_Constant_description(d_impl_p);
508 }
509 
510 inline int Constant::status() const
511 {
512  return blpapi_Constant_status(d_impl_p);
513 }
514 
515 inline int Constant::datatype() const
516 {
517  return blpapi_Constant_datatype(d_impl_p);
518 }
519 
520 inline const blpapi_Constant_t *Constant::impl() const { return d_impl_p; }
521 
522 inline int Constant::getValueAs(char *buffer) const
523 {
524  return blpapi_Constant_getValueAsChar(d_impl_p, buffer);
525 }
526 
527 inline int Constant::getValueAs(Int32 *buffer) const
528 {
529  return blpapi_Constant_getValueAsInt32(d_impl_p, buffer);
530 }
531 
532 inline int Constant::getValueAs(Int64 *buffer) const
533 {
534  return blpapi_Constant_getValueAsInt64(d_impl_p, buffer);
535 }
536 
537 inline int Constant::getValueAs(Float32 *buffer) const
538 {
539  return blpapi_Constant_getValueAsFloat32(d_impl_p, buffer);
540 }
541 
542 inline int Constant::getValueAs(Float64 *buffer) const
543 {
544  return blpapi_Constant_getValueAsFloat64(d_impl_p, buffer);
545 }
546 
547 inline int Constant::getValueAs(Datetime *buffer) const
548 {
549  assert(buffer);
550 
551  return blpapi_Constant_getValueAsDatetime(d_impl_p, &buffer->rawValue());
552 }
553 
554 inline int Constant::getValueAs(std::string *result) const
555 {
556  const char *buffer = 0;
557  int rc = blpapi_Constant_getValueAsString(d_impl_p, &buffer);
558  if (!rc) {
559  *result = buffer;
560  }
561  return rc;
562 }
563 
564 inline char Constant::getValueAsChar() const
565 {
566  char value = 0;
568  return value;
569 }
570 
572 {
573  int value = 0;
575  return value;
576 }
577 
579 {
580  Int64 value = 0;
582  return value;
583 }
584 
585 inline float Constant::getValueAsFloat32() const
586 {
587  Float32 value = 0.0;
589  return value;
590 }
591 
592 inline double Constant::getValueAsFloat64() const
593 {
594  Float64 value = 0.0;
596  return value;
597 }
598 
600 {
601  Datetime value;
603  return value;
604 }
605 
606 inline std::string Constant::getValueAsString() const
607 {
608  std::string value;
610  return value;
611 }
612 
613 inline void Constant::setUserData(void *newUserData)
614 {
615  blpapi_Constant_setUserData(d_impl_p, newUserData);
616 }
617 
618 inline void *Constant::userData() const
619 {
620  return blpapi_Constant_userData(d_impl_p);
621 }
622 
624  : d_impl_p(handle)
625 {
626 }
627 
628 inline Name ConstantList::name() const
629 {
630  return blpapi_ConstantList_name(d_impl_p);
631 }
632 
633 inline const char *ConstantList::description() const
634 {
635  return blpapi_ConstantList_description(d_impl_p);
636 }
637 
638 inline int ConstantList::status() const
639 {
640  return blpapi_ConstantList_status(d_impl_p);
641 }
642 
643 inline int ConstantList::datatype() const
644 {
645  return blpapi_ConstantList_datatype(d_impl_p);
646 }
647 
648 inline int ConstantList::numConstants() const
649 {
650  return blpapi_ConstantList_numConstants(d_impl_p);
651 }
652 
653 inline Constant ConstantList::getConstant(const Name& constantName) const
654 {
655  return blpapi_ConstantList_getConstant(d_impl_p, 0, constantName.impl());
656 }
657 
658 inline Constant ConstantList::getConstant(const char *nameString) const
659 {
660  return blpapi_ConstantList_getConstant(d_impl_p, nameString, 0);
661 }
662 
663 inline Constant ConstantList::getConstantAt(size_t index) const
664 {
665  return blpapi_ConstantList_getConstantAt(d_impl_p, index);
666 }
667 
669 {
670  return d_impl_p;
671 }
672 
673 inline void ConstantList::setUserData(void *newUserData)
674 {
675  blpapi_ConstantList_setUserData(d_impl_p, newUserData);
676 }
677 
678 inline void *ConstantList::userData() const
679 {
680  return blpapi_ConstantList_userData(d_impl_p);
681 }
682 
683 } // close namespace blpapi
684 } // close namespace BloombergLP
685 
686 #endif // #ifndef __cplusplus
687 
688 #endif // #ifndef INCLUDED_BLPAPI_CONSTANT
int getValueAs(char *buffer) const
Definition: blpapi_constant.h:522
BLPAPI_EXPORT int blpapi_Constant_getValueAsChar(const blpapi_Constant_t *constant, blpapi_Char_t *buffer)
BLPAPI_EXPORT void * blpapi_Constant_userData(const blpapi_Constant_t *constant)
Name name() const
Definition: blpapi_constant.h:503
BLPAPI_EXPORT void * blpapi_ConstantList_userData(const blpapi_ConstantList_t *constant)
Float32 getValueAsFloat32() const
Definition: blpapi_constant.h:585
Common definitions used by the library.
int status() const
Definition: blpapi_constant.h:510
int datatype() const
Definition: blpapi_constant.h:515
int datatype() const
Definition: blpapi_constant.h:643
blpapi_Int32_t Int32
Definition: blpapi_types.h:469
Represents a date and/or time.
Definition: blpapi_abstractsession.h:220
Definition: blpapi_name.h:150
blpapi_Float64_t Float64
Definition: blpapi_types.h:474
Definition: blpapi_constant.h:396
BLPAPI_EXPORT blpapi_Name_t * blpapi_ConstantList_name(const blpapi_ConstantList_t *list)
BLPAPI_EXPORT int blpapi_Constant_getValueAsFloat64(const blpapi_Constant_t *constant, blpapi_Float64_t *buffer)
BLPAPI_EXPORT int blpapi_Constant_getValueAsString(const blpapi_Constant_t *constant, const char **buffer)
BLPAPI_EXPORT blpapi_Constant_t * blpapi_ConstantList_getConstantAt(const blpapi_ConstantList_t *constant, size_t index)
void * userData() const
Definition: blpapi_constant.h:618
blpapi_Name_t * impl() const
Definition: blpapi_name.h:403
int blpapi_Int32_t
Definition: blpapi_types.h:67
const blpapi_ConstantList_t * impl() const
Definition: blpapi_constant.h:668
struct blpapi_Name blpapi_Name_t
Definition: blpapi_types.h:154
BLPAPI_EXPORT int blpapi_Constant_datatype(const blpapi_Constant_t *constant)
const char * description() const
Definition: blpapi_constant.h:505
Constant getConstant(const Name &name) const
Definition: blpapi_constant.h:653
Float64 getValueAsFloat64() const
Definition: blpapi_constant.h:592
int status() const
Definition: blpapi_constant.h:638
blpapi_Float32_t Float32
Definition: blpapi_types.h:473
BLPAPI_EXPORT blpapi_Constant_t * blpapi_ConstantList_getConstant(const blpapi_ConstantList_t *constant, const char *nameString, const blpapi_Name_t *name)
static void throwOnError(int errorCode)
Definition: blpapi_exception.h:526
struct blpapi_ConstantList blpapi_ConstantList_t
Definition: blpapi_types.h:133
struct blpapi_Constant blpapi_Constant_t
Definition: blpapi_types.h:130
int numConstants() const
Definition: blpapi_constant.h:648
BLPAPI_EXPORT void blpapi_Constant_setUserData(blpapi_Constant_t *constant, void *userdata)
const char * description() const
Definition: blpapi_constant.h:633
const blpapi_Constant_t * impl() const
Definition: blpapi_constant.h:520
BLPAPI_EXPORT int blpapi_Constant_getValueAsInt32(const blpapi_Constant_t *constant, blpapi_Int32_t *buffer)
ConstantList(blpapi_ConstantList_t *handle)
Definition: blpapi_constant.h:623
blpapi_Datetime_t & rawValue()
Definition: blpapi_datetime.h:1952
BLPAPI_EXPORT const char * blpapi_Constant_description(const blpapi_Constant_t *constant)
void setUserData(void *userData)
Definition: blpapi_constant.h:613
Int32 getValueAsInt32() const
Definition: blpapi_constant.h:571
blpapi_Int64_t Int64
Definition: blpapi_types.h:471
Int64 getValueAsInt64() const
Definition: blpapi_constant.h:578
BLPAPI_EXPORT int blpapi_Constant_getValueAsDatetime(const blpapi_Constant_t *constant, blpapi_Datetime_t *buffer)
BLPAPI_EXPORT int blpapi_ConstantList_datatype(const blpapi_ConstantList_t *constant)
Definition: blpapi_datetime.h:102
BLPAPI_EXPORT int blpapi_Constant_getValueAsInt64(const blpapi_Constant_t *constant, blpapi_Int64_t *buffer)
BLPAPI_EXPORT void blpapi_ConstantList_setUserData(blpapi_ConstantList_t *constant, void *userdata)
double blpapi_Float64_t
Definition: blpapi_types.h:72
BLPAPI_EXPORT const char * blpapi_ConstantList_description(const blpapi_ConstantList_t *list)
char blpapi_Char_t
Definition: blpapi_types.h:63
long long blpapi_Int64_t
Definition: blpapi_types.h:69
void * userData() const
Definition: blpapi_constant.h:678
BLPAPI_EXPORT blpapi_Name_t * blpapi_Constant_name(const blpapi_Constant_t *constant)
BLPAPI_EXPORT int blpapi_ConstantList_numConstants(const blpapi_ConstantList_t *list)
void setUserData(void *userData)
Definition: blpapi_constant.h:673
char getValueAsChar() const
Definition: blpapi_constant.h:564
Defines Exceptions that can be thrown by the blpapi library.
Definition: blpapi_constant.h:210
BLPAPI_EXPORT int blpapi_Constant_status(const blpapi_Constant_t *constant)
float blpapi_Float32_t
Definition: blpapi_types.h:71
BLPAPI_EXPORT int blpapi_ConstantList_status(const blpapi_ConstantList_t *list)
Constant(blpapi_Constant_t *handle)
Definition: blpapi_constant.h:498
Constant getConstantAt(size_t index) const
Definition: blpapi_constant.h:663
Datetime getValueAsDatetime() const
Definition: blpapi_constant.h:599
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
std::string getValueAsString() const
Definition: blpapi_constant.h:606
Definition: blpapi_datetime.h:245
Provide BLPAPI types.
Name name() const
Definition: blpapi_constant.h:628
Provide a representation of strings for use as container keys.
BLPAPI_EXPORT int blpapi_Constant_getValueAsFloat32(const blpapi_Constant_t *constant, blpapi_Float32_t *buffer)