BLPAPI C++ 3.25.7
Loading...
Searching...
No Matches
blpapi_element.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_ELEMENT
29#define INCLUDED_BLPAPI_ELEMENT
30
59#include <blpapi_call.h>
60#include <blpapi_datetime.h>
61#include <blpapi_defs.h>
62#include <blpapi_deprecate.h>
63#include <blpapi_name.h>
64#include <blpapi_schema.h>
65#include <blpapi_streamproxy.h>
66#include <blpapi_types.h>
67
68#include <stddef.h>
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
75 const blpapi_Element_t *element);
76
78 const blpapi_Element_t *element);
79
81 const blpapi_Element_t *element);
82
84
86 const blpapi_Element_t *element);
87
89
91
93
95 const blpapi_Element_t *element);
96
98 const blpapi_Element_t *element, size_t position);
99
101
103 blpapi_StreamWriter_t streamWriter,
104 void *stream,
105 int level,
106 int spacesPerLevel);
107
110 blpapi_Element_t **result,
111 size_t position);
112
115 blpapi_Element_t **result,
116 const char *nameString,
117 const blpapi_Name_t *name);
118
121 const char *nameString,
122 const blpapi_Name_t *name);
123
126 const char *nameString,
127 const blpapi_Name_t *name,
128 int excludeNullElements,
129 int reserved);
130
133 const blpapi_Element_t *element, blpapi_Bool_t *buffer, size_t index);
134
137 const blpapi_Element_t *element, blpapi_Char_t *buffer, size_t index);
138
141 const blpapi_Element_t *element, blpapi_Int32_t *buffer, size_t index);
142
145 const blpapi_Element_t *element, blpapi_Int64_t *buffer, size_t index);
146
149 blpapi_Float32_t *buffer,
150 size_t index);
151
154 blpapi_Float64_t *buffer,
155 size_t index);
156
159 const blpapi_Element_t *element, const char **buffer, size_t index);
160
163 blpapi_Datetime_t *buffer,
164 size_t index);
165
168 const blpapi_Element_t *element,
170 size_t index);
171
174 blpapi_Element_t **buffer,
175 size_t index);
176
179 const blpapi_Element_t *element, blpapi_Name_t **buffer, size_t index);
180
183 const char **buffer,
184 size_t *length,
185 size_t index);
186
189 const blpapi_Element_t *element, blpapi_Element_t **result);
190
193 blpapi_Element_t *element, blpapi_Bool_t value, size_t index);
194
197 blpapi_Element_t *element, blpapi_Char_t value, size_t index);
198
201 blpapi_Element_t *element, blpapi_Int32_t value, size_t index);
202
205 blpapi_Element_t *element, blpapi_Int64_t value, size_t index);
206
209 blpapi_Element_t *element, blpapi_Float32_t value, size_t index);
210
213 blpapi_Element_t *element, blpapi_Float64_t value, size_t index);
214
217 blpapi_Element_t *element, const char *value, size_t index);
218
221 const blpapi_Datetime_t *value,
222 size_t index);
223
227 size_t index);
228
231 const char *value,
232 size_t length,
233 size_t index);
234
237 blpapi_Element_t *element, blpapi_Element_t *value, size_t index);
238
241 blpapi_Element_t *element, const blpapi_Name_t *value, size_t index);
242
245 const char *nameString,
246 const blpapi_Name_t *name,
247 blpapi_Bool_t value);
248
251 const char *nameString,
252 const blpapi_Name_t *name,
253 blpapi_Char_t value);
254
257 const char *nameString,
258 const blpapi_Name_t *name,
259 blpapi_Int32_t value);
260
263 const char *nameString,
264 const blpapi_Name_t *name,
265 blpapi_Int64_t value);
266
269 const char *nameString,
270 const blpapi_Name_t *name,
271 blpapi_Float32_t value);
272
275 const char *nameString,
276 const blpapi_Name_t *name,
277 blpapi_Float64_t value);
278
281 const char *nameString,
282 const blpapi_Name_t *name,
283 const char *value);
284
287 const char *nameString,
288 const blpapi_Name_t *name,
289 const blpapi_Datetime_t *value);
290
293 const char *nameString,
294 const blpapi_Name_t *name,
295 const blpapi_HighPrecisionDatetime_t *value);
296
299 const char *nameString,
300 const blpapi_Name_t *name,
301 const char *value,
302 size_t length);
303
306 const char *nameString,
307 const blpapi_Name_t *name,
308 blpapi_Element_t *sourcebuffer);
309
312 const char *elementName,
313 const blpapi_Name_t *name,
314 const blpapi_Name_t *buffer);
315
318 blpapi_Element_t *element, blpapi_Element_t **appendedElement);
319
322 blpapi_Element_t **resultElement,
323 const char *nameCstr,
324 const blpapi_Name_t *name,
325 size_t index);
326
327#ifdef __cplusplus
328}
329
330#include <blpapi_exception.h>
331
332#include <cassert>
333#include <string>
334#include <type_traits>
335
343namespace BloombergLP {
344namespace blpapi {
345
465class Element {
466
467 blpapi_Element_t *d_handle_p;
468
469 public:
470 Element();
477 explicit Element(blpapi_Element_t *element);
478
479 // MANIPULATORS
480
481 void rebind(blpapi_Element_t *element);
482
483 BLPAPI_DEPRECATE_STRING_NAME void setElement(const char *name, bool value);
496 BLPAPI_DEPRECATE_STRING_NAME void setElement(const char *name, char value);
509 BLPAPI_DEPRECATE_STRING_NAME void setElement(
510 const char *name, Int32 value);
523 BLPAPI_DEPRECATE_STRING_NAME void setElement(
524 const char *name, Int64 value);
537 BLPAPI_DEPRECATE_STRING_NAME void setElement(
538 const char *name, Float32 value);
551 BLPAPI_DEPRECATE_STRING_NAME void setElement(
552 const char *name, Float64 value);
565 BLPAPI_DEPRECATE_STRING_NAME void setElement(
566 const char *name, const Datetime& value);
579 BLPAPI_DEPRECATE_STRING_NAME void setElement(
580 const char *name, const char *value);
593 BLPAPI_DEPRECATE_STRING_NAME void setElement(
594 const char *name, const Name& value);
608 void setElement(const Name& name, bool value);
619 void setElement(const Name& name, char value);
630 void setElement(const Name& name, Int32 value);
641 void setElement(const Name& name, Int64 value);
652 void setElement(const Name& name, Float32 value);
663 void setElement(const Name& name, Float64 value);
674 void setElement(const Name& name, const Datetime& value);
685 void setElement(const Name& name, const char *value);
696 void setElement(const Name& name, const std::string& value);
708 void setElement(const Name& name, const Name& value);
719 void setElement(const Name& name, const void *value, size_t length);
730 template <typename BYTES,
731 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type
732 = true>
733 void setElement(const Name& name, const BYTES& value);
749 void setValue(bool value, size_t index = 0);
758 void setValue(char value, size_t index = 0);
767 void setValue(Int32 value, size_t index = 0);
776 void setValue(Int64 value, size_t index = 0);
785 void setValue(Float32 value, size_t index = 0);
794 void setValue(Float64 value, size_t index = 0);
803 void setValue(const Datetime& value, size_t index = 0);
812 void setValue(const char *value, size_t index = 0);
821 void setValue(const std::string& value, size_t index = 0);
831 void setValue(const Name& valueName, size_t index = 0);
841 void setValue(const void *value, size_t length, size_t index);
850 template <typename BYTES,
851 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type
852 = true>
853 void setValue(const BYTES& value, size_t index = 0);
867 void appendValue(bool value);
877 void appendValue(char value);
887 void appendValue(Int32 value);
897 void appendValue(Int64 value);
907 void appendValue(Float32 value);
917 void appendValue(Float64 value);
927 void appendValue(const Datetime& value);
937 void appendValue(const char *value);
947 void appendValue(const std::string& value);
959 void appendValue(const Name& value);
977 BLPAPI_DEPRECATE_STRING_NAME Element setChoice(const char *selectionName);
987 Element setChoice(const Name& selectionName);
996
997 // ACCESSORS
998
999 Name name() const;
1008 int datatype() const;
1016 bool isComplexType() const;
1022 bool isArray() const;
1029 bool isNull() const;
1034 bool isReadOnly() const;
1045 size_t numValues() const;
1055 size_t numElements() const;
1063 bool isValid() const;
1070 bool isNullValue(size_t position = 0) const;
1078 BLPAPI_DEPRECATE_STRING_NAME bool hasElement(
1079 const char *name, bool excludeNullElements = false) const;
1088 bool hasElement(const Name& name, bool excludeNullElements = false) const;
1095 int getValueAs(bool *result, size_t index = 0) const;
1104 int getValueAs(char *result, size_t index = 0) const;
1113 int getValueAs(Int32 *result, size_t index = 0) const;
1122 int getValueAs(Int64 *result, size_t index = 0) const;
1131 int getValueAs(Float32 *result, size_t index = 0) const;
1140 int getValueAs(Float64 *result, size_t index = 0) const;
1149 int getValueAs(Datetime *result, size_t index = 0) const;
1161 int getValueAs(std::string *result, size_t index = 0) const;
1170 int getValueAs(Bytes *result, size_t index = 0) const;
1178 int getValueAs(Element *result, size_t index = 0) const;
1187 int getValueAs(Name *result, size_t index = 0) const;
1195 bool getValueAsBool(size_t index = 0) const;
1202 char getValueAsChar(size_t index = 0) const;
1209 Int32 getValueAsInt32(size_t index = 0) const;
1216 Int64 getValueAsInt64(size_t index = 0) const;
1223 Float32 getValueAsFloat32(size_t index = 0) const;
1230 Float64 getValueAsFloat64(size_t index = 0) const;
1237 Datetime getValueAsDatetime(size_t index = 0) const;
1248 const char *getValueAsString(size_t index = 0) const;
1257 Bytes getValueAsBytes(size_t index = 0) const;
1265 Element getValueAsElement(size_t index = 0) const;
1273 Name getValueAsName(size_t index = 0) const;
1280 BLPAPI_DEPRECATE_STRING_NAME int getElement(
1281 Element *result, const char *name) const;
1292 int getElement(Element *result, const Name& name) const;
1301 int getElement(Element *result, size_t position) const;
1310 Element getElement(size_t position) const;
1318 Element getElement(const Name& name) const;
1326 BLPAPI_DEPRECATE_STRING_NAME Element getElement(const char *name) const;
1337 BLPAPI_DEPRECATE_STRING_NAME bool getElementAsBool(const char *name) const;
1348 bool getElementAsBool(const Name& name) const;
1357 BLPAPI_DEPRECATE_STRING_NAME char getElementAsChar(const char *name) const;
1368 char getElementAsChar(const Name& name) const;
1377 BLPAPI_DEPRECATE_STRING_NAME Int32 getElementAsInt32(
1378 const char *name) const;
1389 Int32 getElementAsInt32(const Name& name) const;
1398 BLPAPI_DEPRECATE_STRING_NAME Int64 getElementAsInt64(
1399 const char *name) const;
1410 Int64 getElementAsInt64(const Name& name) const;
1419 BLPAPI_DEPRECATE_STRING_NAME Float32 getElementAsFloat32(
1420 const char *name) const;
1431 Float32 getElementAsFloat32(const Name& name) const;
1440 BLPAPI_DEPRECATE_STRING_NAME Float64 getElementAsFloat64(
1441 const char *name) const;
1452 Float64 getElementAsFloat64(const Name& name) const;
1461 BLPAPI_DEPRECATE_STRING_NAME Datetime getElementAsDatetime(
1462 const char *name) const;
1477 Datetime getElementAsDatetime(const Name& name) const;
1489 BLPAPI_DEPRECATE_STRING_NAME const char *getElementAsString(
1490 const char *name) const;
1502 const char *getElementAsString(const Name& name) const;
1512 Bytes getElementAsBytes(const Name& name) const;
1522 BLPAPI_DEPRECATE_STRING_NAME Name getElementAsName(const char *name) const;
1533 Name getElementAsName(const Name& name) const;
1542 Element getChoice() const;
1548 const blpapi_Element_t *handle() const;
1549
1550 std::ostream& print(
1551 std::ostream& stream, int level = 0, int spacesPerLevel = 4) const;
1564};
1565
1569// FREE OPERATORS
1570std::ostream& operator<<(std::ostream& stream, const Element& element);
1584// ============================================================================
1585// INLINE AND TEMPLATE FUNCTION IMPLEMENTATIONS
1586// ============================================================================
1587
1588// -------------
1589// class Element
1590// -------------
1591
1593 : d_handle_p(0)
1594{
1595}
1596
1598 : d_handle_p(newHandle)
1599{
1600}
1601
1603{
1604 d_handle_p = element;
1605}
1606
1607inline void Element::setElement(const char *elementName, bool value)
1608{
1610 d_handle_p, elementName, 0, value ? 1 : 0));
1611}
1612
1613inline void Element::setElement(const char *elementName, char value)
1614{
1616 blpapi_Element_setElementChar(d_handle_p, elementName, 0, value));
1617}
1618
1619inline void Element::setElement(const char *elementName, Int32 value)
1620{
1622 blpapi_Element_setElementInt32(d_handle_p, elementName, 0, value));
1623}
1624
1625inline void Element::setElement(const char *elementName, Int64 value)
1626{
1628 blpapi_Element_setElementInt64(d_handle_p, elementName, 0, value));
1629}
1630
1631inline void Element::setElement(const char *elementName, Float32 value)
1632{
1634 d_handle_p, elementName, 0, value));
1635}
1636
1637inline void Element::setElement(const char *elementName, Float64 value)
1638{
1640 d_handle_p, elementName, 0, value));
1641}
1642
1643inline void Element::setElement(const char *elementName, const Datetime& value)
1644{
1647 elementName,
1648 0,
1649 &value.rawHighPrecisionValue()));
1650}
1651
1652inline void Element::setElement(const char *elementName, const char *value)
1653{
1655 d_handle_p, elementName, 0, value));
1656}
1657
1658inline void Element::setElement(const char *elementName, const Name& value)
1659{
1661 d_handle_p, elementName, 0, value.impl()));
1662}
1663
1664inline void Element::setElement(const Name& elementName, bool value)
1665{
1667 d_handle_p, 0, elementName.impl(), value ? 1 : 0));
1668}
1669
1670inline void Element::setElement(const Name& elementName, char value)
1671{
1673 d_handle_p, 0, elementName.impl(), value));
1674}
1675
1676inline void Element::setElement(const Name& elementName, Int32 value)
1677{
1679 d_handle_p, 0, elementName.impl(), value));
1680}
1681
1682inline void Element::setElement(const Name& elementName, Int64 value)
1683{
1685 d_handle_p, 0, elementName.impl(), value));
1686}
1687
1688inline void Element::setElement(const Name& elementName, Float32 value)
1689{
1691 d_handle_p, 0, elementName.impl(), value));
1692}
1693
1694inline void Element::setElement(const Name& elementName, Float64 value)
1695{
1697 d_handle_p, 0, elementName.impl(), value));
1698}
1699
1700inline void Element::setElement(const Name& elementName, const Datetime& value)
1701{
1704 0,
1705 elementName.impl(),
1706 &value.rawHighPrecisionValue()));
1707}
1708
1709inline void Element::setElement(const Name& elementName, const char *value)
1710{
1712 d_handle_p, 0, elementName.impl(), value));
1713}
1714
1716 const Name& elementName, const std::string& value)
1717{
1718 setElement(elementName, value.c_str());
1719}
1720
1721inline void Element::setElement(const Name& elementName, const Name& value)
1722{
1724 d_handle_p, 0, elementName.impl(), value.impl()));
1725}
1726
1728 const Name& elementName, const void *value, size_t length)
1729{
1732 0,
1733 elementName.impl(),
1734 reinterpret_cast<const char *>(value),
1735 length));
1736}
1737
1738template <typename BYTES,
1739 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type>
1740inline void Element::setElement(const Name& elementName, const BYTES& value)
1741{
1742 setElement(elementName, value.data(), value.size());
1743}
1744
1745inline void Element::setValue(bool value, size_t index)
1746{
1748 blpapi_Element_setValueBool(d_handle_p, value, index));
1749}
1750
1751inline void Element::setValue(char value, size_t index)
1752{
1754 blpapi_Element_setValueChar(d_handle_p, value, index));
1755}
1756
1757inline void Element::setValue(Int32 value, size_t index)
1758{
1760 blpapi_Element_setValueInt32(d_handle_p, value, index));
1761}
1762
1763inline void Element::setValue(Int64 value, size_t index)
1764{
1766 blpapi_Element_setValueInt64(d_handle_p, value, index));
1767}
1768
1769inline void Element::setValue(Float32 value, size_t index)
1770{
1772 blpapi_Element_setValueFloat32(d_handle_p, value, index));
1773}
1774
1775inline void Element::setValue(Float64 value, size_t index)
1776{
1778 blpapi_Element_setValueFloat64(d_handle_p, value, index));
1779}
1780
1781inline void Element::setValue(const Datetime& value, size_t index)
1782{
1785 d_handle_p, &value.rawHighPrecisionValue(), index));
1786}
1787
1788inline void Element::setValue(const char *value, size_t index)
1789{
1791 blpapi_Element_setValueString(d_handle_p, value, index));
1792}
1793
1794inline void Element::setValue(const std::string& value, size_t index)
1795{
1796 setValue(value.c_str(), index);
1797}
1798
1799inline void Element::setValue(const Name& valueName, size_t index)
1800{
1802 d_handle_p, valueName.impl(), index));
1803}
1804
1805inline void Element::setValue(const void *value, size_t length, size_t index)
1806{
1808 d_handle_p, reinterpret_cast<const char *>(value), length, index));
1809}
1810
1811template <typename BYTES,
1812 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type>
1813inline void Element::setValue(const BYTES& value, size_t index)
1814{
1815 setValue(value.data(), value.size(), index);
1816}
1817
1818inline void Element::appendValue(bool value)
1819{
1821 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
1822}
1823
1824inline void Element::appendValue(char value)
1825{
1827 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
1828}
1829
1835
1841
1847
1853
1861
1862inline void Element::appendValue(const char *value)
1863{
1865 d_handle_p, value, BLPAPI_ELEMENT_INDEX_END));
1866}
1867
1868inline void Element::appendValue(const std::string& value)
1869{
1870 appendValue(value.c_str());
1871}
1872
1873inline void Element::appendValue(const Name& valueName)
1874{
1876 d_handle_p, valueName.impl(), BLPAPI_ELEMENT_INDEX_END));
1877}
1878
1880{
1881 blpapi_Element_t *appendedElement = 0;
1883 blpapi_Element_appendElement(d_handle_p, &appendedElement));
1884 return Element(appendedElement);
1885}
1886
1887inline Element Element::setChoice(const char *selectionName)
1888{
1889 blpapi_Element_t *resultElement = 0;
1891 d_handle_p, &resultElement, selectionName, 0, 0));
1892 return Element(resultElement);
1893}
1894
1895inline Element Element::setChoice(const Name& selectionName)
1896{
1897 blpapi_Element_t *resultElement = 0;
1899 d_handle_p, &resultElement, 0, selectionName.impl(), 0));
1900 return Element(resultElement);
1901}
1902
1903inline blpapi_Element_t *Element::handle() { return d_handle_p; }
1904
1905inline Name Element::name() const
1906{
1907 return Name(blpapi_Element_name(d_handle_p));
1908}
1909
1910inline int Element::getElement(Element *element, const char *nameString) const
1911{
1912 assert(element);
1913
1914 blpapi_Element_t *fldt = 0;
1915 int rc = blpapi_Element_getElement(d_handle_p, &fldt, nameString, 0);
1916 if (!rc) {
1917 element->rebind(fldt);
1918 }
1919
1920 return rc;
1921}
1922
1923inline int Element::getElement(Element *element, const Name& elementName) const
1924{
1925 assert(element);
1926
1927 blpapi_Element_t *fldt = 0;
1929 d_handle_p, &fldt, 0, elementName.impl());
1930 if (!rc) {
1931 element->rebind(fldt);
1932 }
1933
1934 return rc;
1935}
1936
1937inline int Element::getElement(Element *element, size_t position) const
1938{
1939 assert(element);
1940
1941 blpapi_Element_t *fldt = 0;
1942 int rc = blpapi_Element_getElementAt(d_handle_p, &fldt, position);
1943 if (!rc) {
1944 element->rebind(fldt);
1945 }
1946
1947 return rc;
1948}
1949
1950inline int Element::datatype() const
1951{
1952 return blpapi_Element_datatype(d_handle_p);
1953}
1954
1955inline bool Element::isComplexType() const
1956{
1957 return blpapi_Element_isComplexType(d_handle_p) ? true : false;
1958}
1959
1960inline bool Element::isArray() const
1961{
1962 return blpapi_Element_isArray(d_handle_p) ? true : false;
1963}
1964
1965inline bool Element::isNull() const
1966{
1967 return blpapi_Element_isNull(d_handle_p) ? true : false;
1968}
1969
1970inline bool Element::isReadOnly() const
1971{
1972 return blpapi_Element_isReadOnly(d_handle_p) ? true : false;
1973}
1974
1979
1980inline size_t Element::numValues() const
1981{
1982 return blpapi_Element_numValues(d_handle_p);
1983}
1984
1985inline size_t Element::numElements() const
1986{
1987 return blpapi_Element_numElements(d_handle_p);
1988}
1989
1990inline bool Element::isValid() const { return d_handle_p ? true : false; }
1991
1992inline bool Element::isNullValue(size_t position) const
1993{
1994 int rc = blpapi_Element_isNullValue(d_handle_p, position);
1995 if (rc != 0 && rc != 1) {
1997 }
1998 return rc ? true : false;
1999}
2000
2002 const char *nameString, bool excludeNullElements) const
2003{
2004 if (excludeNullElements) {
2006 d_handle_p, nameString, 0, excludeNullElements, 0)
2007 ? true
2008 : false);
2009 }
2010 return blpapi_Element_hasElement(d_handle_p, nameString, 0) ? true : false;
2011}
2012
2014 const Name& elementName, bool excludeNullElements) const
2015{
2016 if (excludeNullElements) {
2017 return (blpapi_Element_hasElementEx(d_handle_p,
2018 0,
2019 elementName.impl(),
2020 excludeNullElements,
2021 0)
2022 ? true
2023 : false);
2024 }
2025 return blpapi_Element_hasElement(d_handle_p, 0, elementName.impl())
2026 ? true
2027 : false;
2028}
2029
2030inline Element Element::getElement(const Name& elementName) const
2031{
2032 blpapi_Element_t *fldt = 0;
2034 d_handle_p, &fldt, 0, elementName.impl()));
2035 return Element(fldt);
2036}
2037
2038inline Element Element::getElement(const char *elementName) const
2039{
2040 blpapi_Element_t *fldt = 0;
2042 blpapi_Element_getElement(d_handle_p, &fldt, elementName, 0));
2043 return Element(fldt);
2044}
2045
2046inline Element Element::getElement(size_t position) const
2047{
2048 blpapi_Element_t *element = 0;
2050 blpapi_Element_getElementAt(d_handle_p, &element, position));
2051 return Element(element);
2052}
2053
2054inline int Element::getValueAs(bool *buffer, size_t index) const
2055{
2056 assert(buffer);
2057
2058 blpapi_Bool_t tmp = false;
2059
2060 int res = blpapi_Element_getValueAsBool(d_handle_p, &tmp, index);
2061 *buffer = tmp ? true : false;
2062 return res;
2063}
2064
2065inline int Element::getValueAs(char *buffer, size_t index) const
2066{
2067 return blpapi_Element_getValueAsChar(d_handle_p, buffer, index);
2068}
2069
2070inline int Element::getValueAs(Int32 *buffer, size_t index) const
2071{
2072 return blpapi_Element_getValueAsInt32(d_handle_p, buffer, index);
2073}
2074
2075inline int Element::getValueAs(Int64 *buffer, size_t index) const
2076{
2077 return blpapi_Element_getValueAsInt64(d_handle_p, buffer, index);
2078}
2079
2080inline int Element::getValueAs(Float32 *buffer, size_t index) const
2081{
2082 return blpapi_Element_getValueAsFloat32(d_handle_p, buffer, index);
2083}
2084
2085inline int Element::getValueAs(Float64 *buffer, size_t index) const
2086{
2087 return blpapi_Element_getValueAsFloat64(d_handle_p, buffer, index);
2088}
2089
2090inline int Element::getValueAs(Datetime *buffer, size_t index) const
2091{
2093 d_handle_p, buffer, index);
2094}
2095
2096inline int Element::getValueAs(std::string *result, size_t index) const
2097{
2098 assert(result);
2099
2100 const char *buffer = 0;
2101 int rc = blpapi_Element_getValueAsString(d_handle_p, &buffer, index);
2102 if (!rc) {
2103 *result = buffer;
2104 }
2105 return rc;
2106}
2107
2108inline int Element::getValueAs(Bytes *result, size_t index) const
2109{
2110 assert(result);
2111
2112 const char *buffer = 0;
2113 size_t length = 0;
2115 d_handle_p, &buffer, &length, index);
2116 if (!rc) {
2117 result->assign(buffer, length);
2118 }
2119 return rc;
2120}
2121
2122inline int Element::getValueAs(Element *buffer, size_t index) const
2123{
2124 assert(buffer);
2125
2127 d_handle_p, &buffer->d_handle_p, index);
2128}
2129
2130inline int Element::getValueAs(Name *buffer, size_t index) const
2131{
2132 assert(buffer);
2133
2134 blpapi_Name_t *tmpName = 0;
2135 int res = blpapi_Element_getValueAsName(d_handle_p, &tmpName, index);
2136 if (!res) {
2137 *buffer = Name(tmpName);
2138 }
2139 return res;
2140}
2141
2142inline bool Element::getValueAsBool(size_t index) const
2143{
2144 bool value = false;
2146 return value;
2147}
2148
2149inline char Element::getValueAsChar(size_t index) const
2150{
2151 char value = 0;
2153 return value;
2154}
2155
2156inline Int32 Element::getValueAsInt32(size_t index) const
2157{
2158 Int32 value = 0;
2160 return value;
2161}
2162
2163inline Int64 Element::getValueAsInt64(size_t index) const
2164{
2165 Int64 value = 0;
2167 return value;
2168}
2169
2170inline Float32 Element::getValueAsFloat32(size_t index) const
2171{
2172 Float32 value = 0.0;
2174 return value;
2175}
2176
2177inline Float64 Element::getValueAsFloat64(size_t index) const
2178{
2179 Float64 value = 0.0;
2181 return value;
2182}
2183
2184inline Datetime Element::getValueAsDatetime(size_t index) const
2185{
2186 Datetime value;
2188 return value;
2189}
2190
2191inline const char *Element::getValueAsString(size_t index) const
2192{
2193 const char *tmpStringBuffer = 0;
2195 d_handle_p, &tmpStringBuffer, index));
2196 return tmpStringBuffer;
2197}
2198
2199inline Bytes Element::getValueAsBytes(size_t index) const
2200{
2201 Bytes value;
2203 return value;
2204}
2205
2206inline Element Element::getValueAsElement(size_t index) const
2207{
2208 blpapi_Element_t *element = 0;
2210 blpapi_Element_getValueAsElement(d_handle_p, &element, index));
2211 return Element(element);
2212}
2213
2214inline Name Element::getValueAsName(size_t index) const
2215{
2216 blpapi_Name_t *nameValue = 0;
2218 blpapi_Element_getValueAsName(d_handle_p, &nameValue, index));
2219 return Name(nameValue);
2220}
2221
2223{
2224 blpapi_Element_t *element = 0;
2226 blpapi_Element_getChoice(d_handle_p, &element));
2227 return Element(element);
2228}
2229
2230inline bool Element::getElementAsBool(const char *elementName) const
2231{
2232 return getElement(Name(elementName)).getValueAsBool();
2233}
2234
2235inline bool Element::getElementAsBool(const Name& elementName) const
2236{
2237 return getElement(elementName).getValueAsBool();
2238}
2239
2240inline char Element::getElementAsChar(const char *elementName) const
2241{
2242 return getElement(Name(elementName)).getValueAsChar();
2243}
2244
2245inline char Element::getElementAsChar(const Name& elementName) const
2246{
2247 return getElement(elementName).getValueAsChar();
2248}
2249
2250inline Int32 Element::getElementAsInt32(const char *elementName) const
2251{
2252 return getElement(Name(elementName)).getValueAsInt32();
2253}
2254
2255inline Int32 Element::getElementAsInt32(const Name& elementName) const
2256{
2257 return getElement(elementName).getValueAsInt32();
2258}
2259
2260inline Int64 Element::getElementAsInt64(const char *elementName) const
2261{
2262 return getElement(Name(elementName)).getValueAsInt64();
2263}
2264
2265inline Int64 Element::getElementAsInt64(const Name& elementName) const
2266{
2267 return getElement(elementName).getValueAsInt64();
2268}
2269
2270inline Float32 Element::getElementAsFloat32(const char *elementName) const
2271{
2272 return getElement(Name(elementName)).getValueAsFloat32();
2273}
2274
2275inline Float32 Element::getElementAsFloat32(const Name& elementName) const
2276{
2277 return getElement(elementName).getValueAsFloat32();
2278}
2279
2280inline Float64 Element::getElementAsFloat64(const char *elementName) const
2281{
2282 return getElement(Name(elementName)).getValueAsFloat64();
2283}
2284
2285inline Float64 Element::getElementAsFloat64(const Name& elementName) const
2286{
2287 return getElement(elementName).getValueAsFloat64();
2288}
2289
2290inline Datetime Element::getElementAsDatetime(const char *elementName) const
2291{
2292 return getElement(Name(elementName)).getValueAsDatetime();
2293}
2294
2295inline Datetime Element::getElementAsDatetime(const Name& elementName) const
2296{
2297 return getElement(elementName).getValueAsDatetime();
2298}
2299
2300inline const char *Element::getElementAsString(const char *elementName) const
2301{
2302 return getElement(Name(elementName)).getValueAsString();
2303}
2304
2305inline const char *Element::getElementAsString(const Name& elementName) const
2306{
2307 return getElement(elementName).getValueAsString();
2308}
2309
2310inline Bytes Element::getElementAsBytes(const Name& elementName) const
2311{
2312 return getElement(elementName).getValueAsBytes();
2313}
2314
2315inline Name Element::getElementAsName(const char *elementName) const
2316{
2317 return getElement(Name(elementName)).getValueAsName();
2318}
2319
2320inline Name Element::getElementAsName(const Name& elementName) const
2321{
2322 return getElement(elementName).getValueAsName();
2323}
2324
2325inline const blpapi_Element_t *Element::handle() const { return d_handle_p; }
2326
2327inline std::ostream& Element::print(
2328 std::ostream& stream, int level, int spacesPerLevel) const
2329{
2330 blpapi_Element_print(d_handle_p,
2332 &stream,
2333 level,
2334 spacesPerLevel);
2335 return stream;
2336}
2337
2338inline std::ostream& operator<<(std::ostream& stream, const Element& element)
2339{
2340 element.print(stream, 0, -1);
2341 return stream;
2342}
2343
2344} // close namespace blpapi
2345} // close namespace BloombergLP
2346
2347#endif // #ifdef __cplusplus
2348#endif // #ifndef INCLUDED_BLPAPI_ELEMENT
Provide functions for dispatchtbl.
#define BLPAPI_CALL_ELEMENT_GETVALUEASHIGHPRECISIONDATETIME(a1, a2, a3)
Definition blpapi_call.h:403
#define BLPAPI_CALL_ELEMENT_SETELEMENTHIGHPRECISIONDATETIME(a1, a2, a3, a4)
Definition blpapi_call.h:401
#define BLPAPI_CALL_ELEMENT_SETVALUEHIGHPRECISIONDATETIME(a1, a2, a3)
Definition blpapi_call.h:399
#define BLPAPI_CALL(FUNCNAME)
Definition blpapi_call.h:353
Represents a date and/or time.
Common definitions used by the library.
#define BLPAPI_EXPORT
Definition blpapi_defs.h:171
#define BLPAPI_ELEMENT_INDEX_END
Definition blpapi_defs.h:96
BLPAPI_EXPORT int blpapi_Element_setValueHighPrecisionDatetime(blpapi_Element_t *element, const blpapi_HighPrecisionDatetime_t *value, size_t index)
BLPAPI_EXPORT int blpapi_Element_getValueAsInt32(const blpapi_Element_t *element, blpapi_Int32_t *buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_setValueFromName(blpapi_Element_t *element, const blpapi_Name_t *value, size_t index)
BLPAPI_EXPORT int blpapi_Element_datatype(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_setElementHighPrecisionDatetime(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, const blpapi_HighPrecisionDatetime_t *value)
BLPAPI_EXPORT blpapi_Name_t * blpapi_Element_name(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_setValueFromElement(blpapi_Element_t *element, blpapi_Element_t *value, size_t index)
BLPAPI_EXPORT int blpapi_Element_setElementFromField(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, blpapi_Element_t *sourcebuffer)
BLPAPI_EXPORT int blpapi_Element_setElementFromName(blpapi_Element_t *element, const char *elementName, const blpapi_Name_t *name, const blpapi_Name_t *buffer)
BLPAPI_EXPORT int blpapi_Element_appendElement(blpapi_Element_t *element, blpapi_Element_t **appendedElement)
BLPAPI_EXPORT size_t blpapi_Element_numValues(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_getValueAsFloat64(const blpapi_Element_t *element, blpapi_Float64_t *buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_setValueString(blpapi_Element_t *element, const char *value, size_t index)
BLPAPI_EXPORT int blpapi_Element_isReadOnly(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_setElementInt32(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, blpapi_Int32_t value)
BLPAPI_EXPORT size_t blpapi_Element_numElements(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_setValueInt32(blpapi_Element_t *element, blpapi_Int32_t value, size_t index)
BLPAPI_EXPORT const char * blpapi_Element_nameString(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_setElementChar(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, blpapi_Char_t value)
BLPAPI_EXPORT int blpapi_Element_getElement(const blpapi_Element_t *element, blpapi_Element_t **result, const char *nameString, const blpapi_Name_t *name)
BLPAPI_EXPORT int blpapi_Element_setValueFloat32(blpapi_Element_t *element, blpapi_Float32_t value, size_t index)
BLPAPI_EXPORT int blpapi_Element_setValueBytes(blpapi_Element_t *element, const char *value, size_t length, size_t index)
BLPAPI_EXPORT int blpapi_Element_isNull(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_setElementBytes(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, const char *value, size_t length)
BLPAPI_EXPORT int blpapi_Element_isComplexType(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_getValueAsString(const blpapi_Element_t *element, const char **buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_setValueChar(blpapi_Element_t *element, blpapi_Char_t value, size_t index)
BLPAPI_EXPORT int blpapi_Element_getValueAsDatetime(const blpapi_Element_t *element, blpapi_Datetime_t *buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_setElementString(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, const char *value)
BLPAPI_EXPORT int blpapi_Element_setValueBool(blpapi_Element_t *element, blpapi_Bool_t value, size_t index)
BLPAPI_EXPORT int blpapi_Element_getValueAsChar(const blpapi_Element_t *element, blpapi_Char_t *buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_getElementAt(const blpapi_Element_t *element, blpapi_Element_t **result, size_t position)
BLPAPI_EXPORT int blpapi_Element_getValueAsBool(const blpapi_Element_t *element, blpapi_Bool_t *buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_setElementInt64(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, blpapi_Int64_t value)
BLPAPI_EXPORT int blpapi_Element_getValueAsFloat32(const blpapi_Element_t *element, blpapi_Float32_t *buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_hasElementEx(const blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, int excludeNullElements, int reserved)
BLPAPI_EXPORT int blpapi_Element_setElementBool(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, blpapi_Bool_t value)
BLPAPI_EXPORT int blpapi_Element_setValueInt64(blpapi_Element_t *element, blpapi_Int64_t value, size_t index)
BLPAPI_EXPORT int blpapi_Element_isArray(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_getChoice(const blpapi_Element_t *element, blpapi_Element_t **result)
BLPAPI_EXPORT int blpapi_Element_setElementFloat64(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, blpapi_Float64_t value)
BLPAPI_EXPORT int blpapi_Element_print(const blpapi_Element_t *element, blpapi_StreamWriter_t streamWriter, void *stream, int level, int spacesPerLevel)
BLPAPI_EXPORT int blpapi_Element_setElementDatetime(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, const blpapi_Datetime_t *value)
BLPAPI_EXPORT int blpapi_Element_getValueAsElement(const blpapi_Element_t *element, blpapi_Element_t **buffer, size_t index)
BLPAPI_EXPORT blpapi_SchemaElementDefinition_t * blpapi_Element_definition(const blpapi_Element_t *element)
BLPAPI_EXPORT int blpapi_Element_hasElement(const blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name)
BLPAPI_EXPORT int blpapi_Element_getValueAsHighPrecisionDatetime(const blpapi_Element_t *element, blpapi_HighPrecisionDatetime_t *buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_getValueAsName(const blpapi_Element_t *element, blpapi_Name_t **buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_getValueAsInt64(const blpapi_Element_t *element, blpapi_Int64_t *buffer, size_t index)
BLPAPI_EXPORT int blpapi_Element_setChoice(blpapi_Element_t *element, blpapi_Element_t **resultElement, const char *nameCstr, const blpapi_Name_t *name, size_t index)
BLPAPI_EXPORT int blpapi_Element_setValueFloat64(blpapi_Element_t *element, blpapi_Float64_t value, size_t index)
BLPAPI_EXPORT int blpapi_Element_setElementFloat32(blpapi_Element_t *element, const char *nameString, const blpapi_Name_t *name, blpapi_Float32_t value)
BLPAPI_EXPORT int blpapi_Element_getValueAsBytes(const blpapi_Element_t *element, const char **buffer, size_t *length, size_t index)
BLPAPI_EXPORT int blpapi_Element_isNullValue(const blpapi_Element_t *element, size_t position)
BLPAPI_EXPORT int blpapi_Element_setValueDatetime(blpapi_Element_t *element, const blpapi_Datetime_t *value, size_t index)
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.
int(* blpapi_StreamWriter_t)(const char *data, int length, void *stream)
Definition blpapi_streamproxy.h:53
Provide BLPAPI types.
int blpapi_Bool_t
Definition blpapi_types.h:62
char blpapi_Char_t
Definition blpapi_types.h:63
float blpapi_Float32_t
Definition blpapi_types.h:71
long long blpapi_Int64_t
Definition blpapi_types.h:69
int blpapi_Int32_t
Definition blpapi_types.h:67
double blpapi_Float64_t
Definition blpapi_types.h:72
Definition blpapi_types.h:312
void assign(pointer ptr, size_type length) noexcept
Definition blpapi_types.h:496
Definition blpapi_datetime.h:245
blpapi_HighPrecisionDatetime_t & rawHighPrecisionValue()
Definition blpapi_datetime.h:1954
Definition blpapi_element.h:465
BLPAPI_DEPRECATE_STRING_NAME Datetime getElementAsDatetime(const char *name) const
Definition blpapi_element.h:2290
Name name() const
Definition blpapi_element.h:1905
void rebind(blpapi_Element_t *element)
Definition blpapi_element.h:1602
int getValueAs(bool *result, size_t index=0) const
Definition blpapi_element.h:2054
BLPAPI_DEPRECATE_STRING_NAME Element setChoice(const char *selectionName)
Definition blpapi_element.h:1887
Bytes getElementAsBytes(const Name &name) const
Definition blpapi_element.h:2310
bool isNullValue(size_t position=0) const
Definition blpapi_element.h:1992
BLPAPI_DEPRECATE_STRING_NAME int getElement(Element *result, const char *name) const
Definition blpapi_element.h:1910
Float64 getValueAsFloat64(size_t index=0) const
Definition blpapi_element.h:2177
Element getValueAsElement(size_t index=0) const
Definition blpapi_element.h:2206
Name getValueAsName(size_t index=0) const
Definition blpapi_element.h:2214
int datatype() const
Definition blpapi_element.h:1950
BLPAPI_DEPRECATE_STRING_NAME Name getElementAsName(const char *name) const
Definition blpapi_element.h:2315
Int64 getValueAsInt64(size_t index=0) const
Definition blpapi_element.h:2163
Bytes getValueAsBytes(size_t index=0) const
Definition blpapi_element.h:2199
blpapi_Element_t * handle()
Definition blpapi_element.h:1903
BLPAPI_DEPRECATE_STRING_NAME Float64 getElementAsFloat64(const char *name) const
Definition blpapi_element.h:2280
size_t numValues() const
Definition blpapi_element.h:1980
bool isReadOnly() const
Definition blpapi_element.h:1970
BLPAPI_DEPRECATE_STRING_NAME bool hasElement(const char *name, bool excludeNullElements=false) const
Definition blpapi_element.h:2001
void appendValue(bool value)
Definition blpapi_element.h:1818
bool isValid() const
Definition blpapi_element.h:1990
BLPAPI_DEPRECATE_STRING_NAME bool getElementAsBool(const char *name) const
Definition blpapi_element.h:2230
bool getValueAsBool(size_t index=0) const
Definition blpapi_element.h:2142
std::ostream & print(std::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition blpapi_element.h:2327
void setValue(bool value, size_t index=0)
Definition blpapi_element.h:1745
BLPAPI_DEPRECATE_STRING_NAME char getElementAsChar(const char *name) const
Definition blpapi_element.h:2240
Element appendElement()
Definition blpapi_element.h:1879
const char * getValueAsString(size_t index=0) const
Definition blpapi_element.h:2191
bool isComplexType() const
Definition blpapi_element.h:1955
char getValueAsChar(size_t index=0) const
Definition blpapi_element.h:2149
BLPAPI_DEPRECATE_STRING_NAME void setElement(const char *name, bool value)
Definition blpapi_element.h:1607
Element()
Definition blpapi_element.h:1592
Datetime getValueAsDatetime(size_t index=0) const
Definition blpapi_element.h:2184
bool isNull() const
Definition blpapi_element.h:1965
SchemaElementDefinition elementDefinition() const
Definition blpapi_element.h:1975
BLPAPI_DEPRECATE_STRING_NAME Int64 getElementAsInt64(const char *name) const
Definition blpapi_element.h:2260
BLPAPI_DEPRECATE_STRING_NAME Int32 getElementAsInt32(const char *name) const
Definition blpapi_element.h:2250
Element getChoice() const
Definition blpapi_element.h:2222
Float32 getValueAsFloat32(size_t index=0) const
Definition blpapi_element.h:2170
bool isArray() const
Definition blpapi_element.h:1960
Int32 getValueAsInt32(size_t index=0) const
Definition blpapi_element.h:2156
BLPAPI_DEPRECATE_STRING_NAME const char * getElementAsString(const char *name) const
Definition blpapi_element.h:2300
BLPAPI_DEPRECATE_STRING_NAME Float32 getElementAsFloat32(const char *name) const
Definition blpapi_element.h:2270
size_t numElements() const
Definition blpapi_element.h:1985
static void throwOnError(int errorCode)
Definition blpapi_exception.h:526
Definition blpapi_name.h:150
blpapi_Name_t * impl() const
Definition blpapi_name.h:403
Definition blpapi_schema.h:327
struct blpapi_Name blpapi_Name_t
Definition blpapi_types.h:154
struct blpapi_SchemaElementDefinition blpapi_SchemaElementDefinition_t
Definition blpapi_types.h:191
struct blpapi_Element blpapi_Element_t
Definition blpapi_types.h:136
blpapi_Float64_t Float64
Definition blpapi_types.h:474
blpapi_Float32_t Float32
Definition blpapi_types.h:473
blpapi_Int64_t Int64
Definition blpapi_types.h:471
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition blpapi_correlationid.h:592
blpapi_Int32_t Int32
Definition blpapi_types.h:469
Definition blpapi_abstractsession.h:195
static int writeToStream(const char *data, int length, void *stream)
Definition blpapi_streamproxy.h:93
Definition blpapi_datetime.h:102
Definition blpapi_datetime.h:115