BLPAPI C++ 3.26.5
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
35
36#ifndef INCLUDED_BLPAPI_NAME
37#define INCLUDED_BLPAPI_NAME
38
67
68#include <blpapi_defs.h>
69#include <blpapi_types.h>
70
71#include <stddef.h>
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
78
81
83
96BLPAPI_EXPORT
97blpapi_Name_t *blpapi_Name_create(const char *nameString);
98
100
108BLPAPI_EXPORT
109void blpapi_Name_destroy(blpapi_Name_t *name);
110
112
121BLPAPI_EXPORT
122blpapi_Name_t *blpapi_Name_duplicate(const blpapi_Name_t *src);
123
125
135BLPAPI_EXPORT
136int blpapi_Name_equalsStr(const blpapi_Name_t *name, const char *string);
137
139
147BLPAPI_EXPORT
148const char *blpapi_Name_string(const blpapi_Name_t *name);
149
151
161BLPAPI_EXPORT
162size_t blpapi_Name_length(const blpapi_Name_t *name);
163
165
176BLPAPI_EXPORT
177blpapi_Name_t *blpapi_Name_findName(const char *nameString);
178
181
182#ifdef __cplusplus
183}
184
185#include <cstring> // for strcmp
186#include <iostream>
187#include <utility> // for swap
188
195
196namespace BloombergLP {
197namespace blpapi {
198
242class Name {
243
244 blpapi_Name_t *d_impl_p;
245
246 public:
247 // CLASS METHODS
248
249 static Name findName(const char *nameString);
258
259 static bool hasName(const char *nameString);
266
267 Name();
273
274 explicit Name(blpapi_Name_t *handle);
275
276 Name(const Name& original);
281
282 explicit Name(const char *nameString);
293
294 ~Name();
298
299 // MANIPULATORS
300
301 Name& operator=(const Name& rhs);
306
307 // ACCESSORS
308
309 const char *string() const;
315
316 size_t length() const;
323
324 size_t hash() const;
331
332 blpapi_Name_t *impl() const;
333};
334
337
338// FREE OPERATORS
339bool operator==(const Name& lhs, const Name& rhs);
346
347bool operator!=(const Name& lhs, const Name& rhs);
355
356bool operator==(const Name& lhs, const char *rhs);
364
365bool operator!=(const Name& lhs, const char *rhs);
373
374bool operator==(const char *lhs, const Name& rhs);
382
383bool operator!=(const char *lhs, const Name& rhs);
391
392bool operator<(const Name& lhs, const Name& rhs);
402
403bool operator<=(const Name& lhs, const Name& rhs);
413
414bool operator>(const Name& lhs, const Name& rhs);
424
425bool operator>=(const Name& lhs, const Name& rhs);
435
436std::ostream& operator<<(std::ostream& stream, const Name& name);
443
444//=============================================================================
445// INLINE FUNCTION DEFINITIONS
446//=============================================================================
447
448// ----------
449// class Name
450// ----------
451
452inline Name::Name(blpapi_Name_t *handle)
453 : d_impl_p(handle)
454{
455}
456
458 : d_impl_p(0)
459{
460}
461
462inline Name::Name(const Name& original)
463 : d_impl_p(blpapi_Name_duplicate(original.d_impl_p))
464{
465}
466
467inline Name::Name(const char *nameString)
468{
469 d_impl_p = blpapi_Name_create(nameString);
470}
471
473{
474 if (d_impl_p) {
475 blpapi_Name_destroy(d_impl_p);
476 }
477}
478
479inline Name& Name::operator=(const Name& rhs)
480{
481 using std::swap;
482
483 Name tmp(rhs);
484 swap(tmp.d_impl_p, d_impl_p);
485 return *this;
486}
487
488inline const char *Name::string() const
489{
490 return blpapi_Name_string(d_impl_p);
491}
492
493inline size_t Name::length() const { return blpapi_Name_length(d_impl_p); }
494
495inline blpapi_Name_t *Name::impl() const { return d_impl_p; }
496
497inline Name Name::findName(const char *nameString)
498{
499 return Name(blpapi_Name_findName(nameString));
500}
501
502inline bool Name::hasName(const char *nameString)
503{
504 return blpapi_Name_findName(nameString) ? true : false;
505}
506
507inline size_t Name::hash() const { return reinterpret_cast<size_t>(impl()); }
508
509} // close namespace blpapi
510
511inline bool blpapi::operator==(const Name& lhs, const Name& rhs)
512{
513 return (lhs.impl() == rhs.impl());
514}
515
516inline bool blpapi::operator!=(const Name& lhs, const Name& rhs)
517{
518 return !(lhs == rhs);
519}
520
521inline bool blpapi::operator==(const Name& lhs, const char *rhs)
522{
523 return blpapi_Name_equalsStr(lhs.impl(), rhs) != 0;
524}
525
526inline bool blpapi::operator!=(const Name& lhs, const char *rhs)
527{
528 return !(lhs == rhs);
529}
530
531inline bool blpapi::operator==(const char *lhs, const Name& rhs)
532{
533 return rhs == lhs;
534}
535
536inline bool blpapi::operator!=(const char *lhs, const Name& rhs)
537{
538 return !(rhs == lhs);
539}
540
541inline bool blpapi::operator<(const Name& lhs, const Name& rhs)
542{
543 return lhs.impl() < rhs.impl();
544}
545
546inline bool blpapi::operator<=(const Name& lhs, const Name& rhs)
547{
548 return !(rhs < lhs);
549}
550
551inline bool blpapi::operator>(const Name& lhs, const Name& rhs)
552{
553 return rhs < lhs;
554}
555
556inline bool blpapi::operator>=(const Name& lhs, const Name& rhs)
557{
558 return !(lhs < rhs);
559}
560
561inline std::ostream& blpapi::operator<<(std::ostream& stream, const Name& name)
562{
563 return stream << name.string();
564}
565
566} // close namespace BloombergLP
567
568#endif // __cplusplus
569
570#endif // #ifndef INCLUDED_BLPAPI_NAME
Common definitions used by the library.
Provide BLPAPI types.
Definition blpapi_name.h:242
static bool hasName(const char *nameString)
Definition blpapi_name.h:502
Name & operator=(const Name &rhs)
Definition blpapi_name.h:479
size_t length() const
Definition blpapi_name.h:493
blpapi_Name_t * impl() const
Definition blpapi_name.h:495
static Name findName(const char *nameString)
Definition blpapi_name.h:497
~Name()
Definition blpapi_name.h:472
const char * string() const
Definition blpapi_name.h:488
Name()
Definition blpapi_name.h:457
size_t hash() const
Definition blpapi_name.h:507
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition blpapi_event.h:739
Definition blpapi_abstractsession.h:212
bool operator==(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:637
bool operator>(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2116
bool operator<=(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2111
bool operator>=(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2121
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition blpapi_correlationid.h:680
bool operator!=(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:660
bool operator<(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:665
Definition blpapi_abstractsession.h:211