BLPAPI C++ 3.25.7
Loading...
Searching...
No Matches
blpapi_name.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_NAME
29#define INCLUDED_BLPAPI_NAME
30
60#include <blpapi_defs.h>
61#include <blpapi_types.h>
62
63#include <stddef.h>
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
70blpapi_Name_t *blpapi_Name_create(const char *nameString);
71
74
77
79int blpapi_Name_equalsStr(const blpapi_Name_t *name, const char *string);
80
82const char *blpapi_Name_string(const blpapi_Name_t *name);
83
86
88blpapi_Name_t *blpapi_Name_findName(const char *nameString);
89
90#ifdef __cplusplus
91}
92
93#include <cstring> // for strcmp
94#include <iostream>
95#include <utility> // for swap
96
104namespace BloombergLP {
105namespace blpapi {
106
150class Name {
151
152 blpapi_Name_t *d_impl_p;
153
154 public:
155 // CLASS METHODS
156
157 static Name findName(const char *nameString);
167 static bool hasName(const char *nameString);
175 Name();
182 explicit Name(blpapi_Name_t *handle);
183
184 Name(const Name& original);
190 explicit Name(const char *nameString);
202 ~Name();
207 // MANIPULATORS
208
209 Name& operator=(const Name& rhs);
215 // ACCESSORS
216
217 const char *string() const;
224 size_t length() const;
232 size_t hash() const;
240 blpapi_Name_t *impl() const;
241};
242
246// FREE OPERATORS
247bool operator==(const Name& lhs, const Name& rhs);
255bool operator!=(const Name& lhs, const Name& rhs);
264bool operator==(const Name& lhs, const char *rhs);
273bool operator!=(const Name& lhs, const char *rhs);
282bool operator==(const char *lhs, const Name& rhs);
291bool operator!=(const char *lhs, const Name& rhs);
300bool operator<(const Name& lhs, const Name& rhs);
311bool operator<=(const Name& lhs, const Name& rhs);
322bool operator>(const Name& lhs, const Name& rhs);
333bool operator>=(const Name& lhs, const Name& rhs);
344std::ostream& operator<<(std::ostream& stream, const Name& name);
352//=============================================================================
353// INLINE FUNCTION DEFINITIONS
354//=============================================================================
355
356// ----------
357// class Name
358// ----------
359
361 : d_impl_p(handle)
362{
363}
364
366 : d_impl_p(0)
367{
368}
369
370inline Name::Name(const Name& original)
371 : d_impl_p(blpapi_Name_duplicate(original.d_impl_p))
372{
373}
374
375inline Name::Name(const char *nameString)
376{
377 d_impl_p = blpapi_Name_create(nameString);
378}
379
381{
382 if (d_impl_p) {
383 blpapi_Name_destroy(d_impl_p);
384 }
385}
386
387inline Name& Name::operator=(const Name& rhs)
388{
389 using std::swap;
390
391 Name tmp(rhs);
392 swap(tmp.d_impl_p, d_impl_p);
393 return *this;
394}
395
396inline const char *Name::string() const
397{
398 return blpapi_Name_string(d_impl_p);
399}
400
401inline size_t Name::length() const { return blpapi_Name_length(d_impl_p); }
402
403inline blpapi_Name_t *Name::impl() const { return d_impl_p; }
404
405inline Name Name::findName(const char *nameString)
406{
407 return Name(blpapi_Name_findName(nameString));
408}
409
410inline bool Name::hasName(const char *nameString)
411{
412 return blpapi_Name_findName(nameString) ? true : false;
413}
414
415inline size_t Name::hash() const { return reinterpret_cast<size_t>(impl()); }
416
417} // close namespace blpapi
418
419inline bool blpapi::operator==(const Name& lhs, const Name& rhs)
420{
421 return (lhs.impl() == rhs.impl());
422}
423
424inline bool blpapi::operator!=(const Name& lhs, const Name& rhs)
425{
426 return !(lhs == rhs);
427}
428
429inline bool blpapi::operator==(const Name& lhs, const char *rhs)
430{
431 return blpapi_Name_equalsStr(lhs.impl(), rhs) != 0;
432}
433
434inline bool blpapi::operator!=(const Name& lhs, const char *rhs)
435{
436 return !(lhs == rhs);
437}
438
439inline bool blpapi::operator==(const char *lhs, const Name& rhs)
440{
441 return rhs == lhs;
442}
443
444inline bool blpapi::operator!=(const char *lhs, const Name& rhs)
445{
446 return !(rhs == lhs);
447}
448
449inline bool blpapi::operator<(const Name& lhs, const Name& rhs)
450{
451 return lhs.impl() < rhs.impl();
452}
453
454inline bool blpapi::operator<=(const Name& lhs, const Name& rhs)
455{
456 return !(rhs < lhs);
457}
458
459inline bool blpapi::operator>(const Name& lhs, const Name& rhs)
460{
461 return rhs < lhs;
462}
463
464inline bool blpapi::operator>=(const Name& lhs, const Name& rhs)
465{
466 return !(lhs < rhs);
467}
468
469inline std::ostream& blpapi::operator<<(std::ostream& stream, const Name& name)
470{
471 return stream << name.string();
472}
473
474} // close namespace BloombergLP
475
476#endif // __cplusplus
477
478#endif // #ifndef INCLUDED_BLPAPI_NAME
Common definitions used by the library.
#define BLPAPI_EXPORT
Definition blpapi_defs.h:171
BLPAPI_EXPORT blpapi_Name_t * blpapi_Name_duplicate(const blpapi_Name_t *src)
BLPAPI_EXPORT const char * blpapi_Name_string(const blpapi_Name_t *name)
BLPAPI_EXPORT int blpapi_Name_equalsStr(const blpapi_Name_t *name, const char *string)
BLPAPI_EXPORT blpapi_Name_t * blpapi_Name_create(const char *nameString)
BLPAPI_EXPORT size_t blpapi_Name_length(const blpapi_Name_t *name)
BLPAPI_EXPORT void blpapi_Name_destroy(blpapi_Name_t *name)
BLPAPI_EXPORT blpapi_Name_t * blpapi_Name_findName(const char *nameString)
Provide BLPAPI types.
Definition blpapi_name.h:150
static bool hasName(const char *nameString)
Definition blpapi_name.h:410
Name & operator=(const Name &rhs)
Definition blpapi_name.h:387
size_t length() const
Definition blpapi_name.h:401
blpapi_Name_t * impl() const
Definition blpapi_name.h:403
static Name findName(const char *nameString)
Definition blpapi_name.h:405
~Name()
Definition blpapi_name.h:380
const char * string() const
Definition blpapi_name.h:396
Name()
Definition blpapi_name.h:365
size_t hash() const
Definition blpapi_name.h:415
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition blpapi_event.h:723
struct blpapi_Name blpapi_Name_t
Definition blpapi_types.h:154
bool operator==(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:562
bool operator>(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2088
bool operator<=(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2083
bool operator>=(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2093
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition blpapi_correlationid.h:592
bool operator!=(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:582
bool operator<(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:587
Definition blpapi_abstractsession.h:195