38#ifndef INCLUDED_BLPAPI_ELEMENT
39#define INCLUDED_BLPAPI_ELEMENT
71#include <blpapi_deprecate.h>
94BLPAPI_EXPORT blpapi_Name_t *blpapi_Element_name(
95 const blpapi_Element_t *element);
104BLPAPI_EXPORT
const char *blpapi_Element_nameString(
105 const blpapi_Element_t *element);
113BLPAPI_EXPORT blpapi_SchemaElementDefinition_t *blpapi_Element_definition(
114 const blpapi_Element_t *element);
123BLPAPI_EXPORT
int blpapi_Element_datatype(
const blpapi_Element_t *element);
132BLPAPI_EXPORT
int blpapi_Element_isComplexType(
133 const blpapi_Element_t *element);
142BLPAPI_EXPORT
int blpapi_Element_isArray(
const blpapi_Element_t *element);
151BLPAPI_EXPORT
int blpapi_Element_isReadOnly(
const blpapi_Element_t *element);
160BLPAPI_EXPORT
size_t blpapi_Element_numValues(
const blpapi_Element_t *element);
169BLPAPI_EXPORT
size_t blpapi_Element_numElements(
170 const blpapi_Element_t *element);
180BLPAPI_EXPORT
int blpapi_Element_isNullValue(
181 const blpapi_Element_t *element,
size_t position);
190BLPAPI_EXPORT
int blpapi_Element_isNull(
const blpapi_Element_t *element);
205BLPAPI_EXPORT
int blpapi_Element_print(
const blpapi_Element_t *element,
206 blpapi_StreamWriter_t streamWriter,
221BLPAPI_EXPORT
int blpapi_Element_toJson(
const blpapi_Element_t *element,
222 blpapi_StreamWriter_t streamWriter,
233BLPAPI_EXPORT
int blpapi_Element_fromJson(
234 const blpapi_Element_t *element,
char const *json);
247int blpapi_Element_getElementAt(
const blpapi_Element_t *element,
248 blpapi_Element_t **result,
268int blpapi_Element_getElement(
const blpapi_Element_t *element,
269 blpapi_Element_t **result,
270 const char *nameString,
271 const blpapi_Name_t *name);
289int blpapi_Element_hasElement(
const blpapi_Element_t *element,
290 const char *nameString,
291 const blpapi_Name_t *name);
314int blpapi_Element_hasElementEx(
const blpapi_Element_t *element,
315 const char *nameString,
316 const blpapi_Name_t *name,
317 int excludeNullElements,
331int blpapi_Element_getValueAsBool(
332 const blpapi_Element_t *element, blpapi_Bool_t *buffer,
size_t index);
344int blpapi_Element_getValueAsChar(
345 const blpapi_Element_t *element, blpapi_Char_t *buffer,
size_t index);
357int blpapi_Element_getValueAsInt32(
358 const blpapi_Element_t *element, blpapi_Int32_t *buffer,
size_t index);
370int blpapi_Element_getValueAsInt64(
371 const blpapi_Element_t *element, blpapi_Int64_t *buffer,
size_t index);
383int blpapi_Element_getValueAsFloat32(
const blpapi_Element_t *element,
384 blpapi_Float32_t *buffer,
397int blpapi_Element_getValueAsFloat64(
const blpapi_Element_t *element,
398 blpapi_Float64_t *buffer,
412int blpapi_Element_getValueAsString(
413 const blpapi_Element_t *element,
const char **buffer,
size_t index);
425int blpapi_Element_getValueAsDatetime(
const blpapi_Element_t *element,
426 blpapi_Datetime_t *buffer,
439int blpapi_Element_getValueAsHighPrecisionDatetime(
440 const blpapi_Element_t *element,
441 blpapi_HighPrecisionDatetime_t *buffer,
455int blpapi_Element_getValueAsElement(
const blpapi_Element_t *element,
456 blpapi_Element_t **buffer,
470int blpapi_Element_getValueAsName(
471 const blpapi_Element_t *element, blpapi_Name_t **buffer,
size_t index);
486int blpapi_Element_getValueAsBytes(
const blpapi_Element_t *element,
501int blpapi_Element_getChoice(
502 const blpapi_Element_t *element, blpapi_Element_t **result);
515int blpapi_Element_setValueBool(
516 blpapi_Element_t *element, blpapi_Bool_t value,
size_t index);
528int blpapi_Element_setValueChar(
529 blpapi_Element_t *element, blpapi_Char_t value,
size_t index);
541int blpapi_Element_setValueInt32(
542 blpapi_Element_t *element, blpapi_Int32_t value,
size_t index);
554int blpapi_Element_setValueInt64(
555 blpapi_Element_t *element, blpapi_Int64_t value,
size_t index);
567int blpapi_Element_setValueFloat32(
568 blpapi_Element_t *element, blpapi_Float32_t value,
size_t index);
580int blpapi_Element_setValueFloat64(
581 blpapi_Element_t *element, blpapi_Float64_t value,
size_t index);
593int blpapi_Element_setValueString(
594 blpapi_Element_t *element,
const char *value,
size_t index);
606int blpapi_Element_setValueDatetime(blpapi_Element_t *element,
607 const blpapi_Datetime_t *value,
620int blpapi_Element_setValueHighPrecisionDatetime(blpapi_Element_t *element,
621 const blpapi_HighPrecisionDatetime_t *value,
635int blpapi_Element_setValueBytes(blpapi_Element_t *element,
650int blpapi_Element_setValueFromElement(
651 blpapi_Element_t *element, blpapi_Element_t *value,
size_t index);
663int blpapi_Element_setValueFromName(
664 blpapi_Element_t *element,
const blpapi_Name_t *value,
size_t index);
682int blpapi_Element_setElementBool(blpapi_Element_t *element,
683 const char *nameString,
684 const blpapi_Name_t *name,
685 blpapi_Bool_t value);
703int blpapi_Element_setElementChar(blpapi_Element_t *element,
704 const char *nameString,
705 const blpapi_Name_t *name,
706 blpapi_Char_t value);
724int blpapi_Element_setElementInt32(blpapi_Element_t *element,
725 const char *nameString,
726 const blpapi_Name_t *name,
727 blpapi_Int32_t value);
745int blpapi_Element_setElementInt64(blpapi_Element_t *element,
746 const char *nameString,
747 const blpapi_Name_t *name,
748 blpapi_Int64_t value);
767int blpapi_Element_setElementFloat32(blpapi_Element_t *element,
768 const char *nameString,
769 const blpapi_Name_t *name,
770 blpapi_Float32_t value);
789int blpapi_Element_setElementFloat64(blpapi_Element_t *element,
790 const char *nameString,
791 const blpapi_Name_t *name,
792 blpapi_Float64_t value);
811int blpapi_Element_setElementString(blpapi_Element_t *element,
812 const char *nameString,
813 const blpapi_Name_t *name,
832int blpapi_Element_setElementDatetime(blpapi_Element_t *element,
833 const char *nameString,
834 const blpapi_Name_t *name,
835 const blpapi_Datetime_t *value);
854int blpapi_Element_setElementHighPrecisionDatetime(blpapi_Element_t *element,
855 const char *nameString,
856 const blpapi_Name_t *name,
857 const blpapi_HighPrecisionDatetime_t *value);
876int blpapi_Element_setElementBytes(blpapi_Element_t *element,
877 const char *nameString,
878 const blpapi_Name_t *name,
899int blpapi_Element_setElementFromField(blpapi_Element_t *element,
900 const char *nameString,
901 const blpapi_Name_t *name,
902 blpapi_Element_t *sourcebuffer);
917int blpapi_Element_setElementFromName(blpapi_Element_t *element,
918 const char *elementName,
919 const blpapi_Name_t *name,
920 const blpapi_Name_t *buffer);
932int blpapi_Element_appendElement(
933 blpapi_Element_t *element, blpapi_Element_t **appendedElement);
951int blpapi_Element_setChoice(blpapi_Element_t *element,
952 blpapi_Element_t **resultElement,
953 const char *nameCstr,
954 const blpapi_Name_t *name,
968#include <type_traits>
1100 blpapi_Element_t *d_handle_p;
1110 explicit Element(blpapi_Element_t *element);
1114 void rebind(blpapi_Element_t *element);
1116 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
const char *
name,
bool value);
1129 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
const char *
name,
char value);
1142 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1156 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1170 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1184 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1198 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1212 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1213 const char *
name,
const char *value);
1226 BLPAPI_DEPRECATE_STRING_NAME
void setElement(
1227 const char *
name,
const Name& value);
1363 template <
typename BYTES,
1364 typename std::enable_if<IsByteSequence<BYTES>::value,
bool>::type
1381 void setValue(
bool value,
size_t index = 0);
1390 void setValue(
char value,
size_t index = 0);
1444 void setValue(
const char *value,
size_t index = 0);
1453 void setValue(
const std::string& value,
size_t index = 0);
1463 void setValue(
const Name& valueName,
size_t index = 0);
1473 void setValue(
const void *value,
size_t length,
size_t index);
1481 template <
typename BYTES,
1482 typename std::enable_if<IsByteSequence<BYTES>::value,
bool>::type
1484 void setValue(
const BYTES& value,
size_t index = 0);
1626 blpapi_Element_t *handle();
1709 BLPAPI_DEPRECATE_STRING_NAME
bool hasElement(
1710 const char *
name,
bool excludeNullElements =
false)
const;
1728 int getValueAs(
bool *result,
size_t index = 0)
const;
1736 int getValueAs(
char *result,
size_t index = 0)
const;
1787 int getValueAs(std::string *result,
size_t index = 0)
const;
2001 const char *
name)
const;
2022 const char *
name)
const;
2043 const char *
name)
const;
2064 const char *
name)
const;
2085 const char *
name)
const;
2113 const char *
name)
const;
2172 const blpapi_Element_t *handle()
const;
2175 std::ostream&
print(
2176 std::ostream& stream,
int level = 0,
int spacesPerLevel = 4)
const;
2190 std::string
toJson()
const;
2207 void fromJson(
const std::string& json);
2251 : d_handle_p(newHandle)
2257 d_handle_p = element;
2263 d_handle_p, elementName, 0, value ? 1 : 0));
2269 blpapi_Element_setElementChar(d_handle_p, elementName, 0, value));
2275 blpapi_Element_setElementInt32(d_handle_p, elementName, 0, value));
2281 blpapi_Element_setElementInt64(d_handle_p, elementName, 0, value));
2287 d_handle_p, elementName, 0, value));
2293 d_handle_p, elementName, 0, value));
2299 BLPAPI_CALL_ELEMENT_SETELEMENTHIGHPRECISIONDATETIME(d_handle_p,
2308 d_handle_p, elementName, 0, value));
2314 d_handle_p, elementName, 0, value.impl()));
2320 d_handle_p, 0, elementName.impl(), value ? 1 : 0));
2326 d_handle_p, 0, elementName.impl(), value));
2332 d_handle_p, 0, elementName.impl(), value));
2338 d_handle_p, 0, elementName.impl(), value));
2344 d_handle_p, 0, elementName.impl(), value));
2350 d_handle_p, 0, elementName.impl(), value));
2356 BLPAPI_CALL_ELEMENT_SETELEMENTHIGHPRECISIONDATETIME(d_handle_p,
2365 d_handle_p, 0, elementName.impl(), value));
2369 const Name& elementName,
const std::string& value)
2377 d_handle_p, 0, elementName.impl(), value.impl()));
2381 const Name& elementName,
const void *value,
size_t length)
2384 BLPAPI_CALL(blpapi_Element_setElementBytes)(d_handle_p,
2387 reinterpret_cast<const char *
>(value),
2391template <
typename BYTES,
2392 typename std::enable_if<IsByteSequence<BYTES>::value,
bool>::type>
2395 setElement(elementName, value.data(), value.size());
2401 blpapi_Element_setValueBool(d_handle_p, value, index));
2407 blpapi_Element_setValueChar(d_handle_p, value, index));
2413 blpapi_Element_setValueInt32(d_handle_p, value, index));
2419 blpapi_Element_setValueInt64(d_handle_p, value, index));
2425 blpapi_Element_setValueFloat32(d_handle_p, value, index));
2431 blpapi_Element_setValueFloat64(d_handle_p, value, index));
2437 BLPAPI_CALL_ELEMENT_SETVALUEHIGHPRECISIONDATETIME(
2444 blpapi_Element_setValueString(d_handle_p, value, index));
2455 d_handle_p, valueName.impl(), index));
2461 d_handle_p,
reinterpret_cast<const char *
>(value), length, index));
2464template <
typename BYTES,
2465 typename std::enable_if<IsByteSequence<BYTES>::value,
bool>::type>
2468 setValue(value.data(), value.size(), index);
2474 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2480 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2486 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2492 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2498 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2504 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2510 BLPAPI_CALL_ELEMENT_SETVALUEHIGHPRECISIONDATETIME(d_handle_p,
2512 BLPAPI_ELEMENT_INDEX_END));
2518 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
2529 d_handle_p, valueName.impl(), BLPAPI_ELEMENT_INDEX_END));
2534 blpapi_Element_t *appendedElement = 0;
2536 blpapi_Element_appendElement(d_handle_p, &appendedElement));
2537 return Element(appendedElement);
2542 blpapi_Element_t *resultElement = 0;
2544 d_handle_p, &resultElement, selectionName, 0, 0));
2545 return Element(resultElement);
2550 blpapi_Element_t *resultElement = 0;
2552 d_handle_p, &resultElement, 0, selectionName.impl(), 0));
2553 return Element(resultElement);
2557inline blpapi_Element_t *Element::handle() {
return d_handle_p; }
2562 return Name(blpapi_Element_name(d_handle_p));
2569 blpapi_Element_t *fldt = 0;
2570 int rc = blpapi_Element_getElement(d_handle_p, &fldt, nameString, 0);
2582 blpapi_Element_t *fldt = 0;
2583 int rc = blpapi_Element_getElement(
2584 d_handle_p, &fldt, 0, elementName.impl());
2596 blpapi_Element_t *fldt = 0;
2597 int rc = blpapi_Element_getElementAt(d_handle_p, &fldt, position);
2607 return blpapi_Element_datatype(d_handle_p);
2612 return blpapi_Element_isComplexType(d_handle_p) ? true :
false;
2617 return blpapi_Element_isArray(d_handle_p) ? true :
false;
2622 return blpapi_Element_isNull(d_handle_p) ? true :
false;
2627 return blpapi_Element_isReadOnly(d_handle_p) ? true :
false;
2637 return blpapi_Element_numValues(d_handle_p);
2642 return blpapi_Element_numElements(d_handle_p);
2649 int rc = blpapi_Element_isNullValue(d_handle_p, position);
2650 if (rc != 0 && rc != 1) {
2653 return rc ? true :
false;
2657 const char *nameString,
bool excludeNullElements)
const
2659 if (excludeNullElements) {
2660 return (blpapi_Element_hasElementEx(
2661 d_handle_p, nameString, 0, excludeNullElements, 0)
2665 return blpapi_Element_hasElement(d_handle_p, nameString, 0) ? true :
false;
2669 const Name& elementName,
bool excludeNullElements)
const
2671 if (excludeNullElements) {
2672 return (blpapi_Element_hasElementEx(d_handle_p,
2675 excludeNullElements,
2680 return blpapi_Element_hasElement(d_handle_p, 0, elementName.impl())
2687 blpapi_Element_t *fldt = 0;
2689 d_handle_p, &fldt, 0, elementName.impl()));
2695 blpapi_Element_t *fldt = 0;
2697 blpapi_Element_getElement(d_handle_p, &fldt, elementName, 0));
2703 blpapi_Element_t *element = 0;
2705 blpapi_Element_getElementAt(d_handle_p, &element, position));
2713 blpapi_Bool_t tmp =
false;
2715 int res = blpapi_Element_getValueAsBool(d_handle_p, &tmp, index);
2716 *buffer = tmp ? true :
false;
2722 return blpapi_Element_getValueAsChar(d_handle_p, buffer, index);
2727 return blpapi_Element_getValueAsInt32(d_handle_p, buffer, index);
2732 return blpapi_Element_getValueAsInt64(d_handle_p, buffer, index);
2737 return blpapi_Element_getValueAsFloat32(d_handle_p, buffer, index);
2742 return blpapi_Element_getValueAsFloat64(d_handle_p, buffer, index);
2747 BLPAPI_CALL_ELEMENT_GETVALUEASHIGHPRECISIONDATETIME(
2748 d_handle_p, buffer, index);
2755 const char *buffer = 0;
2756 int rc = blpapi_Element_getValueAsString(d_handle_p, &buffer, index);
2767 const char *buffer = 0;
2769 const int rc = BLPAPI_CALL(blpapi_Element_getValueAsBytes)(
2770 d_handle_p, &buffer, &length, index);
2772 result->
assign(buffer, length);
2781 return blpapi_Element_getValueAsElement(
2782 d_handle_p, &buffer->d_handle_p, index);
2789 blpapi_Name_t *tmpName = 0;
2790 int res = blpapi_Element_getValueAsName(d_handle_p, &tmpName, index);
2792 *buffer =
Name(tmpName);
2848 const char *tmpStringBuffer = 0;
2850 d_handle_p, &tmpStringBuffer, index));
2851 return tmpStringBuffer;
2863 blpapi_Element_t *element = 0;
2865 blpapi_Element_getValueAsElement(d_handle_p, &element, index));
2871 blpapi_Name_t *nameValue = 0;
2873 blpapi_Element_getValueAsName(d_handle_p, &nameValue, index));
2874 return Name(nameValue);
2879 blpapi_Element_t *element = 0;
2881 blpapi_Element_getChoice(d_handle_p, &element));
2892 return getElement(elementName).getValueAsBool();
2902 return getElement(elementName).getValueAsChar();
2912 return getElement(elementName).getValueAsInt32();
2922 return getElement(elementName).getValueAsInt64();
2932 return getElement(elementName).getValueAsFloat32();
2942 return getElement(elementName).getValueAsFloat64();
2952 return getElement(elementName).getValueAsDatetime();
2962 return getElement(elementName).getValueAsString();
2967 return getElement(elementName).getValueAsBytes();
2977 return getElement(elementName).getValueAsName();
2981inline const blpapi_Element_t *Element::handle()
const {
return d_handle_p; }
2985 std::ostream& stream,
int level,
int spacesPerLevel)
const
2987 blpapi_Element_print(d_handle_p,
2997 std::ostringstream stream;
3000 return stream.str();
3015 element.
print(stream, 0, -1);
Provide functions for dispatchtbl.
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:395
void assign(pointer ptr, size_type length) noexcept
Definition blpapi_types.h:581
Definition blpapi_datetime.h:312
blpapi_HighPrecisionDatetime_t & rawHighPrecisionValue()
Definition blpapi_datetime.h:2020
Definition blpapi_element.h:1098
Datetime getElementAsDatetime(const char *name) const
Definition blpapi_element.h:2945
Name name() const
Definition blpapi_element.h:2560
void rebind(blpapi_Element_t *element)
Definition blpapi_element.h:2255
int getValueAs(bool *result, size_t index=0) const
Definition blpapi_element.h:2709
Element setChoice(const char *selectionName)
Definition blpapi_element.h:2540
Bytes getElementAsBytes(const Name &name) const
Definition blpapi_element.h:2965
bool isNullValue(size_t position=0) const
Definition blpapi_element.h:2647
int getElement(Element *result, const char *name) const
Definition blpapi_element.h:2565
Float64 getValueAsFloat64(size_t index=0) const
Definition blpapi_element.h:2832
Element getValueAsElement(size_t index=0) const
Definition blpapi_element.h:2861
Name getValueAsName(size_t index=0) const
Definition blpapi_element.h:2869
int datatype() const
Definition blpapi_element.h:2605
Name getElementAsName(const char *name) const
Definition blpapi_element.h:2970
Int64 getValueAsInt64(size_t index=0) const
Definition blpapi_element.h:2818
Bytes getValueAsBytes(size_t index=0) const
Definition blpapi_element.h:2854
Float64 getElementAsFloat64(const char *name) const
Definition blpapi_element.h:2935
size_t numValues() const
Definition blpapi_element.h:2635
bool isReadOnly() const
Definition blpapi_element.h:2625
bool hasElement(const char *name, bool excludeNullElements=false) const
Definition blpapi_element.h:2656
void appendValue(bool value)
Definition blpapi_element.h:2471
bool isValid() const
Definition blpapi_element.h:2645
bool getElementAsBool(const char *name) const
Definition blpapi_element.h:2885
bool getValueAsBool(size_t index=0) const
Definition blpapi_element.h:2797
std::ostream & print(std::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition blpapi_element.h:2984
void setValue(bool value, size_t index=0)
Definition blpapi_element.h:2398
char getElementAsChar(const char *name) const
Definition blpapi_element.h:2895
Element appendElement()
Definition blpapi_element.h:2532
const char * getValueAsString(size_t index=0) const
Definition blpapi_element.h:2846
bool isComplexType() const
Definition blpapi_element.h:2610
char getValueAsChar(size_t index=0) const
Definition blpapi_element.h:2804
void setElement(const char *name, bool value)
Definition blpapi_element.h:2260
std::string toJson() const
Definition blpapi_element.h:2995
void fromJson(const char *json)
Definition blpapi_element.h:3003
Element()
Definition blpapi_element.h:2245
Datetime getValueAsDatetime(size_t index=0) const
Definition blpapi_element.h:2839
bool isNull() const
Definition blpapi_element.h:2620
SchemaElementDefinition elementDefinition() const
Definition blpapi_element.h:2630
Int64 getElementAsInt64(const char *name) const
Definition blpapi_element.h:2915
Int32 getElementAsInt32(const char *name) const
Definition blpapi_element.h:2905
Element getChoice() const
Definition blpapi_element.h:2877
Float32 getValueAsFloat32(size_t index=0) const
Definition blpapi_element.h:2825
bool isArray() const
Definition blpapi_element.h:2615
Int32 getValueAsInt32(size_t index=0) const
Definition blpapi_element.h:2811
const char * getElementAsString(const char *name) const
Definition blpapi_element.h:2955
Float32 getElementAsFloat32(const char *name) const
Definition blpapi_element.h:2925
size_t numElements() const
Definition blpapi_element.h:2640
static void throwOnError(int errorCode)
Definition blpapi_exception.h:556
Definition blpapi_name.h:228
Definition blpapi_schema.h:597
Definition blpapi_abstractsession.h:452
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_Int64_t Int64
64-bit signed integer type alias.
Definition blpapi_types.h:556
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition blpapi_correlationid.h:761
blpapi_Int32_t Int32
32-bit signed integer type alias.
Definition blpapi_types.h:554
Definition blpapi_abstractsession.h:451
static int writeToStream(const char *data, int length, void *stream)
Definition blpapi_streamproxy.h:108