BLPAPI C++ 3.26.6
Loading...
Searching...
No Matches
blpapi_eventformatter.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
37
38#ifndef INCLUDED_BLPAPI_EVENTFORMATTER
39#define INCLUDED_BLPAPI_EVENTFORMATTER
40
67
68#include <blpapi_call.h>
69#include <blpapi_defs.h>
70#include <blpapi_deprecate.h>
71#include <blpapi_element.h>
72#include <blpapi_event.h>
73#include <blpapi_topic.h>
74#include <blpapi_types.h>
75
76#include <stddef.h>
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
83
86
99BLPAPI_EXPORT
100blpapi_EventFormatter_t *blpapi_EventFormatter_create(blpapi_Event_t *event);
101
109BLPAPI_EXPORT
110void blpapi_EventFormatter_destroy(blpapi_EventFormatter_t *victim);
111
136BLPAPI_EXPORT
137int blpapi_EventFormatter_appendMessage(blpapi_EventFormatter_t *formatter,
138 const char *typeString,
139 blpapi_Name_t *typeName,
140 const blpapi_Topic_t *topic);
141
169BLPAPI_EXPORT
170int blpapi_EventFormatter_appendMessageSeq(blpapi_EventFormatter_t *formatter,
171 const char *typeString,
172 blpapi_Name_t *typeName,
173 const blpapi_Topic_t *topic,
174 unsigned int sequenceNumber,
175 unsigned int);
176
198BLPAPI_EXPORT
199int blpapi_EventFormatter_appendResponse(blpapi_EventFormatter_t *formatter,
200 const char *typeString,
201 blpapi_Name_t *typeName);
202
226BLPAPI_EXPORT
227int blpapi_EventFormatter_appendRecapMessage(
228 blpapi_EventFormatter_t *formatter,
229 const blpapi_Topic_t *topic,
230 const blpapi_CorrelationId_t *cid);
231
259BLPAPI_EXPORT
260int blpapi_EventFormatter_appendRecapMessageSeq(
261 blpapi_EventFormatter_t *formatter,
262 const blpapi_Topic_t *topic,
263 const blpapi_CorrelationId_t *cid,
264 unsigned int sequenceNumber,
265 unsigned int);
266
293BLPAPI_EXPORT
294int blpapi_EventFormatter_appendFragmentedRecapMessage(
295 blpapi_EventFormatter_t *formatter,
296 const char *typeString,
297 blpapi_Name_t *typeName,
298 const blpapi_Topic_t *topic,
299 const blpapi_CorrelationId_t *cid,
300 int fragmentType);
301
329BLPAPI_EXPORT
330int blpapi_EventFormatter_appendFragmentedRecapMessageSeq(
331 blpapi_EventFormatter_t *formatter,
332 const char *typeString,
333 blpapi_Name_t *typeName,
334 const blpapi_Topic_t *topic,
335 int fragmentType,
336 unsigned int sequenceNumber);
337
359BLPAPI_EXPORT
360int blpapi_EventFormatter_setValueBool(blpapi_EventFormatter_t *formatter,
361 const char *typeString,
362 const blpapi_Name_t *typeName,
363 blpapi_Bool_t value);
364
386BLPAPI_EXPORT
387int blpapi_EventFormatter_setValueChar(blpapi_EventFormatter_t *formatter,
388 const char *typeString,
389 const blpapi_Name_t *typeName,
390 char value);
391
413BLPAPI_EXPORT
414int blpapi_EventFormatter_setValueInt32(blpapi_EventFormatter_t *formatter,
415 const char *typeString,
416 const blpapi_Name_t *typeName,
417 blpapi_Int32_t value);
418
440BLPAPI_EXPORT
441int blpapi_EventFormatter_setValueInt64(blpapi_EventFormatter_t *formatter,
442 const char *typeString,
443 const blpapi_Name_t *typeName,
444 blpapi_Int64_t value);
445
467BLPAPI_EXPORT
468int blpapi_EventFormatter_setValueFloat32(blpapi_EventFormatter_t *formatter,
469 const char *typeString,
470 const blpapi_Name_t *typeName,
471 blpapi_Float32_t value);
472
494BLPAPI_EXPORT
495int blpapi_EventFormatter_setValueFloat64(blpapi_EventFormatter_t *formatter,
496 const char *typeString,
497 const blpapi_Name_t *typeName,
498 blpapi_Float64_t value);
499
523BLPAPI_EXPORT
524int blpapi_EventFormatter_setValueDatetime(blpapi_EventFormatter_t *formatter,
525 const char *typeString,
526 const blpapi_Name_t *typeName,
527 const blpapi_Datetime_t *value);
528
553BLPAPI_EXPORT
554int blpapi_EventFormatter_setValueHighPrecisionDatetime(
555 blpapi_EventFormatter_t *formatter,
556 const char *typeString,
557 const blpapi_Name_t *typeName,
558 const blpapi_HighPrecisionDatetime_t *value);
559
584BLPAPI_EXPORT
585int blpapi_EventFormatter_setValueString(blpapi_EventFormatter_t *formatter,
586 const char *typeString,
587 const blpapi_Name_t *typeName,
588 const char *value);
589
613BLPAPI_EXPORT
614int blpapi_EventFormatter_setValueFromName(blpapi_EventFormatter_t *formatter,
615 const char *typeString,
616 const blpapi_Name_t *typeName,
617 const blpapi_Name_t *value);
618
640BLPAPI_EXPORT
641int blpapi_EventFormatter_setValueBytes(blpapi_EventFormatter_t *formatter,
642 const char *typeString,
643 const blpapi_Name_t *typeName,
644 const char *value,
645 size_t length);
646
668BLPAPI_EXPORT
669int blpapi_EventFormatter_setValueNull(blpapi_EventFormatter_t *formatter,
670 const char *typeString,
671 const blpapi_Name_t *typeName);
672
699BLPAPI_EXPORT
700int blpapi_EventFormatter_pushElement(blpapi_EventFormatter_t *formatter,
701 const char *typeString,
702 const blpapi_Name_t *typeName);
703
718BLPAPI_EXPORT
719int blpapi_EventFormatter_popElement(blpapi_EventFormatter_t *formatter);
720
733BLPAPI_EXPORT
734int blpapi_EventFormatter_appendValueBool(
735 blpapi_EventFormatter_t *formatter, blpapi_Bool_t value);
736
749BLPAPI_EXPORT
750int blpapi_EventFormatter_appendValueChar(
751 blpapi_EventFormatter_t *formatter, char value);
752
765BLPAPI_EXPORT
766int blpapi_EventFormatter_appendValueInt32(
767 blpapi_EventFormatter_t *formatter, blpapi_Int32_t value);
768
781BLPAPI_EXPORT
782int blpapi_EventFormatter_appendValueInt64(
783 blpapi_EventFormatter_t *formatter, blpapi_Int64_t value);
784
797BLPAPI_EXPORT
798int blpapi_EventFormatter_appendValueFloat32(
799 blpapi_EventFormatter_t *formatter, blpapi_Float32_t value);
800
813BLPAPI_EXPORT
814int blpapi_EventFormatter_appendValueFloat64(
815 blpapi_EventFormatter_t *formatter, blpapi_Float64_t value);
816
831BLPAPI_EXPORT
832int blpapi_EventFormatter_appendValueDatetime(
833 blpapi_EventFormatter_t *formatter, const blpapi_Datetime_t *value);
834
850BLPAPI_EXPORT
851int blpapi_EventFormatter_appendValueHighPrecisionDatetime(
852 blpapi_EventFormatter_t *formatter,
853 const blpapi_HighPrecisionDatetime_t *value);
854
868BLPAPI_EXPORT
869int blpapi_EventFormatter_appendValueString(
870 blpapi_EventFormatter_t *formatter, const char *value);
871
885BLPAPI_EXPORT
886int blpapi_EventFormatter_appendValueFromName(
887 blpapi_EventFormatter_t *formatter, const blpapi_Name_t *value);
888
901BLPAPI_EXPORT
902int blpapi_EventFormatter_appendElement(blpapi_EventFormatter_t *formatter);
903
918BLPAPI_EXPORT
919int blpapi_EventFormatter_getElementDefinition(
920 blpapi_EventFormatter_t *formatter,
921 blpapi_SchemaElementDefinition_t **definition);
922
938BLPAPI_EXPORT
939int blpapi_EventFormatter_getElement(
940 blpapi_EventFormatter_t *formatter, blpapi_Element_t **element);
941
944
945#ifdef __cplusplus
946}
947
948#include <string>
949#include <type_traits>
950
951namespace BloombergLP {
952namespace blpapi {
959
997class EventFormatter {
998
999 blpapi_EventFormatter_t *d_handle;
1000
1001 private:
1002 EventFormatter& operator=(const EventFormatter&);
1003 EventFormatter(const EventFormatter&);
1004 EventFormatter();
1005
1006 public:
1007 explicit EventFormatter(Event& event);
1014
1019
1020 void appendMessage(const Name& messageType, const Topic& topic);
1027
1028 void appendMessage(const Name& messageType,
1029 const Topic& topic,
1030 unsigned int sequenceNumber);
1041
1042 void appendResponse(const Name& operationName);
1053
1054 void appendRecapMessage(const Topic& topic, const CorrelationId *cid = 0);
1072
1073 void appendRecapMessage(
1074 const Topic& topic, Message::Fragment fragmentType);
1089
1090 void appendRecapMessage(const Name& messageType,
1091 const Topic& topic,
1109
1110 void appendRecapMessage(const Topic& topic,
1111 unsigned int sequenceNumber,
1112 const CorrelationId *cid = 0);
1134
1135 void appendRecapMessage(const Name& messageType,
1136 const Topic& topic,
1137 unsigned int sequenceNumber);
1150
1151 void appendRecapMessage(const Topic& topic,
1152 Message::Fragment fragmentType,
1153 unsigned int sequenceNumber);
1173
1174 void appendRecapMessage(const Name& messageType,
1175 const Topic& topic,
1176 Message::Fragment fragmentType,
1177 unsigned int sequenceNumber);
1197
1198 void appendRecapMessage(const CorrelationId& cid,
1218
1219 void appendRecapMessage(const Name& messageType,
1220 const CorrelationId& cid,
1240
1241 void setElement(const Name& name, bool value);
1250
1251 void setElement(const Name& name, char value);
1260
1261 void setElement(const Name& name, Int32 value);
1270
1271 void setElement(const Name& name, Int64 value);
1280
1281 void setElement(const Name& name, Float32 value);
1290
1291 void setElement(const Name& name, Float64 value);
1300
1301 void setElement(const Name& name, const Datetime& value);
1311
1312 void setElement(const Name& name, const Datetime::HighPrecision& value);
1323
1324 void setElement(const Name& name, const char *value);
1336
1337 void setElement(const Name& name, const std::string& value);
1347
1348 void setElement(const Name& name, const Name& value);
1357
1358 void setElement(const Name& name, const void *value, size_t length);
1371
1372 template <typename BYTES,
1373 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type
1374 = true>
1375 void setElement(const Name& name, const BYTES& value);
1390
1391 void setElementNull(const Name& name);
1401
1402 void pushElement(const Name& name);
1419
1420 void popElement();
1429
1430 void appendValue(bool value);
1436
1437 void appendValue(char value);
1443
1444 void appendValue(Int32 value);
1450
1451 void appendValue(Int64 value);
1457
1458 void appendValue(Float32 value);
1464
1465 void appendValue(Float64 value);
1471
1472 void appendValue(const char *value);
1478
1479 void appendValue(const std::string& value);
1485
1486 void appendValue(const Name& value);
1492
1493 void appendValue(const Datetime& value);
1499
1500 void appendValue(const Datetime::HighPrecision& value);
1506
1507 void appendElement();
1513
1517
1518 BLPAPI_DEPRECATE_STRING_NAME void appendMessage(
1519 const char *messageType, const Topic& topic);
1528
1529 BLPAPI_DEPRECATE_STRING_NAME void appendMessage(const char *messageType,
1530 const Topic& topic,
1531 unsigned int sequenceNumber);
1544
1545 BLPAPI_DEPRECATE_STRING_NAME void appendResponse(
1546 const char *operationName);
1558
1559 BLPAPI_DEPRECATE_STRING_NAME void appendRecapMessage(
1560 const char *messageType,
1561 const Topic& topic,
1582
1583 BLPAPI_DEPRECATE_STRING_NAME void appendRecapMessage(
1584 const char *messageType,
1585 const Topic& topic,
1586 unsigned int sequenceNumber);
1601
1602 BLPAPI_DEPRECATE_STRING_NAME void appendRecapMessage(
1603 const char *messageType,
1604 const Topic& topic,
1605 Message::Fragment fragmentType,
1606 unsigned int sequenceNumber);
1628
1629 BLPAPI_DEPRECATE_STRING_NAME void appendRecapMessage(
1630 const char *messageType,
1631 const CorrelationId& cid,
1653
1654 BLPAPI_DEPRECATE_STRING_NAME void setElement(const char *name, bool value);
1669
1670 BLPAPI_DEPRECATE_STRING_NAME void setElement(const char *name, char value);
1685
1686 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1687 const char *name, Int32 value);
1702
1703 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1704 const char *name, Int64 value);
1719
1720 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1721 const char *name, Float32 value);
1736
1737 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1738 const char *name, Float64 value);
1753
1754 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1755 const char *name, const Datetime& value);
1771
1772 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1773 const char *name, const Datetime::HighPrecision& value);
1790
1791 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1792 const char *name, const char *value);
1810
1811 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1812 const char *name, const Name& value);
1827
1828 BLPAPI_DEPRECATE_STRING_NAME void setElementNull(const char *name);
1844
1845 BLPAPI_DEPRECATE_STRING_NAME void pushElement(const char *name);
1853
1868
1869 void fromJson(const char *json);
1881
1882 void fromJson(const std::string& json);
1895
1897 const blpapi_EventFormatter_t *handle() const;
1901
1902 blpapi_EventFormatter_t *handle();
1907};
1908
1911
1912// ============================================================================
1913// INLINE AND TEMPLATE FUNCTION IMPLEMENTATIONS
1914// ============================================================================
1915
1916// --------------------
1917// class EventFormatter
1918// --------------------
1919
1920inline EventFormatter::EventFormatter(Event& event)
1921{
1922 d_handle = blpapi_EventFormatter_create(event.impl());
1923}
1924
1926{
1927 blpapi_EventFormatter_destroy(d_handle);
1928}
1929
1931 const char *messageType, const Topic& topic)
1932{
1933 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendMessage(
1934 d_handle, messageType, 0, topic.impl()));
1935}
1936
1938 const Name& messageType, const Topic& topic)
1939{
1940 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendMessage(
1941 d_handle, 0, messageType.impl(), topic.impl()));
1942}
1943
1944inline void EventFormatter::appendMessage(const char *messageType,
1945 const Topic& topic,
1946 unsigned int sequenceNumber)
1947{
1948 ExceptionUtil::throwOnError(BLPAPI_CALL_EVENTFORMATTER_APPENDMESSAGESEQ(
1949 d_handle, messageType, 0, topic.impl(), sequenceNumber, 0));
1950}
1951
1952inline void EventFormatter::appendMessage(const Name& messageType,
1953 const Topic& topic,
1954 unsigned int sequenceNumber)
1955{
1956 ExceptionUtil::throwOnError(BLPAPI_CALL_EVENTFORMATTER_APPENDMESSAGESEQ(
1957 d_handle, 0, messageType.impl(), topic.impl(), sequenceNumber, 0));
1958}
1959
1960inline void EventFormatter::appendResponse(const char *operationName)
1961{
1963 blpapi_EventFormatter_appendResponse(d_handle, operationName, 0));
1964}
1965
1966inline void EventFormatter::appendResponse(const Name& operationName)
1967{
1968 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendResponse(
1969 d_handle, 0, operationName.impl()));
1970}
1971
1973 const Topic& topic, const CorrelationId *cid)
1974{
1975 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendRecapMessage(
1976 d_handle, topic.impl(), cid ? &cid->impl() : 0));
1977}
1978
1980 const Topic& topic, Message::Fragment fragmentType)
1981{
1982 ExceptionUtil::throwOnError(BLPAPI_CALL(
1983 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
1984 0, // 'typeString'
1985 0, // 'typeName'
1986 topic.impl(), // 'topic'
1987 0, // 'cid'
1988 static_cast<int>(fragmentType)));
1989}
1990
1991inline void EventFormatter::appendRecapMessage(const Name& messageType,
1992 const Topic& topic,
1993 Message::Fragment fragmentType)
1994{
1995 ExceptionUtil::throwOnError(BLPAPI_CALL(
1996 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
1997 0, // 'typeString'
1998 messageType.impl(), // 'typeName'
1999 topic.impl(), // 'topic'
2000 0, // 'cid'
2001 static_cast<int>(fragmentType)));
2002}
2003
2004inline void EventFormatter::appendRecapMessage(const char *messageType,
2005 const Topic& topic,
2006 Message::Fragment fragmentType)
2007{
2008 ExceptionUtil::throwOnError(BLPAPI_CALL(
2009 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
2010 messageType, // 'typeString'
2011 0, // 'typeName'
2012 topic.impl(), // 'topic'
2013 0, // 'cid'
2014 static_cast<int>(fragmentType)));
2015}
2016
2018 unsigned int sequenceNumber,
2019 const CorrelationId *cid)
2020{
2022 BLPAPI_CALL_EVENTFORMATTER_APPENDRECAPMESSAGESEQ(d_handle,
2023 topic.impl(),
2024 cid ? &cid->impl() : 0,
2025 sequenceNumber,
2026 0));
2027}
2028
2029inline void EventFormatter::appendRecapMessage(const Name& messageType,
2030 const Topic& topic,
2031 unsigned int sequenceNumber)
2032{
2033 ExceptionUtil::throwOnError(BLPAPI_CALL(
2034 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
2035 0, // 'typeString'
2036 messageType.impl(), // 'typeName'
2037 topic.impl(), // 'topic'
2038 static_cast<int>(Message::FRAGMENT_NONE),
2039 sequenceNumber));
2040}
2041
2042inline void EventFormatter::appendRecapMessage(const char *messageType,
2043 const Topic& topic,
2044 unsigned int sequenceNumber)
2045{
2046 ExceptionUtil::throwOnError(BLPAPI_CALL(
2047 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
2048 messageType, // 'typeString'
2049 0, // 'typeName'
2050 topic.impl(), // 'topic'
2051 static_cast<int>(Message::FRAGMENT_NONE),
2052 sequenceNumber));
2053}
2054
2056 Message::Fragment fragmentType,
2057 unsigned int sequenceNumber)
2058{
2059 ExceptionUtil::throwOnError(BLPAPI_CALL(
2060 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
2061 0, // 'typeString'
2062 0, // 'typeName'
2063 topic.impl(), // 'topic'
2064 static_cast<int>(fragmentType),
2065 sequenceNumber));
2066}
2067
2068inline void EventFormatter::appendRecapMessage(const Name& messageType,
2069 const Topic& topic,
2070 Message::Fragment fragmentType,
2071 unsigned int sequenceNumber)
2072{
2073 ExceptionUtil::throwOnError(BLPAPI_CALL(
2074 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
2075 0, // 'typeString'
2076 messageType.impl(), // 'typeName'
2077 topic.impl(), // 'topic'
2078 static_cast<int>(fragmentType),
2079 sequenceNumber));
2080}
2081
2082inline void EventFormatter::appendRecapMessage(const char *messageType,
2083 const Topic& topic,
2084 Message::Fragment fragmentType,
2085 unsigned int sequenceNumber)
2086{
2087 ExceptionUtil::throwOnError(BLPAPI_CALL(
2088 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
2089 messageType, // 'typeString'
2090 0, // 'typeName'
2091 topic.impl(), // 'topic'
2092 static_cast<int>(fragmentType),
2093 sequenceNumber));
2094}
2095
2097 const CorrelationId& cid, Message::Fragment fragmentType)
2098{
2099 ExceptionUtil::throwOnError(BLPAPI_CALL(
2100 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
2101 0, // 'typeString'
2102 0, // 'typeName'
2103 0, // 'topic'
2104 &cid.impl(), // 'cid'
2105 static_cast<int>(fragmentType)));
2106}
2107
2108inline void EventFormatter::appendRecapMessage(const Name& messageType,
2109 const CorrelationId& cid,
2110 Message::Fragment fragmentType)
2111{
2112 ExceptionUtil::throwOnError(BLPAPI_CALL(
2113 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
2114 0, // 'typeString'
2115 messageType.impl(), // 'typeName'
2116 0, // 'topic'
2117 &cid.impl(), // 'cid'
2118 static_cast<int>(fragmentType)));
2119}
2120
2121inline void EventFormatter::appendRecapMessage(const char *messageType,
2122 const CorrelationId& cid,
2123 Message::Fragment fragmentType)
2124{
2125 ExceptionUtil::throwOnError(BLPAPI_CALL(
2126 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
2127 messageType, // 'typeString'
2128 0, // 'typeName'
2129 0, // 'topic'
2130 &cid.impl(), // 'cid'
2131 static_cast<int>(fragmentType)));
2132}
2133
2134inline void EventFormatter::setElement(const char *name, bool value)
2135{
2137 blpapi_EventFormatter_setValueBool(d_handle, name, 0, value));
2138}
2139
2140inline void EventFormatter::setElement(const char *name, char value)
2141{
2143 blpapi_EventFormatter_setValueChar(d_handle, name, 0, value));
2144}
2145
2146inline void EventFormatter::setElement(const char *name, Int32 value)
2147{
2149 blpapi_EventFormatter_setValueInt32(d_handle, name, 0, value));
2150}
2151
2152inline void EventFormatter::setElement(const char *name, Int64 value)
2153{
2155 blpapi_EventFormatter_setValueInt64(d_handle, name, 0, value));
2156}
2157
2158inline void EventFormatter::setElement(const char *name, Float32 value)
2159{
2161 blpapi_EventFormatter_setValueFloat32(d_handle, name, 0, value));
2162}
2163
2164inline void EventFormatter::setElement(const char *name, Float64 value)
2165{
2167 blpapi_EventFormatter_setValueFloat64(d_handle, name, 0, value));
2168}
2169
2170inline void EventFormatter::setElement(const char *name, const Datetime& value)
2171{
2172 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueDatetime(
2173 d_handle, name, 0, &value.rawValue()));
2174}
2175
2177 const char *name, const Datetime::HighPrecision& value)
2178{
2180 BLPAPI_CALL(blpapi_EventFormatter_setValueHighPrecisionDatetime)(
2181 d_handle, name, 0, &value));
2182}
2183
2184inline void EventFormatter::setElement(const char *name, const char *value)
2185{
2187 blpapi_EventFormatter_setValueString(d_handle, name, 0, value));
2188}
2189
2190inline void EventFormatter::setElement(const char *name, const Name& value)
2191{
2192 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueFromName(
2193 d_handle, name, 0, value.impl()));
2194}
2195
2196inline void EventFormatter::setElementNull(const char *name)
2197{
2199 BLPAPI_CALL_EVENTFORMATTER_SETVALUENULL(d_handle, name, 0));
2200}
2201
2202inline void EventFormatter::setElement(const Name& name, bool value)
2203{
2204 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueBool(
2205 d_handle, 0, name.impl(), value));
2206}
2207
2208inline void EventFormatter::setElement(const Name& name, char value)
2209{
2210 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueChar(
2211 d_handle, 0, name.impl(), value));
2212}
2213
2214inline void EventFormatter::setElement(const Name& name, Int32 value)
2215{
2216 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueInt32(
2217 d_handle, 0, name.impl(), value));
2218}
2219
2220inline void EventFormatter::setElement(const Name& name, Int64 value)
2221{
2222 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueInt64(
2223 d_handle, 0, name.impl(), value));
2224}
2225
2226inline void EventFormatter::setElement(const Name& name, Float32 value)
2227{
2228 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueFloat32(
2229 d_handle, 0, name.impl(), value));
2230}
2231inline void EventFormatter::setElement(const Name& name, Float64 value)
2232{
2233 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueFloat64(
2234 d_handle, 0, name.impl(), value));
2235}
2236
2237inline void EventFormatter::setElement(const Name& name, const Datetime& value)
2238{
2239 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueDatetime(
2240 d_handle, 0, name.impl(), &value.rawValue()));
2241}
2242
2244 const Name& name, const Datetime::HighPrecision& value)
2245{
2247 BLPAPI_CALL(blpapi_EventFormatter_setValueHighPrecisionDatetime)(
2248 d_handle, 0, name.impl(), &value));
2249}
2250
2251inline void EventFormatter::setElement(const Name& name, const char *value)
2252{
2253 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueString(
2254 d_handle, 0, name.impl(), value));
2255}
2256
2258 const Name& name, const std::string& value)
2259{
2260 setElement(name, value.c_str());
2261}
2262
2263inline void EventFormatter::setElement(const Name& name, const Name& value)
2264{
2265 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueFromName(
2266 d_handle, 0, name.impl(), value.impl()));
2267}
2268
2270 const Name& name, const void *value, size_t length)
2271{
2273 BLPAPI_CALL(blpapi_EventFormatter_setValueBytes)(d_handle,
2274 0,
2275 name.impl(),
2276 reinterpret_cast<const char *>(value),
2277 length));
2278}
2279
2280template <typename BYTES,
2281 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type>
2282inline void EventFormatter::setElement(const Name& name, const BYTES& value)
2283{
2284 setElement(name, value.data(), value.size());
2285}
2286
2287inline void EventFormatter::setElementNull(const Name& name)
2288{
2290 BLPAPI_CALL_EVENTFORMATTER_SETVALUENULL(d_handle, 0, name.impl()));
2291}
2292
2293inline void EventFormatter::pushElement(const char *name)
2294{
2296 blpapi_EventFormatter_pushElement(d_handle, name, 0));
2297}
2298
2299inline void EventFormatter::pushElement(const Name& name)
2300{
2302 blpapi_EventFormatter_pushElement(d_handle, 0, name.impl()));
2303}
2304
2306{
2307 ExceptionUtil::throwOnError(blpapi_EventFormatter_popElement(d_handle));
2308}
2309
2310inline void EventFormatter::appendValue(bool value)
2311{
2313 blpapi_EventFormatter_appendValueBool(d_handle, value));
2314}
2315
2316inline void EventFormatter::appendValue(char value)
2317{
2319 blpapi_EventFormatter_appendValueChar(d_handle, value));
2320}
2321
2323{
2325 blpapi_EventFormatter_appendValueInt32(d_handle, value));
2326}
2327
2329{
2331 blpapi_EventFormatter_appendValueInt64(d_handle, value));
2332}
2333
2335{
2337 blpapi_EventFormatter_appendValueFloat32(d_handle, value));
2338}
2339
2341{
2343 blpapi_EventFormatter_appendValueFloat64(d_handle, value));
2344}
2345
2346inline void EventFormatter::appendValue(const Datetime& value)
2347{
2348 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendValueDatetime(
2349 d_handle, &value.rawValue()));
2350}
2351
2353{
2354 ExceptionUtil::throwOnError(BLPAPI_CALL(
2355 blpapi_EventFormatter_appendValueHighPrecisionDatetime)(
2356 d_handle, &value));
2357}
2358
2359inline void EventFormatter::appendValue(const char *value)
2360{
2362 blpapi_EventFormatter_appendValueString(d_handle, value));
2363}
2364
2365inline void EventFormatter::appendValue(const std::string& value)
2366{
2367 appendValue(value.c_str());
2368}
2369
2370inline void EventFormatter::appendValue(const Name& value)
2371{
2373 blpapi_EventFormatter_appendValueFromName(d_handle, value.impl()));
2374}
2375
2377{
2378 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendElement(d_handle));
2379}
2380
2382{
2383 blpapi_Element_t *element = nullptr;
2385 blpapi_EventFormatter_getElement(d_handle, &element));
2386 if (element == nullptr) {
2387 throw blpapi::InvalidStateException("Not a valid element");
2388 }
2389 return blpapi::Element(element);
2390}
2391
2392inline void EventFormatter::fromJson(const char *json)
2393{
2394 getElement().fromJson(json);
2395}
2396
2397inline void EventFormatter::fromJson(const std::string& json)
2398{
2399 fromJson(json.c_str());
2400}
2401
2403inline const blpapi_EventFormatter_t *EventFormatter::handle() const
2404{
2405 return d_handle;
2406}
2407
2408inline blpapi_EventFormatter_t *EventFormatter::handle() { return d_handle; }
2410
2411} // close namespace blpapi
2412} // close namespace BloombergLP
2413
2414#endif // #ifdef __cplusplus
2415#endif // #ifndef INCLUDED_BLPAPI_EVENTFORMATTER
Provide functions for dispatchtbl.
Common definitions used by the library.
Provide a representation of an item in a message.
A component which defines events related operations.
Provide representation of a Topic.
Provide BLPAPI types.
Definition blpapi_correlationid.h:306
Definition blpapi_datetime.h:312
blpapi_HighPrecisionDatetime_t HighPrecision
Definition blpapi_datetime.h:338
blpapi_Datetime_t & rawValue()
Definition blpapi_datetime.h:2018
Definition blpapi_element.h:1098
void fromJson(const char *json)
Definition blpapi_element.h:3003
blpapi::Element getElement()
Definition blpapi_eventformatter.h:2381
void appendValue(bool value)
Definition blpapi_eventformatter.h:2310
void appendMessage(const Name &messageType, const Topic &topic)
Definition blpapi_eventformatter.h:1937
void setElementNull(const Name &name)
Definition blpapi_eventformatter.h:2287
void setElement(const Name &name, bool value)
Definition blpapi_eventformatter.h:2202
void appendRecapMessage(const Topic &topic, const CorrelationId *cid=0)
Definition blpapi_eventformatter.h:1972
void appendResponse(const Name &operationName)
Definition blpapi_eventformatter.h:1966
~EventFormatter()
Definition blpapi_eventformatter.h:1925
void appendElement()
Definition blpapi_eventformatter.h:2376
void fromJson(const char *json)
Definition blpapi_eventformatter.h:2392
void popElement()
Definition blpapi_eventformatter.h:2305
void pushElement(const Name &name)
Definition blpapi_eventformatter.h:2299
Definition blpapi_event.h:325
static void throwOnError(int errorCode)
Definition blpapi_exception.h:556
Definition blpapi_exception.h:252
Fragment
Definition blpapi_message.h:354
@ FRAGMENT_NONE
message is not fragmented
Definition blpapi_message.h:356
Definition blpapi_name.h:228
Definition blpapi_topic.h:177
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
blpapi_Int32_t Int32
32-bit signed integer type alias.
Definition blpapi_types.h:554
Definition blpapi_abstractsession.h:451