BLPAPI C++  3.21.0
blpapi_streamproxy.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_STREAMPROXY
29 #define INCLUDED_BLPAPI_STREAMPROXY
30 
53 typedef int (*blpapi_StreamWriter_t)(
54  const char *data, int length, void *stream);
55 
56 #ifdef __cplusplus
57 
58 #include <cassert>
59 #include <ostream>
60 
68 namespace BloombergLP {
69 namespace blpapi {
70 
71 inline int OstreamWriter(const char *data, int length, void *stream);
77 
78  static int writeToStream(const char *data, int length, void *stream);
84 };
85 
89 //=============================================================================
90 // INLINE FUNCTION DEFINITIONS
91 //=============================================================================
92 
94  const char *data, int length, void *stream)
95 {
96  assert(stream);
97 
98  reinterpret_cast<std::ostream *>(stream)->write(data, length);
99  return 0;
100 }
101 
102 inline int OstreamWriter(const char *data, int length, void *stream)
103 {
104  return StreamProxyOstream::writeToStream(data, length, stream);
105 }
106 
107 } // close namespace blpapi
108 } // close namespace BloombergLP
109 
110 #endif // #ifdef __cplusplus
111 #endif // #ifndef INCLUDED_BLPAPI_STREAMPROXY
Definition: blpapi_abstractsession.h:215
int(* blpapi_StreamWriter_t)(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:53
Definition: blpapi_streamproxy.h:76
int OstreamWriter(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:102
static int writeToStream(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:93