BLPAPI C++ 3.25.8
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
226#ifdef __cplusplus
227} // extern "C"
228
229#include <string>
230#include <type_traits>
231
239namespace BloombergLP {
240namespace blpapi {
241namespace test {
242
259
260 private:
262
263 public:
264 // CREATORS
271 MessageFormatter(const MessageFormatter& original);
283 // MANIPULATORS
289 void setElement(const Name& name, bool value);
298 void setElement(const Name& name, char value);
307 void setElement(const Name& name, Int32 value);
316 void setElement(const Name& name, Int64 value);
325 void setElement(const Name& name, Float32 value);
334 void setElement(const Name& name, Float64 value);
343 void setElement(const Name& name, const Datetime& value);
352 void setElement(const Name& name, const Datetime::HighPrecision& value);
361 void setElement(const Name& name, const char *value);
373 void setElement(const Name& name, const std::string& value);
383 void setElement(const Name& name, const Name& value);
392 void setElement(const Name& name, const void *value, size_t length);
405 template <typename BYTES,
406 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type
407 = true>
408 void setElement(const Name& name, const BYTES& value);
423 void setElementNull(const Name& name);
433 void pushElement(const Name& name);
455 void popElement();
465 void appendValue(bool value);
473 void appendValue(char value);
481 void appendValue(Int32 value);
489 void appendValue(Int64 value);
497 void appendValue(Float32 value);
505 void appendValue(Float64 value);
513 void appendValue(const Datetime& value);
521 void appendValue(const Datetime::HighPrecision& value);
529 void appendValue(const char *value);
537 void appendValue(const std::string& value);
547 void appendValue(const Name& value);
555 void appendElement();
563 void formatMessageJson(const char *message);
571 void formatMessageXml(const char *message);
579 // ACCESSORS
585};
586
590// ============================================================================
591// INLINE AND TEMPLATE FUNCTION IMPLEMENTATIONS
592// ============================================================================
593
594// ----------------------
595// class MessageFormatter
596// ----------------------
597
599 : d_handle(handle)
600{
601}
602
604{
605 if (d_handle) {
607 }
608}
609
615
617 const MessageFormatter& rhs)
618{
620 &d_handle, rhs.impl()));
621 return *this;
622}
623
624inline void MessageFormatter::setElement(const Name& name, bool value)
625{
628 d_handle, name.impl(), value));
629}
630
631inline void MessageFormatter::setElement(const Name& name, char value)
632{
635 d_handle, name.impl(), value));
636}
637
638inline void MessageFormatter::setElement(const Name& name, Int32 value)
639{
642 d_handle, name.impl(), value));
643}
644
645inline void MessageFormatter::setElement(const Name& name, Int64 value)
646{
649 d_handle, name.impl(), value));
650}
651
652inline void MessageFormatter::setElement(const Name& name, Float32 value)
653{
656 d_handle, name.impl(), value));
657}
658
659inline void MessageFormatter::setElement(const Name& name, Float64 value)
660{
663 d_handle, name.impl(), value));
664}
665
667 const Name& name, const Datetime& value)
668{
671 d_handle, name.impl(), &value.rawValue()));
672}
673
675 const Name& name, const Datetime::HighPrecision& value)
676{
679 d_handle, name.impl(), &value));
680}
681
682inline void MessageFormatter::setElement(const Name& name, const char *value)
683{
686 d_handle, name.impl(), value));
687}
688
690 const Name& name, const std::string& value)
691{
692 setElement(name, value.c_str());
693}
694
695inline void MessageFormatter::setElement(const Name& name, const Name& value)
696{
699 d_handle, name.impl(), value.impl()));
700}
701
703 const Name& name, const void *value, size_t length)
704{
707 name.impl(),
708 reinterpret_cast<const char *>(value),
709 length));
710}
711
712template <typename BYTES,
713 typename std::enable_if<IsByteSequence<BYTES>::value, bool>::type>
714inline void MessageFormatter::setElement(const Name& name, const BYTES& value)
715{
716 setElement(name, value.data(), value.size());
717}
718
724
730
736
742
748
754
760
766
772
779
786
792
793inline void MessageFormatter::appendValue(const std::string& value)
794{
795 appendValue(value.c_str());
796}
797
804
810
812{
813 return d_handle;
814}
815
821
822inline void MessageFormatter::formatMessageXml(const char *message)
823{
825 blpapi_MessageFormatter_FormatMessageXml)(d_handle, message));
826}
827
828} // close namespace test
829
830// *Deprecated*
831// Following typedef is provided for backwards compatibility. It will be
832// removed in a future release.
834
835} // close namespace blpapi
836} // close namespace BloombergLP
837
838#endif // #ifdef __cplusplus
839#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:171
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_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:258
void formatMessageXml(const char *message)
Definition blpapi_messageformatter.h:822
void appendValue(bool value)
Definition blpapi_messageformatter.h:737
void setElementNull(const Name &name)
Definition blpapi_messageformatter.h:719
void setElement(const Name &name, bool value)
Definition blpapi_messageformatter.h:624
void formatMessageJson(const char *message)
Definition blpapi_messageformatter.h:816
MessageFormatter(blpapi_MessageFormatter_t *handle)
Definition blpapi_messageformatter.h:598
blpapi_MessageFormatter_t * impl() const
Definition blpapi_messageformatter.h:811
void appendElement()
Definition blpapi_messageformatter.h:805
void popElement()
Definition blpapi_messageformatter.h:731
~MessageFormatter()
Definition blpapi_messageformatter.h:603
void pushElement(const Name &name)
Definition blpapi_messageformatter.h:725
MessageFormatter & operator=(const MessageFormatter &rhs)
Definition blpapi_messageformatter.h:616
test::MessageFormatter MessageFormatter
Definition blpapi_messageformatter.h:833
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
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