36#ifndef INCLUDED_BLPAPI_ELEMENT
37#define INCLUDED_BLPAPI_ELEMENT
70#include <blpapi_deprecate.h>
95BLPAPI_EXPORT blpapi_Name_t *blpapi_Element_name(
96 const blpapi_Element_t *element);
107BLPAPI_EXPORT
const char *blpapi_Element_nameString(
108 const blpapi_Element_t *element);
118BLPAPI_EXPORT blpapi_SchemaElementDefinition_t *blpapi_Element_definition(
119 const blpapi_Element_t *element);
130BLPAPI_EXPORT
int blpapi_Element_datatype(
const blpapi_Element_t *element);
141BLPAPI_EXPORT
int blpapi_Element_isComplexType(
142 const blpapi_Element_t *element);
153BLPAPI_EXPORT
int blpapi_Element_isArray(
const blpapi_Element_t *element);
164BLPAPI_EXPORT
int blpapi_Element_isReadOnly(
const blpapi_Element_t *element);
175BLPAPI_EXPORT
size_t blpapi_Element_numValues(
const blpapi_Element_t *element);
186BLPAPI_EXPORT
size_t blpapi_Element_numElements(
187 const blpapi_Element_t *element);
199BLPAPI_EXPORT
int blpapi_Element_isNullValue(
200 const blpapi_Element_t *element,
size_t position);
211BLPAPI_EXPORT
int blpapi_Element_isNull(
const blpapi_Element_t *element);
228BLPAPI_EXPORT
int blpapi_Element_print(
const blpapi_Element_t *element,
229 blpapi_StreamWriter_t streamWriter,
246BLPAPI_EXPORT
int blpapi_Element_toJson(
const blpapi_Element_t *element,
247 blpapi_StreamWriter_t streamWriter,
260BLPAPI_EXPORT
int blpapi_Element_fromJson(
261 const blpapi_Element_t *element,
char const *json);
276int blpapi_Element_getElementAt(
const blpapi_Element_t *element,
277 blpapi_Element_t **result,
296int blpapi_Element_getElement(
const blpapi_Element_t *element,
297 blpapi_Element_t **result,
298 const char *nameString,
299 const blpapi_Name_t *name);
316int blpapi_Element_hasElement(
const blpapi_Element_t *element,
317 const char *nameString,
318 const blpapi_Name_t *name);
338int blpapi_Element_hasElementEx(
const blpapi_Element_t *element,
339 const char *nameString,
340 const blpapi_Name_t *name,
341 int excludeNullElements,
357int blpapi_Element_getValueAsBool(
358 const blpapi_Element_t *element, blpapi_Bool_t *buffer,
size_t index);
372int blpapi_Element_getValueAsChar(
373 const blpapi_Element_t *element, blpapi_Char_t *buffer,
size_t index);
387int blpapi_Element_getValueAsInt32(
388 const blpapi_Element_t *element, blpapi_Int32_t *buffer,
size_t index);
402int blpapi_Element_getValueAsInt64(
403 const blpapi_Element_t *element, blpapi_Int64_t *buffer,
size_t index);
417int blpapi_Element_getValueAsFloat32(
const blpapi_Element_t *element,
418 blpapi_Float32_t *buffer,
433int blpapi_Element_getValueAsFloat64(
const blpapi_Element_t *element,
434 blpapi_Float64_t *buffer,
450int blpapi_Element_getValueAsString(
451 const blpapi_Element_t *element,
const char **buffer,
size_t index);
465int blpapi_Element_getValueAsDatetime(
const blpapi_Element_t *element,
466 blpapi_Datetime_t *buffer,
481int blpapi_Element_getValueAsHighPrecisionDatetime(
482 const blpapi_Element_t *element,
483 blpapi_HighPrecisionDatetime_t *buffer,
499int blpapi_Element_getValueAsElement(
const blpapi_Element_t *element,
500 blpapi_Element_t **buffer,
516int blpapi_Element_getValueAsName(
517 const blpapi_Element_t *element, blpapi_Name_t **buffer,
size_t index);
534int blpapi_Element_getValueAsBytes(
const blpapi_Element_t *element,
551int blpapi_Element_getChoice(
552 const blpapi_Element_t *element, blpapi_Element_t **result);
567int blpapi_Element_setValueBool(
568 blpapi_Element_t *element, blpapi_Bool_t value,
size_t index);
582int blpapi_Element_setValueChar(
583 blpapi_Element_t *element, blpapi_Char_t value,
size_t index);
597int blpapi_Element_setValueInt32(
598 blpapi_Element_t *element, blpapi_Int32_t value,
size_t index);
612int blpapi_Element_setValueInt64(
613 blpapi_Element_t *element, blpapi_Int64_t value,
size_t index);
627int blpapi_Element_setValueFloat32(
628 blpapi_Element_t *element, blpapi_Float32_t value,
size_t index);
642int blpapi_Element_setValueFloat64(
643 blpapi_Element_t *element, blpapi_Float64_t value,
size_t index);
657int blpapi_Element_setValueString(
658 blpapi_Element_t *element,
const char *value,
size_t index);
672int blpapi_Element_setValueDatetime(blpapi_Element_t *element,
673 const blpapi_Datetime_t *value,
688int blpapi_Element_setValueHighPrecisionDatetime(blpapi_Element_t *element,
689 const blpapi_HighPrecisionDatetime_t *value,
705int blpapi_Element_setValueBytes(blpapi_Element_t *element,
722int blpapi_Element_setValueFromElement(
723 blpapi_Element_t *element, blpapi_Element_t *value,
size_t index);
737int blpapi_Element_setValueFromName(
738 blpapi_Element_t *element,
const blpapi_Name_t *value,
size_t index);
755int blpapi_Element_setElementBool(blpapi_Element_t *element,
756 const char *nameString,
757 const blpapi_Name_t *name,
758 blpapi_Bool_t value);
775int blpapi_Element_setElementChar(blpapi_Element_t *element,
776 const char *nameString,
777 const blpapi_Name_t *name,
778 blpapi_Char_t value);
795int blpapi_Element_setElementInt32(blpapi_Element_t *element,
796 const char *nameString,
797 const blpapi_Name_t *name,
798 blpapi_Int32_t value);
815int blpapi_Element_setElementInt64(blpapi_Element_t *element,
816 const char *nameString,
817 const blpapi_Name_t *name,
818 blpapi_Int64_t value);
836int blpapi_Element_setElementFloat32(blpapi_Element_t *element,
837 const char *nameString,
838 const blpapi_Name_t *name,
839 blpapi_Float32_t value);
857int blpapi_Element_setElementFloat64(blpapi_Element_t *element,
858 const char *nameString,
859 const blpapi_Name_t *name,
860 blpapi_Float64_t value);
878int blpapi_Element_setElementString(blpapi_Element_t *element,
879 const char *nameString,
880 const blpapi_Name_t *name,
898int blpapi_Element_setElementDatetime(blpapi_Element_t *element,
899 const char *nameString,
900 const blpapi_Name_t *name,
901 const blpapi_Datetime_t *value);
919int blpapi_Element_setElementHighPrecisionDatetime(blpapi_Element_t *element,
920 const char *nameString,
921 const blpapi_Name_t *name,
922 const blpapi_HighPrecisionDatetime_t *value);
940int blpapi_Element_setElementBytes(blpapi_Element_t *element,
941 const char *nameString,
942 const blpapi_Name_t *name,
961int blpapi_Element_setElementFromField(blpapi_Element_t *element,
962 const char *nameString,
963 const blpapi_Name_t *name,
964 blpapi_Element_t *sourcebuffer);
981int blpapi_Element_setElementFromName(blpapi_Element_t *element,
982 const char *elementName,
983 const blpapi_Name_t *name,
984 const blpapi_Name_t *buffer);
998int blpapi_Element_appendElement(
999 blpapi_Element_t *element, blpapi_Element_t **appendedElement);
1019int blpapi_Element_setChoice(blpapi_Element_t *element,
1020 blpapi_Element_t **resultElement,
1021 const char *nameCstr,
1022 const blpapi_Name_t *name,
1036#include <type_traits>
1169 blpapi_Element_t *d_handle_p;
1179 explicit Element(blpapi_Element_t *element);
1183 void rebind(blpapi_Element_t *element);
1185 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
const char *
name,
bool value);
1198 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
const char *
name,
char value);
1211 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1225 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1239 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1253 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1267 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1281 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1282 const char *
name,
const char *value);
1295 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1296 const char *
name,
const Name& value);
1432 template <
typename BYTES,
1433 typename std::enable_if<IsByteSequence<BYTES>::value,
bool>::type
1451 void setValue(
bool value,
size_t index = 0);
1460 void setValue(
char value,
size_t index = 0);
1514 void setValue(
const char *value,
size_t index = 0);
1523 void setValue(
const std::string& value,
size_t index = 0);
1533 void setValue(
const Name& valueName,
size_t index = 0);
1543 void setValue(
const void *value,
size_t length,
size_t index);
1552 template <
typename BYTES,
1553 typename std::enable_if<IsByteSequence<BYTES>::value,
bool>::type
1555 void setValue(
const BYTES& value,
size_t index = 0);
1697 blpapi_Element_t *
handle();
1780 BLPAPI_DEPRECATE_STRING_NAME
bool hasElement(
1781 const char *
name,
bool excludeNullElements =
false)
const;
1799 int getValueAs(
bool *result,
size_t index = 0)
const;
1808 int getValueAs(
char *result,
size_t index = 0)
const;
1865 int getValueAs(std::string *result,
size_t index = 0)
const;
2082 const char *
name)
const;
2103 const char *
name)
const;
2124 const char *
name)
const;
2145 const char *
name)
const;
2166 const char *
name)
const;
2194 const char *
name)
const;
2252 const blpapi_Element_t *
handle()
const;
2254 std::ostream&
print(
2255 std::ostream& stream,
int level = 0,
int spacesPerLevel = 4)
const;
2269 std::string
toJson()
const;
2286 void fromJson(
const std::string& json);
2330 : d_handle_p(newHandle)
2336 d_handle_p = element;
2342 d_handle_p, elementName, 0, value ? 1 : 0));
2348 blpapi_Element_setElementChar(d_handle_p, elementName, 0, value));
2354 blpapi_Element_setElementInt32(d_handle_p, elementName, 0, value));
2360 blpapi_Element_setElementInt64(d_handle_p, elementName, 0, value));
2366 d_handle_p, elementName, 0, value));
2372 d_handle_p, elementName, 0, value));
2387 d_handle_p, elementName, 0, value));
2393 d_handle_p, elementName, 0, value.
impl()));
2399 d_handle_p, 0, elementName.
impl(), value ? 1 : 0));
2405 d_handle_p, 0, elementName.
impl(), value));
2411 d_handle_p, 0, elementName.
impl(), value));
2417 d_handle_p, 0, elementName.
impl(), value));
2423 d_handle_p, 0, elementName.
impl(), value));
2429 d_handle_p, 0, elementName.
impl(), value));
2444 d_handle_p, 0, elementName.
impl(), value));
2448 const Name& elementName,
const std::string& value)
2456 d_handle_p, 0, elementName.
impl(), value.
impl()));
2460 const Name& elementName,
const void *value,
size_t length)
2463 BLPAPI_CALL(blpapi_Element_setElementBytes)(d_handle_p,
2466 reinterpret_cast<const char *
>(value),
2470template <
typename BYTES,
2471 typename std::enable_if<IsByteSequence<BYTES>::value,
bool>::type>
2474 setElement(elementName, value.data(), value.size());
2480 blpapi_Element_setValueBool(d_handle_p, value, index));
2486 blpapi_Element_setValueChar(d_handle_p, value, index));
2492 blpapi_Element_setValueInt32(d_handle_p, value, index));
2498 blpapi_Element_setValueInt64(d_handle_p, value, index));
2504 blpapi_Element_setValueFloat32(d_handle_p, value, index));
2510 blpapi_Element_setValueFloat64(d_handle_p, value, index));
2523 blpapi_Element_setValueString(d_handle_p, value, index));
2534 d_handle_p, valueName.
impl(), index));
2540 d_handle_p,
reinterpret_cast<const char *
>(value), length, index));
2543template <
typename BYTES,
2544 typename std::enable_if<IsByteSequence<BYTES>::value,
bool>::type>
2547 setValue(value.data(), value.size(), index);
2553 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2559 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2565 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2571 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2577 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2583 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2591 BLPAPI_ELEMENT_INDEX_END));
2597 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2608 d_handle_p, valueName.
impl(), BLPAPI_ELEMENT_INDEX_END));
2613 blpapi_Element_t *appendedElement = 0;
2615 blpapi_Element_appendElement(d_handle_p, &appendedElement));
2616 return Element(appendedElement);
2621 blpapi_Element_t *resultElement = 0;
2623 d_handle_p, &resultElement, selectionName, 0, 0));
2624 return Element(resultElement);
2629 blpapi_Element_t *resultElement = 0;
2631 d_handle_p, &resultElement, 0, selectionName.
impl(), 0));
2632 return Element(resultElement);
2639 return Name(blpapi_Element_name(d_handle_p));
2646 blpapi_Element_t *fldt = 0;
2647 int rc = blpapi_Element_getElement(d_handle_p, &fldt, nameString, 0);
2659 blpapi_Element_t *fldt = 0;
2660 int rc = blpapi_Element_getElement(
2661 d_handle_p, &fldt, 0, elementName.
impl());
2673 blpapi_Element_t *fldt = 0;
2674 int rc = blpapi_Element_getElementAt(d_handle_p, &fldt, position);
2684 return blpapi_Element_datatype(d_handle_p);
2689 return blpapi_Element_isComplexType(d_handle_p) ? true :
false;
2694 return blpapi_Element_isArray(d_handle_p) ? true :
false;
2699 return blpapi_Element_isNull(d_handle_p) ? true :
false;
2704 return blpapi_Element_isReadOnly(d_handle_p) ? true :
false;
2714 return blpapi_Element_numValues(d_handle_p);
2719 return blpapi_Element_numElements(d_handle_p);
2726 int rc = blpapi_Element_isNullValue(d_handle_p, position);
2727 if (rc != 0 && rc != 1) {
2730 return rc ? true :
false;
2734 const char *nameString,
bool excludeNullElements)
const
2736 if (excludeNullElements) {
2737 return (blpapi_Element_hasElementEx(
2738 d_handle_p, nameString, 0, excludeNullElements, 0)
2742 return blpapi_Element_hasElement(d_handle_p, nameString, 0) ? true :
false;
2746 const Name& elementName,
bool excludeNullElements)
const
2748 if (excludeNullElements) {
2749 return (blpapi_Element_hasElementEx(d_handle_p,
2752 excludeNullElements,
2757 return blpapi_Element_hasElement(d_handle_p, 0, elementName.
impl())
2764 blpapi_Element_t *fldt = 0;
2766 d_handle_p, &fldt, 0, elementName.
impl()));
2772 blpapi_Element_t *fldt = 0;
2774 blpapi_Element_getElement(d_handle_p, &fldt, elementName, 0));
2780 blpapi_Element_t *element = 0;
2782 blpapi_Element_getElementAt(d_handle_p, &element, position));
2790 blpapi_Bool_t tmp =
false;
2792 int res = blpapi_Element_getValueAsBool(d_handle_p, &tmp, index);
2793 *buffer = tmp ? true :
false;
2799 return blpapi_Element_getValueAsChar(d_handle_p, buffer, index);
2804 return blpapi_Element_getValueAsInt32(d_handle_p, buffer, index);
2809 return blpapi_Element_getValueAsInt64(d_handle_p, buffer, index);
2814 return blpapi_Element_getValueAsFloat32(d_handle_p, buffer, index);
2819 return blpapi_Element_getValueAsFloat64(d_handle_p, buffer, index);
2825 d_handle_p, buffer, index);
2832 const char *buffer = 0;
2833 int rc = blpapi_Element_getValueAsString(d_handle_p, &buffer, index);
2844 const char *buffer = 0;
2846 const int rc =
BLPAPI_CALL(blpapi_Element_getValueAsBytes)(
2847 d_handle_p, &buffer, &length, index);
2849 result->
assign(buffer, length);
2858 return blpapi_Element_getValueAsElement(
2859 d_handle_p, &buffer->d_handle_p, index);
2866 blpapi_Name_t *tmpName = 0;
2867 int res = blpapi_Element_getValueAsName(d_handle_p, &tmpName, index);
2869 *buffer =
Name(tmpName);
2925 const char *tmpStringBuffer = 0;
2927 d_handle_p, &tmpStringBuffer, index));
2928 return tmpStringBuffer;
2940 blpapi_Element_t *element = 0;
2942 blpapi_Element_getValueAsElement(d_handle_p, &element, index));
2948 blpapi_Name_t *nameValue = 0;
2950 blpapi_Element_getValueAsName(d_handle_p, &nameValue, index));
2951 return Name(nameValue);
2956 blpapi_Element_t *element = 0;
2958 blpapi_Element_getChoice(d_handle_p, &element));
2969 return getElement(elementName).getValueAsBool();
2979 return getElement(elementName).getValueAsChar();
2989 return getElement(elementName).getValueAsInt32();
2999 return getElement(elementName).getValueAsInt64();
3009 return getElement(elementName).getValueAsFloat32();
3019 return getElement(elementName).getValueAsFloat64();
3029 return getElement(elementName).getValueAsDatetime();
3039 return getElement(elementName).getValueAsString();
3044 return getElement(elementName).getValueAsBytes();
3054 return getElement(elementName).getValueAsName();
3060 std::ostream& stream,
int level,
int spacesPerLevel)
const
3062 blpapi_Element_print(d_handle_p,
3072 std::ostringstream stream;
3075 return stream.str();
3090 element.
print(stream, 0, -1);
Provide functions for dispatchtbl.
#define BLPAPI_CALL_ELEMENT_GETVALUEASHIGHPRECISIONDATETIME(a1, a2, a3)
Definition blpapi_call.h:411
#define BLPAPI_CALL_ELEMENT_SETELEMENTHIGHPRECISIONDATETIME(a1, a2, a3, a4)
Definition blpapi_call.h:409
#define BLPAPI_CALL_ELEMENT_SETVALUEHIGHPRECISIONDATETIME(a1, a2, a3)
Definition blpapi_call.h:407
#define BLPAPI_CALL(FUNCNAME)
Definition blpapi_call.h:361
Represents a date and/or time.
Common definitions used by the library.
Defines Exceptions that can be thrown by the blpapi library.
Provide a representation of strings for use as container keys.
Provide a representation of a schema describing structured messages.
A signature for callback on print and default C++ implementation.
Definition blpapi_types.h:323
void assign(pointer ptr, size_type length) noexcept
Definition blpapi_types.h:507
Definition blpapi_datetime.h:273
blpapi_HighPrecisionDatetime_t & rawHighPrecisionValue()
Definition blpapi_datetime.h:1982
Definition blpapi_element.h:1167
Datetime getElementAsDatetime(const char *name) const
Definition blpapi_element.h:3022
Name name() const
Definition blpapi_element.h:2637
void rebind(blpapi_Element_t *element)
Definition blpapi_element.h:2334
int getValueAs(bool *result, size_t index=0) const
Definition blpapi_element.h:2786
Element setChoice(const char *selectionName)
Definition blpapi_element.h:2619
Bytes getElementAsBytes(const Name &name) const
Definition blpapi_element.h:3042
bool isNullValue(size_t position=0) const
Definition blpapi_element.h:2724
int getElement(Element *result, const char *name) const
Definition blpapi_element.h:2642
Float64 getValueAsFloat64(size_t index=0) const
Definition blpapi_element.h:2909
Element getValueAsElement(size_t index=0) const
Definition blpapi_element.h:2938
Name getValueAsName(size_t index=0) const
Definition blpapi_element.h:2946
int datatype() const
Definition blpapi_element.h:2682
Name getElementAsName(const char *name) const
Definition blpapi_element.h:3047
Int64 getValueAsInt64(size_t index=0) const
Definition blpapi_element.h:2895
Bytes getValueAsBytes(size_t index=0) const
Definition blpapi_element.h:2931
blpapi_Element_t * handle()
Definition blpapi_element.h:2635
Float64 getElementAsFloat64(const char *name) const
Definition blpapi_element.h:3012
size_t numValues() const
Definition blpapi_element.h:2712
bool isReadOnly() const
Definition blpapi_element.h:2702
bool hasElement(const char *name, bool excludeNullElements=false) const
Definition blpapi_element.h:2733
void appendValue(bool value)
Definition blpapi_element.h:2550
bool isValid() const
Definition blpapi_element.h:2722
bool getElementAsBool(const char *name) const
Definition blpapi_element.h:2962
bool getValueAsBool(size_t index=0) const
Definition blpapi_element.h:2874
std::ostream & print(std::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition blpapi_element.h:3059
void setValue(bool value, size_t index=0)
Definition blpapi_element.h:2477
char getElementAsChar(const char *name) const
Definition blpapi_element.h:2972
Element appendElement()
Definition blpapi_element.h:2611
const char * getValueAsString(size_t index=0) const
Definition blpapi_element.h:2923
bool isComplexType() const
Definition blpapi_element.h:2687
char getValueAsChar(size_t index=0) const
Definition blpapi_element.h:2881
void setElement(const char *name, bool value)
Definition blpapi_element.h:2339
std::string toJson() const
Definition blpapi_element.h:3070
void fromJson(const char *json)
Definition blpapi_element.h:3078
Element()
Definition blpapi_element.h:2324
Datetime getValueAsDatetime(size_t index=0) const
Definition blpapi_element.h:2916
bool isNull() const
Definition blpapi_element.h:2697
SchemaElementDefinition elementDefinition() const
Definition blpapi_element.h:2707
Int64 getElementAsInt64(const char *name) const
Definition blpapi_element.h:2992
Int32 getElementAsInt32(const char *name) const
Definition blpapi_element.h:2982
Element getChoice() const
Definition blpapi_element.h:2954
Float32 getValueAsFloat32(size_t index=0) const
Definition blpapi_element.h:2902
bool isArray() const
Definition blpapi_element.h:2692
Int32 getValueAsInt32(size_t index=0) const
Definition blpapi_element.h:2888
const char * getElementAsString(const char *name) const
Definition blpapi_element.h:3032
Float32 getElementAsFloat32(const char *name) const
Definition blpapi_element.h:3002
size_t numElements() const
Definition blpapi_element.h:2717
static void throwOnError(int errorCode)
Definition blpapi_exception.h:541
Definition blpapi_name.h:242
blpapi_Name_t * impl() const
Definition blpapi_name.h:495
Definition blpapi_schema.h:342
Definition blpapi_abstractsession.h:212
blpapi_Float64_t Float64
Definition blpapi_types.h:485
blpapi_Float32_t Float32
Definition blpapi_types.h:484
blpapi_Int64_t Int64
Definition blpapi_types.h:482
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition blpapi_correlationid.h:680
blpapi_Int32_t Int32
Definition blpapi_types.h:480
Definition blpapi_abstractsession.h:211
static int writeToStream(const char *data, int length, void *stream)
Definition blpapi_streamproxy.h:109