BLPAPI C++ 3.26.6
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
37
38#ifndef INCLUDED_BLPAPI_NAME
39#define INCLUDED_BLPAPI_NAME
40
68
69#include <blpapi_defs.h>
70#include <blpapi_types.h>
71
72#include <stddef.h>
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
79
82
95BLPAPI_EXPORT
96blpapi_Name_t *blpapi_Name_create(const char *nameString);
97
105BLPAPI_EXPORT
106void blpapi_Name_destroy(blpapi_Name_t *name);
107
116BLPAPI_EXPORT
117blpapi_Name_t *blpapi_Name_duplicate(const blpapi_Name_t *src);
118
128BLPAPI_EXPORT
129int blpapi_Name_equalsStr(const blpapi_Name_t *name, const char *string);
130
138BLPAPI_EXPORT
139const char *blpapi_Name_string(const blpapi_Name_t *name);
140
150BLPAPI_EXPORT
151size_t blpapi_Name_length(const blpapi_Name_t *name);
152
163BLPAPI_EXPORT
164blpapi_Name_t *blpapi_Name_findName(const char *nameString);
165
168
169#ifdef __cplusplus
170}
171
172#include <cstring> // for strcmp
173#include <iostream>
174#include <utility> // for swap
175
176namespace BloombergLP {
177namespace blpapi {
184
228class Name {
229
230 blpapi_Name_t *d_impl_p;
231
232 public:
233 // CLASS METHODS
234
235 static Name findName(const char *nameString);
244
245 static bool hasName(const char *nameString);
252
253 Name();
259
260 explicit Name(blpapi_Name_t *handle);
261
262 Name(const Name& original);
267
268 explicit Name(const char *nameString);
278
279 ~Name();
283
284 // MANIPULATORS
285
286 Name& operator=(const Name& rhs);
291
292 // ACCESSORS
293
294 const char *string() const;
300
301 size_t length() const;
308
309 size_t hash() const;
316
318 blpapi_Name_t *impl() const;
320};
321
324
325// FREE OPERATORS
326bool operator==(const Name& lhs, const Name& rhs);
333
334bool operator!=(const Name& lhs, const Name& rhs);
342
343bool operator==(const Name& lhs, const char *rhs);
351
352bool operator!=(const Name& lhs, const char *rhs);
360
361bool operator==(const char *lhs, const Name& rhs);
369
370bool operator!=(const char *lhs, const Name& rhs);
378
379bool operator<(const Name& lhs, const Name& rhs);
389
390bool operator<=(const Name& lhs, const Name& rhs);
400
401bool operator>(const Name& lhs, const Name& rhs);
411
412bool operator>=(const Name& lhs, const Name& rhs);
422
423std::ostream& operator<<(std::ostream& stream, const Name& name);
430
431//=============================================================================
432// INLINE FUNCTION DEFINITIONS
433//=============================================================================
434
435// ----------
436// class Name
437// ----------
438
439inline Name::Name(blpapi_Name_t *handle)
440 : d_impl_p(handle)
441{
442}
443
445 : d_impl_p(0)
446{
447}
448
449inline Name::Name(const Name& original)
450 : d_impl_p(blpapi_Name_duplicate(original.d_impl_p))
451{
452}
453
454inline Name::Name(const char *nameString)
455{
456 d_impl_p = blpapi_Name_create(nameString);
457}
458
460{
461 if (d_impl_p) {
462 blpapi_Name_destroy(d_impl_p);
463 }
464}
465
466inline Name& Name::operator=(const Name& rhs)
467{
468 using std::swap;
469
470 Name tmp(rhs);
471 swap(tmp.d_impl_p, d_impl_p);
472 return *this;
473}
474
475inline const char *Name::string() const
476{
477 return blpapi_Name_string(d_impl_p);
478}
479
480inline size_t Name::length() const { return blpapi_Name_length(d_impl_p); }
481
483inline blpapi_Name_t *Name::impl() const { return d_impl_p; }
485
486inline Name Name::findName(const char *nameString)
487{
488 return Name(blpapi_Name_findName(nameString));
489}
490
491inline bool Name::hasName(const char *nameString)
492{
493 return blpapi_Name_findName(nameString) ? true : false;
494}
495
496inline size_t Name::hash() const { return reinterpret_cast<size_t>(impl()); }
497
498} // close namespace blpapi
499
500inline bool blpapi::operator==(const Name& lhs, const Name& rhs)
501{
502 return (lhs.impl() == rhs.impl());
503}
504
505inline bool blpapi::operator!=(const Name& lhs, const Name& rhs)
506{
507 return !(lhs == rhs);
508}
509
510inline bool blpapi::operator==(const Name& lhs, const char *rhs)
511{
512 return blpapi_Name_equalsStr(lhs.impl(), rhs) != 0;
513}
514
515inline bool blpapi::operator!=(const Name& lhs, const char *rhs)
516{
517 return !(lhs == rhs);
518}
519
520inline bool blpapi::operator==(const char *lhs, const Name& rhs)
521{
522 return rhs == lhs;
523}
524
525inline bool blpapi::operator!=(const char *lhs, const Name& rhs)
526{
527 return !(rhs == lhs);
528}
529
530inline bool blpapi::operator<(const Name& lhs, const Name& rhs)
531{
532 return lhs.impl() < rhs.impl();
533}
534
535inline bool blpapi::operator<=(const Name& lhs, const Name& rhs)
536{
537 return !(rhs < lhs);
538}
539
540inline bool blpapi::operator>(const Name& lhs, const Name& rhs)
541{
542 return rhs < lhs;
543}
544
545inline bool blpapi::operator>=(const Name& lhs, const Name& rhs)
546{
547 return !(lhs < rhs);
548}
549
550inline std::ostream& blpapi::operator<<(std::ostream& stream, const Name& name)
551{
552 return stream << name.string();
553}
554
555} // close namespace BloombergLP
556
557#endif // __cplusplus
558
559#endif // #ifndef INCLUDED_BLPAPI_NAME
Common definitions used by the library.
Provide BLPAPI types.
Definition blpapi_name.h:228
static bool hasName(const char *nameString)
Definition blpapi_name.h:491
Name & operator=(const Name &rhs)
Definition blpapi_name.h:466
size_t length() const
Definition blpapi_name.h:480
static Name findName(const char *nameString)
Definition blpapi_name.h:486
~Name()
Definition blpapi_name.h:459
const char * string() const
Definition blpapi_name.h:475
Name()
Definition blpapi_name.h:444
size_t hash() const
Definition blpapi_name.h:496
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition blpapi_event.h:860
Definition blpapi_abstractsession.h:452
bool operator==(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:718
bool operator>(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2154
bool operator<=(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2149
bool operator>=(const Datetime &lhs, const Datetime &rhs)
Definition blpapi_datetime.h:2159
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition blpapi_correlationid.h:761
bool operator!=(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:741
bool operator<(const CorrelationId &lhs, const CorrelationId &rhs)
Definition blpapi_correlationid.h:746
Definition blpapi_abstractsession.h:451