BLPAPI C++  3.24.11
blpapi_versioninfo.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_VERSIONINFO
29 #define INCLUDED_BLPAPI_VERSIONINFO
30 
130 #ifndef INCLUDED_BLPAPI_CALL
131 #include <blpapi_call.h>
132 #endif
133 
134 #ifndef INCLUDED_BLPAPI_DEFS
135 #include <blpapi_defs.h>
136 #endif
137 
138 #ifndef INCLUDED_BLPAPI_VERSIONMACROS
139 #include <blpapi_versionmacros.h>
140 #endif
141 
142 #ifdef __cplusplus
143 extern "C" {
144 #endif // ifdef __cplusplus
145 
147 void blpapi_getVersionInfo(int *majorVersion,
148  int *minorVersion,
149  int *patchVersion,
150  int *buildVersion);
158 const char *blpapi_getVersionIdentifier(void);
167 #ifdef __cplusplus
168 }
169 
170 #include <ostream>
171 #include <sstream>
172 #include <string>
173 
181 namespace BloombergLP {
182 namespace blpapi {
183 
194 class VersionInfo {
195 
196  private:
198  int d_major;
200  int d_minor;
202  int d_patch;
204  int d_build;
205 
206  VersionInfo(int major, int minor, int patch, int build);
213  public:
214  // CREATORS
215  static VersionInfo headerVersion();
224  static VersionInfo runtimeVersion();
232  VersionInfo();
238  // ACCESSORS
239  int majorVersion() const;
243  int minorVersion() const;
247  int patchVersion() const;
251  int buildVersion() const;
256  static std::string versionIdentifier();
263 };
264 
268 std::ostream& operator<<(std::ostream& stream, const VersionInfo& rhs);
275 //=============================================================================
276 // INLINE FUNCTION DEFINITIONS
277 //=============================================================================
278 
279 // -----------------
280 // class VersionInfo
281 // -----------------
282 // CREATORS
283 inline VersionInfo::VersionInfo(int major, int minor, int patch, int build)
284  : d_major(major)
285  , d_minor(minor)
286  , d_patch(patch)
287  , d_build(build)
288 {
289 }
290 
292 {
297 }
298 
300 {
301  int major, minor, patch, build;
302  blpapi_getVersionInfo(&major, &minor, &patch, &build);
303  return VersionInfo(major, minor, patch, build);
304 }
305 
307 {
308  blpapi_getVersionInfo(&d_major, &d_minor, &d_patch, &d_build);
309 }
310 
311 // ACCESSORS
312 inline int VersionInfo::majorVersion() const { return d_major; }
313 
314 inline int VersionInfo::minorVersion() const { return d_minor; }
315 
316 inline int VersionInfo::patchVersion() const { return d_patch; }
317 
318 inline int VersionInfo::buildVersion() const { return d_build; }
319 
320 inline std::string VersionInfo::versionIdentifier()
321 {
322  std::ostringstream oss;
323  oss << "blpapi-cpp; headers " << headerVersion() << "; runtime "
324  << runtimeVersion();
325  return oss.str();
326 }
327 
328 inline std::ostream& operator<<(std::ostream& stream, const VersionInfo& rhs)
329 {
330  return stream << rhs.majorVersion() << '.' << rhs.minorVersion() << '.'
331  << rhs.patchVersion() << '.' << rhs.buildVersion();
332 }
333 
334 } // close namespace blpapi
335 } // close namespace BloombergLP
336 
337 #endif // ifdef __cplusplus
338 
339 #endif // INCLUDED_BLPAPI_VERSIONINFO
int minorVersion() const
Definition: blpapi_versioninfo.h:314
Definition: blpapi_versioninfo.h:194
Common definitions used by the library.
Definition: blpapi_abstractsession.h:187
#define BLPAPI_VERSION_MAJOR
Definition: blpapi_versionmacros.h:49
VersionInfo()
Definition: blpapi_versioninfo.h:306
static std::string versionIdentifier()
Definition: blpapi_versioninfo.h:320
#define BLPAPI_VERSION_MINOR
Definition: blpapi_versionmacros.h:50
static VersionInfo headerVersion()
Definition: blpapi_versioninfo.h:291
const char * blpapi_getVersionIdentifier(void)
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition: blpapi_correlationid.h:592
int patchVersion() const
Definition: blpapi_versioninfo.h:316
Provide preprocessor macros for BLPAPI library version information.
void blpapi_getVersionInfo(int *majorVersion, int *minorVersion, int *patchVersion, int *buildVersion)
static VersionInfo runtimeVersion()
Definition: blpapi_versioninfo.h:299
#define BLPAPI_VERSION_BUILD
Definition: blpapi_versionmacros.h:52
int majorVersion() const
Definition: blpapi_versioninfo.h:312
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
Provide functions for dispatchtbl.
#define BLPAPI_VERSION_PATCH
Definition: blpapi_versionmacros.h:51
int buildVersion() const
Definition: blpapi_versioninfo.h:318