BLPAPI C++ 3.25.12
Loading...
Searching...
No Matches
blpapi_messageformatter.h
Go to the documentation of this file.
1/* Copyright 2019. 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_MESSAGEFORMATTER
29#define INCLUDED_BLPAPI_MESSAGEFORMATTER
30
72#include <blpapi_call.h>
73#include <blpapi_defs.h>
74#include <blpapi_event.h>
75#include <blpapi_topic.h>
76#include <blpapi_types.h>
77
78#include <stddef.h>
79
80#ifdef __cplusplus
81extern "C" {
82#endif
83
86 const blpapi_Name_t *typeName,
87 blpapi_Bool_t value);
88
91 const blpapi_Name_t *typeName,
92 char value);
93
96 const blpapi_Name_t *typeName,
97 blpapi_Int32_t value);
98
101 const blpapi_Name_t *typeName,
102 blpapi_Int64_t value);
103
106 blpapi_MessageFormatter_t *formatter,
107 const blpapi_Name_t *typeName,
108 blpapi_Float32_t value);
109
112 blpapi_MessageFormatter_t *formatter,
113 const blpapi_Name_t *typeName,
114 blpapi_Float64_t value);
115
118 blpapi_MessageFormatter_t *formatter,
119 const blpapi_Name_t *typeName,
120 const blpapi_Datetime_t *value);
121
124 blpapi_MessageFormatter_t *formatter,
125 const blpapi_Name_t *typeName,
126 const blpapi_HighPrecisionDatetime_t *value);
127
130 blpapi_MessageFormatter_t *formatter,
131 const blpapi_Name_t *typeName,
132 const char *value);
133
136 blpapi_MessageFormatter_t *formatter,
137 const blpapi_Name_t *typeName,
138 const blpapi_Name_t *value);
139
142 const blpapi_Name_t *typeName,
143 const char *value,
144 size_t length);
145
148 blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName);
149
152 blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName);
153
156
159 blpapi_MessageFormatter_t *formatter, blpapi_Bool_t value);
160
163 blpapi_MessageFormatter_t *formatter, char value);
164
167 blpapi_MessageFormatter_t *formatter, blpapi_Int32_t value);
168
171 blpapi_MessageFormatter_t *formatter, blpapi_Int64_t value);
172
176
180
183 blpapi_MessageFormatter_t *formatter, const blpapi_Datetime_t *value);
184
187 blpapi_MessageFormatter_t *formatter,
188 const blpapi_HighPrecisionDatetime_t *value);
189
192 blpapi_MessageFormatter_t *formatter, const char *value);
193
196 blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *value);
197
200 blpapi_MessageFormatter_t *formatter);
201
204 blpapi_MessageFormatter_t *formatter, const char *message);
205
208 blpapi_MessageFormatter_t *formatter, const char *message);
209
212 const blpapi_MessageFormatter_t *original);
213
217
220
223 blpapi_MessageFormatter_t *formatter,
225
228 blpapi_MessageFormatter_t *formatter, blpapi_Element_t **element);
229
230#ifdef __cplusplus
231} // extern "C"
232
233#include <string>
234#include <type_traits>
235
243namespace BloombergLP {
244namespace blpapi {
245namespace test {
246
263
264 private:
266
267 public:
268 // CREATORS
275 MessageFormatter(const MessageFormatter& original);
287 // MANIPULATORS
293 void setElement(const Name& name, bool value);
302 void setElement(const Name& name, char value);
311 void setElement(const Name& name, Int32 value);
320 void setElement(const Name& name, Int64 value);
329 void setElement(const Name& name, Float32 value);
338 void setElement(const Name& name, Float64 value);
347 void setElement(const Name& name, const Datetime& value);
356 void setElement(const Name& name, const Datetime::HighPrecision& value);
365 void setElement(const Name& name, const char *value);
377 void setElement(const Name& name, const std::string& value);
387 void setElement(const Name& name, const Name& value);
396 void setElement(const Name& name, const void *value, size_t length);
409 template <typename BYTES,
410 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type
411 = true>
412 void setElement(const Name& name, const BYTES& value);
427 void setElementNull(const Name& name);
437 void pushElement(const Name& name);
459 void popElement();
469 void appendValue(bool value);
477 void appendValue(char value);
485 void appendValue(Int32 value);
493 void appendValue(Int64 value);
501 void appendValue(Float32 value);
509 void appendValue(Float64 value);
517 void appendValue(const Datetime& value);
525 void appendValue(const Datetime::HighPrecision& value);
533 void appendValue(const char *value);
541 void appendValue(const std::string& value);
551 void appendValue(const Name& value);
559 void appendElement();
567 void formatMessageJson(const char *message);
575 void formatMessageXml(const char *message);
583 // ACCESSORS
589};
590
594// ============================================================================
595// INLINE AND TEMPLATE FUNCTION IMPLEMENTATIONS
596// ============================================================================
597
598// ----------------------
599// class MessageFormatter
600// ----------------------
601
603 : d_handle(handle)
604{
605}
606
608{
609 if (d_handle) {
611 }
612}
613
619
621 const MessageFormatter& rhs)
622{
624 &d_handle, rhs.impl()));
625 return *this;
626}
627
628inline void MessageFormatter::setElement(const Name& name, bool value)
629{
632 d_handle, name.impl(), value));
633}
634
635inline void MessageFormatter::setElement(const Name& name, char value)
636{
639 d_handle, name.impl(), value));
640}
641
642inline void MessageFormatter::setElement(const Name& name, Int32 value)
643{
646 d_handle, name.impl(), value));
647}
648
649inline void MessageFormatter::setElement(const Name& name, Int64 value)
650{
653 d_handle, name.impl(), value));
654}
655
656inline void MessageFormatter::setElement(const Name& name, Float32 value)
657{
660 d_handle, name.impl(), value));
661}
662
663inline void MessageFormatter::setElement(const Name& name, Float64 value)
664{
667 d_handle, name.impl(), value));
668}
669
671 const Name& name, const Datetime& value)
672{
675 d_handle, name.impl(), &value.rawValue()));
676}
677
679 const Name& name, const Datetime::HighPrecision& value)
680{
683 d_handle, name.impl(), &value));
684}
685
686inline void MessageFormatter::setElement(const Name& name, const char *value)
687{
690 d_handle, name.impl(), value));
691}
692
694 const Name& name, const std::string& value)
695{
696 setElement(name, value.c_str());
697}
698
699inline void MessageFormatter::setElement(const Name& name, const Name& value)
700{
703 d_handle, name.impl(), value.impl()));
704}
705
707 const Name& name, const void *value, size_t length)
708{
711 name.impl(),
712 reinterpret_cast<const char *>(value),
713 length));
714}
715
716template <typename BYTES,
717 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type>
718inline void MessageFormatter::setElement(const Name& name, const BYTES& value)
719{
720 setElement(name, value.data(), value.size());
721}
722
728
734
740
746
752
758
764
770
776
783
790
796
797inline void MessageFormatter::appendValue(const std::string& value)
798{
799 appendValue(value.c_str());
800}
801
808
814
816{
817 return d_handle;
818}
819
825
826inline void MessageFormatter::formatMessageXml(const char *message)
827{
829 blpapi_MessageFormatter_FormatMessageXml)(d_handle, message));
830}
831
832} // close namespace test
833
834// *Deprecated*
835// Following typedef is provided for backwards compatibility. It will be
836// removed in a future release.
838
839} // close namespace blpapi
840} // close namespace BloombergLP
841
842#endif // #ifdef __cplusplus
843#endif // #ifndef INCLUDED_BLPAPI_MESSAGEFORMATTER
Provide functions for dispatchtbl.
#define BLPAPI_CALL_UNCHECKED(FUNCNAME)
Definition blpapi_call.h:354
#define BLPAPI_CALL(FUNCNAME)
Definition blpapi_call.h:353
Common definitions used by the library.
#define BLPAPI_EXPORT
Definition blpapi_defs.h:172
A component which defines events related operations.
BLPAPI_EXPORT int blpapi_MessageFormatter_assign(blpapi_MessageFormatter_t **lhs, const blpapi_MessageFormatter_t *rhs)
BLPAPI_EXPORT int blpapi_MessageFormatter_FormatMessageXml(blpapi_MessageFormatter_t *formatter, const char *message)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueBytes(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, const char *value, size_t length)
BLPAPI_EXPORT int blpapi_MessageFormatter_destroy(blpapi_MessageFormatter_t *formatter)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendElement(blpapi_MessageFormatter_t *formatter)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueFloat64(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, blpapi_Float64_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueFloat32(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, blpapi_Float32_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_getElementDefinition(blpapi_MessageFormatter_t *formatter, blpapi_SchemaElementDefinition_t **definition)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueInt32(blpapi_MessageFormatter_t *formatter, blpapi_Int32_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueHighPrecisionDatetime(blpapi_MessageFormatter_t *formatter, const blpapi_HighPrecisionDatetime_t *value)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueFloat64(blpapi_MessageFormatter_t *formatter, blpapi_Float64_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueString(blpapi_MessageFormatter_t *formatter, const char *value)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueNull(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName)
BLPAPI_EXPORT int blpapi_MessageFormatter_copy(blpapi_MessageFormatter_t **formatter, const blpapi_MessageFormatter_t *original)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueString(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, const char *value)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueFromName(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, const blpapi_Name_t *value)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueFloat32(blpapi_MessageFormatter_t *formatter, blpapi_Float32_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueHighPrecisionDatetime(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, const blpapi_HighPrecisionDatetime_t *value)
BLPAPI_EXPORT int blpapi_MessageFormatter_FormatMessageJson(blpapi_MessageFormatter_t *formatter, const char *message)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueInt64(blpapi_MessageFormatter_t *formatter, blpapi_Int64_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueFromName(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *value)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueBool(blpapi_MessageFormatter_t *formatter, blpapi_Bool_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueDatetime(blpapi_MessageFormatter_t *formatter, const blpapi_Datetime_t *value)
BLPAPI_EXPORT int blpapi_MessageFormatter_getElement(blpapi_MessageFormatter_t *formatter, blpapi_Element_t **element)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueInt64(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, blpapi_Int64_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_pushElement(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueBool(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, blpapi_Bool_t value)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueChar(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, char value)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueDatetime(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, const blpapi_Datetime_t *value)
BLPAPI_EXPORT int blpapi_MessageFormatter_popElement(blpapi_MessageFormatter_t *formatter)
BLPAPI_EXPORT int blpapi_MessageFormatter_appendValueChar(blpapi_MessageFormatter_t *formatter, char value)
BLPAPI_EXPORT int blpapi_MessageFormatter_setValueInt32(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName, blpapi_Int32_t value)
Provide representation of a Topic.
Provide BLPAPI types.
int blpapi_Bool_t
Definition blpapi_types.h:62
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_datetime.h:245
blpapi_Datetime_t & rawValue()
Definition blpapi_datetime.h:1952
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_messageformatter.h:262
void formatMessageXml(const char *message)
Definition blpapi_messageformatter.h:826
void appendValue(bool value)
Definition blpapi_messageformatter.h:741
void setElementNull(const Name &name)
Definition blpapi_messageformatter.h:723
void setElement(const Name &name, bool value)
Definition blpapi_messageformatter.h:628
void formatMessageJson(const char *message)
Definition blpapi_messageformatter.h:820
MessageFormatter(blpapi_MessageFormatter_t *handle)
Definition blpapi_messageformatter.h:602
blpapi_MessageFormatter_t * impl() const
Definition blpapi_messageformatter.h:815
void appendElement()
Definition blpapi_messageformatter.h:809
void popElement()
Definition blpapi_messageformatter.h:735
~MessageFormatter()
Definition blpapi_messageformatter.h:607
void pushElement(const Name &name)
Definition blpapi_messageformatter.h:729
MessageFormatter & operator=(const MessageFormatter &rhs)
Definition blpapi_messageformatter.h:620
test::MessageFormatter MessageFormatter
Definition blpapi_messageformatter.h:837
struct blpapi_MessageFormatter blpapi_MessageFormatter_t
Definition blpapi_types.h:197
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
blpapi_Int32_t Int32
Definition blpapi_types.h:469
Definition blpapi_abstractsession.h:195
Definition blpapi_datetime.h:102
Definition blpapi_datetime.h:115