BLPAPI C++ 3.26.5
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
35
36#ifndef INCLUDED_BLPAPI_EVENTFORMATTER
37#define INCLUDED_BLPAPI_EVENTFORMATTER
38
66
67#include <blpapi_call.h>
68#include <blpapi_defs.h>
69#include <blpapi_deprecate.h>
70#include <blpapi_element.h>
71#include <blpapi_event.h>
72#include <blpapi_topic.h>
73#include <blpapi_types.h>
74
75#include <stddef.h>
76
77#ifdef __cplusplus
78extern "C" {
79#endif
80
82
85
86BLPAPI_EXPORT
87blpapi_EventFormatter_t *blpapi_EventFormatter_create(blpapi_Event_t *event);
88
89BLPAPI_EXPORT
90void blpapi_EventFormatter_destroy(blpapi_EventFormatter_t *victim);
91
92BLPAPI_EXPORT
93int blpapi_EventFormatter_appendMessage(blpapi_EventFormatter_t *formatter,
94 const char *typeString,
95 blpapi_Name_t *typeName,
96 const blpapi_Topic_t *topic);
97
98BLPAPI_EXPORT
99int blpapi_EventFormatter_appendMessageSeq(blpapi_EventFormatter_t *formatter,
100 const char *typeString,
101 blpapi_Name_t *typeName,
102 const blpapi_Topic_t *topic,
103 unsigned int sequenceNumber,
104 unsigned int);
105
106BLPAPI_EXPORT
107int blpapi_EventFormatter_appendResponse(blpapi_EventFormatter_t *formatter,
108 const char *typeString,
109 blpapi_Name_t *typeName);
110
111BLPAPI_EXPORT
112int blpapi_EventFormatter_appendRecapMessage(
113 blpapi_EventFormatter_t *formatter,
114 const blpapi_Topic_t *topic,
115 const blpapi_CorrelationId_t *cid);
116
117BLPAPI_EXPORT
118int blpapi_EventFormatter_appendRecapMessageSeq(
119 blpapi_EventFormatter_t *formatter,
120 const blpapi_Topic_t *topic,
121 const blpapi_CorrelationId_t *cid,
122 unsigned int sequenceNumber,
123 unsigned int);
124
125BLPAPI_EXPORT
126int blpapi_EventFormatter_appendFragmentedRecapMessage(
127 blpapi_EventFormatter_t *formatter,
128 const char *typeString,
129 blpapi_Name_t *typeName,
130 const blpapi_Topic_t *topic,
131 const blpapi_CorrelationId_t *cid,
132 int fragmentType);
133
134BLPAPI_EXPORT
135int blpapi_EventFormatter_appendFragmentedRecapMessageSeq(
136 blpapi_EventFormatter_t *formatter,
137 const char *typeString,
138 blpapi_Name_t *typeName,
139 const blpapi_Topic_t *topic,
140 int fragmentType,
141 unsigned int sequenceNumber);
142
143BLPAPI_EXPORT
144int blpapi_EventFormatter_setValueBool(blpapi_EventFormatter_t *formatter,
145 const char *typeString,
146 const blpapi_Name_t *typeName,
147 blpapi_Bool_t value);
148
149BLPAPI_EXPORT
150int blpapi_EventFormatter_setValueChar(blpapi_EventFormatter_t *formatter,
151 const char *typeString,
152 const blpapi_Name_t *typeName,
153 char value);
154
155BLPAPI_EXPORT
156int blpapi_EventFormatter_setValueInt32(blpapi_EventFormatter_t *formatter,
157 const char *typeString,
158 const blpapi_Name_t *typeName,
159 blpapi_Int32_t value);
160
161BLPAPI_EXPORT
162int blpapi_EventFormatter_setValueInt64(blpapi_EventFormatter_t *formatter,
163 const char *typeString,
164 const blpapi_Name_t *typeName,
165 blpapi_Int64_t value);
166
167BLPAPI_EXPORT
168int blpapi_EventFormatter_setValueFloat32(blpapi_EventFormatter_t *formatter,
169 const char *typeString,
170 const blpapi_Name_t *typeName,
171 blpapi_Float32_t value);
172
173BLPAPI_EXPORT
174int blpapi_EventFormatter_setValueFloat64(blpapi_EventFormatter_t *formatter,
175 const char *typeString,
176 const blpapi_Name_t *typeName,
177 blpapi_Float64_t value);
178
179BLPAPI_EXPORT
180int blpapi_EventFormatter_setValueDatetime(blpapi_EventFormatter_t *formatter,
181 const char *typeString,
182 const blpapi_Name_t *typeName,
183 const blpapi_Datetime_t *value);
184
185BLPAPI_EXPORT
186int blpapi_EventFormatter_setValueHighPrecisionDatetime(
187 blpapi_EventFormatter_t *formatter,
188 const char *typeString,
189 const blpapi_Name_t *typeName,
190 const blpapi_HighPrecisionDatetime_t *value);
191
192BLPAPI_EXPORT
193int blpapi_EventFormatter_setValueString(blpapi_EventFormatter_t *formatter,
194 const char *typeString,
195 const blpapi_Name_t *typeName,
196 const char *value);
197
198BLPAPI_EXPORT
199int blpapi_EventFormatter_setValueFromName(blpapi_EventFormatter_t *formatter,
200 const char *typeString,
201 const blpapi_Name_t *typeName,
202 const blpapi_Name_t *value);
203
204BLPAPI_EXPORT
205int blpapi_EventFormatter_setValueBytes(blpapi_EventFormatter_t *formatter,
206 const char *typeString,
207 const blpapi_Name_t *typeName,
208 const char *value,
209 size_t length);
210
211BLPAPI_EXPORT
212int blpapi_EventFormatter_setValueNull(blpapi_EventFormatter_t *formatter,
213 const char *typeString,
214 const blpapi_Name_t *typeName);
215
216BLPAPI_EXPORT
217int blpapi_EventFormatter_pushElement(blpapi_EventFormatter_t *formatter,
218 const char *typeString,
219 const blpapi_Name_t *typeName);
220
221BLPAPI_EXPORT
222int blpapi_EventFormatter_popElement(blpapi_EventFormatter_t *formatter);
223
224BLPAPI_EXPORT
225int blpapi_EventFormatter_appendValueBool(
226 blpapi_EventFormatter_t *formatter, blpapi_Bool_t value);
227
228BLPAPI_EXPORT
229int blpapi_EventFormatter_appendValueChar(
230 blpapi_EventFormatter_t *formatter, char value);
231
232BLPAPI_EXPORT
233int blpapi_EventFormatter_appendValueInt32(
234 blpapi_EventFormatter_t *formatter, blpapi_Int32_t value);
235
236BLPAPI_EXPORT
237int blpapi_EventFormatter_appendValueInt64(
238 blpapi_EventFormatter_t *formatter, blpapi_Int64_t value);
239
240BLPAPI_EXPORT
241int blpapi_EventFormatter_appendValueFloat32(
242 blpapi_EventFormatter_t *formatter, blpapi_Float32_t value);
243
244BLPAPI_EXPORT
245int blpapi_EventFormatter_appendValueFloat64(
246 blpapi_EventFormatter_t *formatter, blpapi_Float64_t value);
247
248BLPAPI_EXPORT
249int blpapi_EventFormatter_appendValueDatetime(
250 blpapi_EventFormatter_t *formatter, const blpapi_Datetime_t *value);
251
252BLPAPI_EXPORT
253int blpapi_EventFormatter_appendValueHighPrecisionDatetime(
254 blpapi_EventFormatter_t *formatter,
255 const blpapi_HighPrecisionDatetime_t *value);
256
257BLPAPI_EXPORT
258int blpapi_EventFormatter_appendValueString(
259 blpapi_EventFormatter_t *formatter, const char *value);
260
261BLPAPI_EXPORT
262int blpapi_EventFormatter_appendValueFromName(
263 blpapi_EventFormatter_t *formatter, const blpapi_Name_t *value);
264
265BLPAPI_EXPORT
266int blpapi_EventFormatter_appendElement(blpapi_EventFormatter_t *formatter);
267
268BLPAPI_EXPORT
269int blpapi_EventFormatter_getElementDefinition(
270 blpapi_EventFormatter_t *formatter,
271 blpapi_SchemaElementDefinition_t **definition);
272
273BLPAPI_EXPORT
274int blpapi_EventFormatter_getElement(
275 blpapi_EventFormatter_t *formatter, blpapi_Element_t **element);
276
279
280#ifdef __cplusplus
281}
282
283#include <string>
284#include <type_traits>
285
292
293namespace BloombergLP {
294namespace blpapi {
295
333class EventFormatter {
334
335 blpapi_EventFormatter_t *d_handle;
336
337 private:
338 EventFormatter& operator=(const EventFormatter&);
339 EventFormatter(const EventFormatter&);
340 EventFormatter();
341
342 public:
343 explicit EventFormatter(Event& event);
350
355
356 void appendMessage(const Name& messageType, const Topic& topic);
363
364 void appendMessage(const Name& messageType,
365 const Topic& topic,
366 unsigned int sequenceNumber);
377
378 void appendResponse(const Name& operationName);
389
390 void appendRecapMessage(const Topic& topic, const CorrelationId *cid = 0);
408
410 const Topic& topic, Message::Fragment fragmentType);
425
426 void appendRecapMessage(const Name& messageType,
427 const Topic& topic,
445
446 void appendRecapMessage(const Topic& topic,
447 unsigned int sequenceNumber,
448 const CorrelationId *cid = 0);
470
471 void appendRecapMessage(const Name& messageType,
472 const Topic& topic,
473 unsigned int sequenceNumber);
486
487 void appendRecapMessage(const Topic& topic,
488 Message::Fragment fragmentType,
489 unsigned int sequenceNumber);
509
510 void appendRecapMessage(const Name& messageType,
511 const Topic& topic,
512 Message::Fragment fragmentType,
513 unsigned int sequenceNumber);
533
534 void appendRecapMessage(const CorrelationId& cid,
554
555 void appendRecapMessage(const Name& messageType,
556 const CorrelationId& cid,
576
577 void setElement(const Name& name, bool value);
586
587 void setElement(const Name& name, char value);
596
597 void setElement(const Name& name, Int32 value);
606
607 void setElement(const Name& name, Int64 value);
616
617 void setElement(const Name& name, Float32 value);
626
627 void setElement(const Name& name, Float64 value);
636
637 void setElement(const Name& name, const Datetime& value);
647
648 void setElement(const Name& name, const Datetime::HighPrecision& value);
659
660 void setElement(const Name& name, const char *value);
672
673 void setElement(const Name& name, const std::string& value);
683
684 void setElement(const Name& name, const Name& value);
693
694 void setElement(const Name& name, const void *value, size_t length);
707
708 template <typename BYTES,
709 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type
710 = true>
711 void setElement(const Name& name, const BYTES& value);
726
727 void setElementNull(const Name& name);
737
738 void pushElement(const Name& name);
755
756 void popElement();
765
766 void appendValue(bool value);
772
773 void appendValue(char value);
779
780 void appendValue(Int32 value);
786
787 void appendValue(Int64 value);
793
794 void appendValue(Float32 value);
800
801 void appendValue(Float64 value);
807
808 void appendValue(const char *value);
814
815 void appendValue(const std::string& value);
821
822 void appendValue(const Name& value);
828
829 void appendValue(const Datetime& value);
835
836 void appendValue(const Datetime::HighPrecision& value);
842
843 void appendElement();
849
853
854 BLPAPI_DEPRECATE_STRING_NAME void appendMessage(
855 const char *messageType, const Topic& topic);
864
865 BLPAPI_DEPRECATE_STRING_NAME void appendMessage(const char *messageType,
866 const Topic& topic,
867 unsigned int sequenceNumber);
880
881 BLPAPI_DEPRECATE_STRING_NAME void appendResponse(
882 const char *operationName);
894
895 BLPAPI_DEPRECATE_STRING_NAME void appendRecapMessage(
896 const char *messageType,
897 const Topic& topic,
918
919 BLPAPI_DEPRECATE_STRING_NAME void appendRecapMessage(
920 const char *messageType,
921 const Topic& topic,
922 unsigned int sequenceNumber);
937
938 BLPAPI_DEPRECATE_STRING_NAME void appendRecapMessage(
939 const char *messageType,
940 const Topic& topic,
941 Message::Fragment fragmentType,
942 unsigned int sequenceNumber);
964
965 BLPAPI_DEPRECATE_STRING_NAME void appendRecapMessage(
966 const char *messageType,
967 const CorrelationId& cid,
989
990 BLPAPI_DEPRECATE_STRING_NAME void setElement(const char *name, bool value);
1005
1006 BLPAPI_DEPRECATE_STRING_NAME void setElement(const char *name, char value);
1021
1022 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1023 const char *name, Int32 value);
1038
1039 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1040 const char *name, Int64 value);
1055
1056 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1057 const char *name, Float32 value);
1072
1073 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1074 const char *name, Float64 value);
1089
1090 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1091 const char *name, const Datetime& value);
1107
1108 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1109 const char *name, const Datetime::HighPrecision& value);
1126
1127 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1128 const char *name, const char *value);
1146
1147 BLPAPI_DEPRECATE_STRING_NAME void setElement(
1148 const char *name, const Name& value);
1163
1164 BLPAPI_DEPRECATE_STRING_NAME void setElementNull(const char *name);
1180
1181 BLPAPI_DEPRECATE_STRING_NAME void pushElement(const char *name);
1189
1204
1205 void fromJson(const char *json);
1217
1218 void fromJson(const std::string& json);
1231
1233 const blpapi_EventFormatter_t *handle() const;
1237
1238 blpapi_EventFormatter_t *handle();
1243};
1244
1247
1248// ============================================================================
1249// INLINE AND TEMPLATE FUNCTION IMPLEMENTATIONS
1250// ============================================================================
1251
1252// --------------------
1253// class EventFormatter
1254// --------------------
1255
1256inline EventFormatter::EventFormatter(Event& event)
1257{
1258 d_handle = blpapi_EventFormatter_create(event.impl());
1259}
1260
1262{
1263 blpapi_EventFormatter_destroy(d_handle);
1264}
1265
1267 const char *messageType, const Topic& topic)
1268{
1269 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendMessage(
1270 d_handle, messageType, 0, topic.impl()));
1271}
1272
1274 const Name& messageType, const Topic& topic)
1275{
1276 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendMessage(
1277 d_handle, 0, messageType.impl(), topic.impl()));
1278}
1279
1280inline void EventFormatter::appendMessage(const char *messageType,
1281 const Topic& topic,
1282 unsigned int sequenceNumber)
1283{
1285 d_handle, messageType, 0, topic.impl(), sequenceNumber, 0));
1286}
1287
1288inline void EventFormatter::appendMessage(const Name& messageType,
1289 const Topic& topic,
1290 unsigned int sequenceNumber)
1291{
1293 d_handle, 0, messageType.impl(), topic.impl(), sequenceNumber, 0));
1294}
1295
1296inline void EventFormatter::appendResponse(const char *operationName)
1297{
1299 blpapi_EventFormatter_appendResponse(d_handle, operationName, 0));
1300}
1301
1302inline void EventFormatter::appendResponse(const Name& operationName)
1303{
1304 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendResponse(
1305 d_handle, 0, operationName.impl()));
1306}
1307
1309 const Topic& topic, const CorrelationId *cid)
1310{
1311 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendRecapMessage(
1312 d_handle, topic.impl(), cid ? &cid->impl() : 0));
1313}
1314
1316 const Topic& topic, Message::Fragment fragmentType)
1317{
1319 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
1320 0, // 'typeString'
1321 0, // 'typeName'
1322 topic.impl(), // 'topic'
1323 0, // 'cid'
1324 static_cast<int>(fragmentType)));
1325}
1326
1327inline void EventFormatter::appendRecapMessage(const Name& messageType,
1328 const Topic& topic,
1329 Message::Fragment fragmentType)
1330{
1332 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
1333 0, // 'typeString'
1334 messageType.impl(), // 'typeName'
1335 topic.impl(), // 'topic'
1336 0, // 'cid'
1337 static_cast<int>(fragmentType)));
1338}
1339
1340inline void EventFormatter::appendRecapMessage(const char *messageType,
1341 const Topic& topic,
1342 Message::Fragment fragmentType)
1343{
1345 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
1346 messageType, // 'typeString'
1347 0, // 'typeName'
1348 topic.impl(), // 'topic'
1349 0, // 'cid'
1350 static_cast<int>(fragmentType)));
1351}
1352
1354 unsigned int sequenceNumber,
1355 const CorrelationId *cid)
1356{
1359 topic.impl(),
1360 cid ? &cid->impl() : 0,
1361 sequenceNumber,
1362 0));
1363}
1364
1365inline void EventFormatter::appendRecapMessage(const Name& messageType,
1366 const Topic& topic,
1367 unsigned int sequenceNumber)
1368{
1370 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
1371 0, // 'typeString'
1372 messageType.impl(), // 'typeName'
1373 topic.impl(), // 'topic'
1374 static_cast<int>(Message::FRAGMENT_NONE),
1375 sequenceNumber));
1376}
1377
1378inline void EventFormatter::appendRecapMessage(const char *messageType,
1379 const Topic& topic,
1380 unsigned int sequenceNumber)
1381{
1383 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
1384 messageType, // 'typeString'
1385 0, // 'typeName'
1386 topic.impl(), // 'topic'
1387 static_cast<int>(Message::FRAGMENT_NONE),
1388 sequenceNumber));
1389}
1390
1392 Message::Fragment fragmentType,
1393 unsigned int sequenceNumber)
1394{
1396 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
1397 0, // 'typeString'
1398 0, // 'typeName'
1399 topic.impl(), // 'topic'
1400 static_cast<int>(fragmentType),
1401 sequenceNumber));
1402}
1403
1404inline void EventFormatter::appendRecapMessage(const Name& messageType,
1405 const Topic& topic,
1406 Message::Fragment fragmentType,
1407 unsigned int sequenceNumber)
1408{
1410 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
1411 0, // 'typeString'
1412 messageType.impl(), // 'typeName'
1413 topic.impl(), // 'topic'
1414 static_cast<int>(fragmentType),
1415 sequenceNumber));
1416}
1417
1418inline void EventFormatter::appendRecapMessage(const char *messageType,
1419 const Topic& topic,
1420 Message::Fragment fragmentType,
1421 unsigned int sequenceNumber)
1422{
1424 blpapi_EventFormatter_appendFragmentedRecapMessageSeq)(d_handle,
1425 messageType, // 'typeString'
1426 0, // 'typeName'
1427 topic.impl(), // 'topic'
1428 static_cast<int>(fragmentType),
1429 sequenceNumber));
1430}
1431
1433 const CorrelationId& cid, Message::Fragment fragmentType)
1434{
1436 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
1437 0, // 'typeString'
1438 0, // 'typeName'
1439 0, // 'topic'
1440 &cid.impl(), // 'cid'
1441 static_cast<int>(fragmentType)));
1442}
1443
1444inline void EventFormatter::appendRecapMessage(const Name& messageType,
1445 const CorrelationId& cid,
1446 Message::Fragment fragmentType)
1447{
1449 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
1450 0, // 'typeString'
1451 messageType.impl(), // 'typeName'
1452 0, // 'topic'
1453 &cid.impl(), // 'cid'
1454 static_cast<int>(fragmentType)));
1455}
1456
1457inline void EventFormatter::appendRecapMessage(const char *messageType,
1458 const CorrelationId& cid,
1459 Message::Fragment fragmentType)
1460{
1462 blpapi_EventFormatter_appendFragmentedRecapMessage)(d_handle,
1463 messageType, // 'typeString'
1464 0, // 'typeName'
1465 0, // 'topic'
1466 &cid.impl(), // 'cid'
1467 static_cast<int>(fragmentType)));
1468}
1469
1470inline void EventFormatter::setElement(const char *name, bool value)
1471{
1473 blpapi_EventFormatter_setValueBool(d_handle, name, 0, value));
1474}
1475
1476inline void EventFormatter::setElement(const char *name, char value)
1477{
1479 blpapi_EventFormatter_setValueChar(d_handle, name, 0, value));
1480}
1481
1482inline void EventFormatter::setElement(const char *name, Int32 value)
1483{
1485 blpapi_EventFormatter_setValueInt32(d_handle, name, 0, value));
1486}
1487
1488inline void EventFormatter::setElement(const char *name, Int64 value)
1489{
1491 blpapi_EventFormatter_setValueInt64(d_handle, name, 0, value));
1492}
1493
1494inline void EventFormatter::setElement(const char *name, Float32 value)
1495{
1497 blpapi_EventFormatter_setValueFloat32(d_handle, name, 0, value));
1498}
1499
1500inline void EventFormatter::setElement(const char *name, Float64 value)
1501{
1503 blpapi_EventFormatter_setValueFloat64(d_handle, name, 0, value));
1504}
1505
1506inline void EventFormatter::setElement(const char *name, const Datetime& value)
1507{
1508 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueDatetime(
1509 d_handle, name, 0, &value.rawValue()));
1510}
1511
1513 const char *name, const Datetime::HighPrecision& value)
1514{
1516 BLPAPI_CALL(blpapi_EventFormatter_setValueHighPrecisionDatetime)(
1517 d_handle, name, 0, &value));
1518}
1519
1520inline void EventFormatter::setElement(const char *name, const char *value)
1521{
1523 blpapi_EventFormatter_setValueString(d_handle, name, 0, value));
1524}
1525
1526inline void EventFormatter::setElement(const char *name, const Name& value)
1527{
1528 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueFromName(
1529 d_handle, name, 0, value.impl()));
1530}
1531
1532inline void EventFormatter::setElementNull(const char *name)
1533{
1535 BLPAPI_CALL_EVENTFORMATTER_SETVALUENULL(d_handle, name, 0));
1536}
1537
1538inline void EventFormatter::setElement(const Name& name, bool value)
1539{
1540 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueBool(
1541 d_handle, 0, name.impl(), value));
1542}
1543
1544inline void EventFormatter::setElement(const Name& name, char value)
1545{
1546 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueChar(
1547 d_handle, 0, name.impl(), value));
1548}
1549
1550inline void EventFormatter::setElement(const Name& name, Int32 value)
1551{
1552 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueInt32(
1553 d_handle, 0, name.impl(), value));
1554}
1555
1556inline void EventFormatter::setElement(const Name& name, Int64 value)
1557{
1558 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueInt64(
1559 d_handle, 0, name.impl(), value));
1560}
1561
1562inline void EventFormatter::setElement(const Name& name, Float32 value)
1563{
1564 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueFloat32(
1565 d_handle, 0, name.impl(), value));
1566}
1567inline void EventFormatter::setElement(const Name& name, Float64 value)
1568{
1569 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueFloat64(
1570 d_handle, 0, name.impl(), value));
1571}
1572
1573inline void EventFormatter::setElement(const Name& name, const Datetime& value)
1574{
1575 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueDatetime(
1576 d_handle, 0, name.impl(), &value.rawValue()));
1577}
1578
1580 const Name& name, const Datetime::HighPrecision& value)
1581{
1583 BLPAPI_CALL(blpapi_EventFormatter_setValueHighPrecisionDatetime)(
1584 d_handle, 0, name.impl(), &value));
1585}
1586
1587inline void EventFormatter::setElement(const Name& name, const char *value)
1588{
1589 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueString(
1590 d_handle, 0, name.impl(), value));
1591}
1592
1594 const Name& name, const std::string& value)
1595{
1596 setElement(name, value.c_str());
1597}
1598
1599inline void EventFormatter::setElement(const Name& name, const Name& value)
1600{
1601 ExceptionUtil::throwOnError(blpapi_EventFormatter_setValueFromName(
1602 d_handle, 0, name.impl(), value.impl()));
1603}
1604
1606 const Name& name, const void *value, size_t length)
1607{
1609 BLPAPI_CALL(blpapi_EventFormatter_setValueBytes)(d_handle,
1610 0,
1611 name.impl(),
1612 reinterpret_cast<const char *>(value),
1613 length));
1614}
1615
1616template <typename BYTES,
1617 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type>
1618inline void EventFormatter::setElement(const Name& name, const BYTES& value)
1619{
1620 setElement(name, value.data(), value.size());
1621}
1622
1623inline void EventFormatter::setElementNull(const Name& name)
1624{
1626 BLPAPI_CALL_EVENTFORMATTER_SETVALUENULL(d_handle, 0, name.impl()));
1627}
1628
1629inline void EventFormatter::pushElement(const char *name)
1630{
1632 blpapi_EventFormatter_pushElement(d_handle, name, 0));
1633}
1634
1635inline void EventFormatter::pushElement(const Name& name)
1636{
1638 blpapi_EventFormatter_pushElement(d_handle, 0, name.impl()));
1639}
1640
1642{
1643 ExceptionUtil::throwOnError(blpapi_EventFormatter_popElement(d_handle));
1644}
1645
1646inline void EventFormatter::appendValue(bool value)
1647{
1649 blpapi_EventFormatter_appendValueBool(d_handle, value));
1650}
1651
1652inline void EventFormatter::appendValue(char value)
1653{
1655 blpapi_EventFormatter_appendValueChar(d_handle, value));
1656}
1657
1659{
1661 blpapi_EventFormatter_appendValueInt32(d_handle, value));
1662}
1663
1665{
1667 blpapi_EventFormatter_appendValueInt64(d_handle, value));
1668}
1669
1671{
1673 blpapi_EventFormatter_appendValueFloat32(d_handle, value));
1674}
1675
1677{
1679 blpapi_EventFormatter_appendValueFloat64(d_handle, value));
1680}
1681
1682inline void EventFormatter::appendValue(const Datetime& value)
1683{
1684 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendValueDatetime(
1685 d_handle, &value.rawValue()));
1686}
1687
1689{
1691 blpapi_EventFormatter_appendValueHighPrecisionDatetime)(
1692 d_handle, &value));
1693}
1694
1695inline void EventFormatter::appendValue(const char *value)
1696{
1698 blpapi_EventFormatter_appendValueString(d_handle, value));
1699}
1700
1701inline void EventFormatter::appendValue(const std::string& value)
1702{
1703 appendValue(value.c_str());
1704}
1705
1706inline void EventFormatter::appendValue(const Name& value)
1707{
1709 blpapi_EventFormatter_appendValueFromName(d_handle, value.impl()));
1710}
1711
1713{
1714 ExceptionUtil::throwOnError(blpapi_EventFormatter_appendElement(d_handle));
1715}
1716
1718{
1719 blpapi_Element_t *element = nullptr;
1721 blpapi_EventFormatter_getElement(d_handle, &element));
1722 if (element == nullptr) {
1723 throw blpapi::InvalidStateException("Not a valid element");
1724 }
1725 return blpapi::Element(element);
1726}
1727
1728inline void EventFormatter::fromJson(const char *json)
1729{
1730 getElement().fromJson(json);
1731}
1732
1733inline void EventFormatter::fromJson(const std::string& json)
1734{
1735 fromJson(json.c_str());
1736}
1737
1738inline const blpapi_EventFormatter_t *EventFormatter::handle() const
1739{
1740 return d_handle;
1741}
1742
1743inline blpapi_EventFormatter_t *EventFormatter::handle() { return d_handle; }
1744
1745} // close namespace blpapi
1746} // close namespace BloombergLP
1747
1748#endif // #ifdef __cplusplus
1749#endif // #ifndef INCLUDED_BLPAPI_EVENTFORMATTER
Provide functions for dispatchtbl.
#define BLPAPI_CALL_EVENTFORMATTER_APPENDRECAPMESSAGESEQ(a1, a2, a3, a4, a5)
Definition blpapi_call.h:366
#define BLPAPI_CALL_EVENTFORMATTER_APPENDMESSAGESEQ(a1, a2, a3, a4, a5, a6)
Definition blpapi_call.h:364
#define BLPAPI_CALL_EVENTFORMATTER_SETVALUENULL(a1, a2, a3)
Definition blpapi_call.h:417
#define BLPAPI_CALL(FUNCNAME)
Definition blpapi_call.h:361
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:225
Definition blpapi_datetime.h:273
blpapi_HighPrecisionDatetime_t HighPrecision
Definition blpapi_datetime.h:299
blpapi_Datetime_t & rawValue()
Definition blpapi_datetime.h:1980
Definition blpapi_element.h:1167
void fromJson(const char *json)
Definition blpapi_element.h:3078
blpapi::Element getElement()
Definition blpapi_eventformatter.h:1717
void appendValue(bool value)
Definition blpapi_eventformatter.h:1646
void appendMessage(const Name &messageType, const Topic &topic)
Definition blpapi_eventformatter.h:1273
void setElementNull(const Name &name)
Definition blpapi_eventformatter.h:1623
void setElement(const Name &name, bool value)
Definition blpapi_eventformatter.h:1538
void appendRecapMessage(const Topic &topic, const CorrelationId *cid=0)
Definition blpapi_eventformatter.h:1308
void appendResponse(const Name &operationName)
Definition blpapi_eventformatter.h:1302
~EventFormatter()
Definition blpapi_eventformatter.h:1261
void appendElement()
Definition blpapi_eventformatter.h:1712
void fromJson(const char *json)
Definition blpapi_eventformatter.h:1728
void popElement()
Definition blpapi_eventformatter.h:1641
void pushElement(const Name &name)
Definition blpapi_eventformatter.h:1635
Definition blpapi_event.h:212
blpapi_Event_t * impl() const
Definition blpapi_event.h:569
static void throwOnError(int errorCode)
Definition blpapi_exception.h:541
Definition blpapi_exception.h:237
Fragment
Definition blpapi_message.h:187
@ FRAGMENT_NONE
message is not fragmented
Definition blpapi_message.h:189
Definition blpapi_name.h:242
blpapi_Name_t * impl() const
Definition blpapi_name.h:495
Definition blpapi_topic.h:130
const blpapi_Topic_t * impl() const
Definition blpapi_topic.h:237
Definition blpapi_abstractsession.h:212
blpapi_Float64_t Float64
Definition blpapi_types.h:485
blpapi_Float32_t Float32
Definition blpapi_types.h:484
blpapi_Int64_t Int64
Definition blpapi_types.h:482
blpapi_Int32_t Int32
Definition blpapi_types.h:480
Definition blpapi_abstractsession.h:211